--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_DolibarrModules.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_DolibarrModules.class.php
@@ -10 +10 @@
- * Copyright (C) 2019-2022  Frédéric France         <frederic.france@netlogic.fr>

+ * Copyright (C) 2019       Frédéric France         <frederic.france@netlogic.fr>

@@ -39,300 +39,242 @@
-	/**

-	 * @var DoliDb Database handler

-	 */

-	public $db;

-

-	/**

-	 * @var int Module unique ID

-	 * @see https://wiki.dolibarr.org/index.php/List_of_modules_id

-	 */

-	public $numero;

-

-	/**

-	 * @var   string Publisher name

-	 * @since 4.0.0

-	 */

-	public $editor_name;

-

-	/**

-	 * @var   string URL of module at publisher site

-	 * @since 4.0.0

-	 */

-	public $editor_url;

-

-	/**

-	 * @var string Family

-	 * @see $familyinfo

-	 *

-	 * Native values: 'crm', 'financial', 'hr', 'projects', 'products', 'ecm', 'technic', 'other'.

-	 * Use familyinfo to declare a custom value.

-	 */

-	public $family;

-

-	/**

-	 * @var array Custom family informations

-	 * @see $family

-	 *

-	 * e.g.:

-	 * array(

-	 *     'myownfamily' => array(

-	 *         'position' => '001',

-	 *         'label' => $langs->trans("MyOwnFamily")

-	 *     )

-	 * );

-	 */

-	public $familyinfo;

-

-	/**

-	 * @var string    Module position on 2 digits

-	 */

-	public $module_position = '50';

-

-	/**

-	 * @var string Module name

-	 *

-	 * Only used if Module[ID]Name translation string is not found.

-	 *

-	 * You can use the following code to automatically derive it from your module's class name:

-	 * preg_replace('/^mod/i', '', get_class($this))

-	 */

-	public $name;

-

-	/**

-	 * @var string[] Paths to create when module is activated

-	 *

-	 * e.g.: array('/mymodule/temp')

-	 */

-	public $dirs = array();

-

-	/**

-	 * @var array Module boxes

-	 */

-	public $boxes = array();

-

-	/**

-	 * @var array Module constants

-	 */

-	public $const = array();

-

-	/**

-	 * @var array Module cron jobs entries

-	 */

-	public $cronjobs = array();

-

-	/**

-	 * @var array 	Module access rights

-	 */

-	public $rights;

-

-	/**

-	 * @var int		1=Admin is always granted of permission of modules (even when module is disabled)

-	 */

-	public $rights_admin_allowed;

-

-	/**

-	 * @var string 	Module access rights family

-	 */

-	public $rights_class;

-

-	/**

-	 * @var array|int 	Module menu entries (1 means the menu entries are not declared into module descriptor but are hardcoded into menu manager)

-	 */

-	public $menu = array();

-

-	/**

-	 * @var array Module parts

-	 *  array(

-	 *      // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)

-	 *      'triggers' => 0,

-	 *      // Set this to 1 if module has its own login method directory (/mymodule/core/login)

-	 *      'login' => 0,

-	 *      // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)

-	 *      'substitutions' => 0,

-	 *      // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)

-	 *      'menus' => 0,

-	 *      // Set this to 1 if module has its own theme directory (/mymodule/theme)

-	 *      'theme' => 0,

-	 *      // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)

-	 *      'tpl' => 0,

-	 *      // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)

-	 *      'barcode' => 0,

-	 *      // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)

-	 *      'models' => 0,

-	 *      // Set this to relative path of css file if module has its own css file

-	 *      'css' => '/mymodule/css/mymodule.css.php',

-	 *      // Set this to relative path of js file if module must load a js on all pages

-	 *      'js' => '/mymodule/js/mymodule.js',

-	 *      // Set here all hooks context managed by module

-	 *      'hooks' => array('hookcontext1','hookcontext2')

-	 *  )

-	 */

-	public $module_parts = array();

-

-	/**

-	 * @var        string Module documents ?

-	 * @deprecated Seems unused anywhere

-	 */

-	public $docs;

-

-	/**

-	 * @var        string ?

-	 * @deprecated Seems unused anywhere

-	 */

-	public $dbversion = "-";

-

-	/**

-	 * @var string Error message

-	 */

-	public $error;

-

-	/**

-	 * @var string[] Array of Errors messages

-	 */

-	public $errors;

-

-	/**

-	 * @var string Module version

-	 * @see http://semver.org

-	 *

-	 * The following keywords can also be used:

-	 * 'development'

-	 * 'experimental'

-	 * 'dolibarr': only for core modules that share its version

-	 * 'dolibarr_deprecated': only for deprecated core modules

-	 */

-	public $version;

-

-	/**

-	 * Module last version

-	 * @var string $lastVersion

-	 */

-	public $lastVersion = '';

-

-	/**

-	 * true indicate this module need update

-	 * @var bool $needUpdate

-	 */

-	public $needUpdate = false;

-

-	/**

-	 * @var string Module description (short text)

-	 *

-	 * Only used if Module[ID]Desc translation string is not found.

-	 */

-	public $description;

-

-	/**

-	 * @var   string Module description (long text)

-	 * @since 4.0.0

-	 *

-	 * HTML content supported.

-	 */

-	public $descriptionlong;

-

-	/**

-	 * @var array dictionaries description

-	 */

-	public $dictionaries;

-

-	/**

-	 * @var array tabs description

-	 */

-	public $tabs;

-

-	// For exports

-

-	/**

-	 * @var string Module export code

-	 */

-	public $export_code;

-

-	/**

-	 * @var string Module export label

-	 */

-	public $export_label;

-

-	public $export_icon;

-

-	/**

-	 * @var array export enabled

-	 */

-	public $export_enabled;

-	public $export_permission;

-	public $export_fields_array;

-	public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid'

-	public $export_entities_array;

-	public $export_aggregate_array;

-	public $export_examplevalues_array;

-	public $export_help_array;

-	public $export_special_array; // special or computed field

-	public $export_dependencies_array;

-	public $export_sql_start;

-	public $export_sql_end;

-	public $export_sql_order;

-

-

-	// For import

-

-	/**

-	 * @var string Module import code

-	 */

-	public $import_code;

-

-	/**

-	 * @var string Module import label

-	 */

-	public $import_label;

-

-	public $import_icon;

-	public $import_entities_array;

-	public $import_tables_array;

-	public $import_tables_creator_array;

-	public $import_fields_array;

-	public $import_fieldshidden_array;

-	public $import_convertvalue_array;

-	public $import_regex_array;

-	public $import_examplevalues_array;

-	public $import_updatekeys_array;

-	public $import_run_sql_after_array;

-	public $import_TypeFields_array;

-	public $import_help_array;

-

-	/**

-	 * @var string Module constant name

-	 */

-	public $const_name;

-

-	/**

-	 * @var bool Module can't be disabled

-	 */

-	public $always_enabled;

-

-	/**

-	 * @var bool Module is disabled

-	 */

-	public $disabled;

-

-	/**

-	 * @var int Module is enabled globally (Multicompany support)

-	 */

-	public $core_enabled;

-

-	/**

-	 * @var string Name of image file used for this module

-	 *

-	 * If file is in theme/yourtheme/img directory under name object_pictoname.png use 'pictoname'

-	 * If file is in module/img directory under name object_pictoname.png use 'pictoname@module'

-	 */

-	public $picto;

-

-	/**

-	 * @var string[]|string 	List of config pages (Old modules uses a string. New one must use an array)

-	 *

-	 * Name of php pages stored into module/admin directory, used to setup module.

-	 * e.g.: array("setup.php@mymodule")

-	 */

-	public $config_page_url;

-

-

-	/**

-	 * @var string[] List of module class names that must be enabled if this module is enabled. e.g.: array('modAnotherModule', 'FR'=>'modYetAnotherModule')

+    /**

+     * @var DoliDb Database handler

+     */

+    public $db;

+

+    /**

+     * @var int Module unique ID

+     * @see https://wiki.dolibarr.org/index.php/List_of_modules_id

+     */

+    public $numero;

+

+    /**

+     * @var   string Publisher name

+     * @since 4.0.0

+     */

+    public $editor_name;

+

+    /**

+     * @var   string URL of module at publisher site

+     * @since 4.0.0

+     */

+    public $editor_url;

+

+    /**

+     * @var string Family

+     * @see $familyinfo

+     *

+     * Native values: 'crm', 'financial', 'hr', 'projects', 'products', 'ecm', 'technic', 'other'.

+     * Use familyinfo to declare a custom value.

+     */

+    public $family;

+

+    /**

+     * @var array Custom family informations

+     * @see $family

+     *

+     * e.g.:

+     * array(

+     *     'myownfamily' => array(

+     *         'position' => '001',

+     *         'label' => $langs->trans("MyOwnFamily")

+     *     )

+     * );

+     */

+    public $familyinfo;

+

+    /**

+     * @var string    Module position on 2 digits

+     */

+    public $module_position = '50';

+

+    /**

+     * @var string Module name

+     *

+     * Only used if Module[ID]Name translation string is not found.

+     *

+     * You can use the following code to automatically derive it from your module's class name:

+     * preg_replace('/^mod/i', '', get_class($this))

+     */

+    public $name;

+

+    /**

+     * @var string[] Paths to create when module is activated

+     *

+     * e.g.: array('/mymodule/temp')

+     */

+    public $dirs = array();

+

+    /**

+     * @var array Module boxes

+     */

+    public $boxes = array();

+

+    /**

+     * @var array Module constants

+     */

+    public $const = array();

+

+    /**

+     * @var array Module cron jobs entries

+     */

+    public $cronjobs = array();

+

+    /**

+     * @var array Module access rights

+     */

+    public $rights;

+

+    /**

+     * @var string Module access rights family

+     */

+    public $rights_class;

+

+    /**

+     * @var array Module menu entries

+     */

+    public $menu = array();

+

+    /**

+     * @var array Module parts

+     *  array(

+     *      // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)

+     *      'triggers' => 0,

+     *      // Set this to 1 if module has its own login method directory (/mymodule/core/login)

+     *      'login' => 0,

+     *      // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)

+     *      'substitutions' => 0,

+     *      // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)

+     *      'menus' => 0,

+     *      // Set this to 1 if module has its own theme directory (/mymodule/theme)

+     *      'theme' => 0,

+     *      // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)

+     *      'tpl' => 0,

+     *      // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)

+     *      'barcode' => 0,

+     *      // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)

+     *      'models' => 0,

+     *      // Set this to relative path of css file if module has its own css file

+     *      'css' => '/mymodule/css/mymodule.css.php',

+     *      // Set this to relative path of js file if module must load a js on all pages

+     *      'js' => '/mymodule/js/mymodule.js',

+     *      // Set here all hooks context managed by module

+     *      'hooks' => array('hookcontext1','hookcontext2')

+     *  )

+     */

+    public $module_parts = array();

+

+    /**

+     * @var        string Module documents ?

+     * @deprecated Seems unused anywhere

+     */

+    public $docs;

+

+    /**

+     * @var        string ?

+     * @deprecated Seems unused anywhere

+     */

+    public $dbversion = "-";

+

+    /**

+     * @var string Error message

+     */

+    public $error;

+

+    /**

+     * @var string Module version

+     * @see http://semver.org

+     *

+     * The following keywords can also be used:

+     * 'development'

+     * 'experimental'

+     * 'dolibarr': only for core modules that share its version

+     * 'dolibarr_deprecated': only for deprecated core modules

+     */

+    public $version;

+

+    /**

+     * @var string Module description (short text)

+     *

+     * Only used if Module[ID]Desc translation string is not found.

+     */

+    public $description;

+

+    /**

+     * @var   string Module description (long text)

+     * @since 4.0.0

+     *

+     * HTML content supported.

+     */

+    public $descriptionlong;

+

+

+    // For exports

+

+    /**

+     * @var string Module export code

+     */

+    public $export_code;

+

+    /**

+     * @var string Module export label

+     */

+    public $export_label;

+

+    public $export_permission;

+    public $export_fields_array;

+    public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid'

+    public $export_entities_array;

+    public $export_special_array; // special or computed field

+    public $export_dependencies_array;

+    public $export_sql_start;

+    public $export_sql_end;

+    public $export_sql_order;

+

+

+    // For import

+

+    /**

+     * @var string Module import code

+     */

+    public $import_code;

+

+    /**

+     * @var string Module import label

+     */

+    public $import_label;

+

+

+    /**

+     * @var string Module constant name

+     */

+    public $const_name;

+

+    /**

+     * @var bool Module can't be disabled

+     */

+    public $always_enabled;

+

+    /**

+     * @var int Module is enabled globally (Multicompany support)

+     */

+    public $core_enabled;

+

+    /**

+     * @var string Name of image file used for this module

+     *

+     * If file is in theme/yourtheme/img directory under name object_pictoname.png use 'pictoname'

+     * If file is in module/img directory under name object_pictoname.png use 'pictoname@module'

+     */

+    public $picto;

+

+    /**

+     * @var string[] List of config pages

+     *

+     * Name of php pages stored into module/admin directory, used to setup module.

+     * e.g.: "admin.php@module"

+     */

+    public $config_page_url;

+

+

+    /**

+     * @var string[] List of module class names that must be enabled if this module is enabled. e.g.: array('modAnotherModule', 'FR'=>'modYetAnotherModule')

@@ -340,664 +282,656 @@
-	 */

-	public $depends;

-

-	/**

-	 * @var string[] List of module class names to disable if the module is disabled.

-	 * @see $depends

-	 */

-	public $requiredby;

-

-	/**

-	 * @var string[] List of module class names as string this module is in conflict with.

-	 * @see $depends

-	 */

-	public $conflictwith;

-

-	/**

-	 * @var string[] Module language files

-	 */

-	public $langfiles;

-

-	/**

-	 * @var array<string,string> Array of warnings to show when we activate the module

-	 *

-	 * array('always'='text') or array('FR'='text')

-	 */

-	public $warnings_activation;

-

-	/**

-	 * @var array<string,string> Array of warnings to show when we activate an external module

-	 *

-	 * array('always'='text') or array('FR'='text')

-	 */

-	public $warnings_activation_ext;

-

-	/**

-	 * @var array<string,string> Array of warnings to show when we disable the module

-	 *

-	 * array('always'='text') or array('FR'='text')

-	 */

-	public $warnings_unactivation;

-

-	/**

-	 * @var array Minimum version of PHP required by module.

-	 * e.g.: PHP ≥ 7.0 = array(7, 0)

-	 */

-	public $phpmin;

-

-	public $phpmax;

-

-	/**

-	 * @var array Minimum version of Dolibarr required by module.

-	 * e.g.: Dolibarr ≥ 3.6 = array(3, 6)

-	 */

-	public $need_dolibarr_version;

-

-	public $need_javascript_ajax;

-

-	public $enabled_bydefault;

-

-	/**

-	 * @var bool Whether to hide the module.

-	 */

-	public $hidden = false;

-

-	/**

-	 * @var string url to check for module update

-	 */

-	public $url_last_version;

-

-

-	/**

-	 * Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 * @param DoliDB $db Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-	}

-	// We should but can't set this as abstract because this will make dolibarr hang

-	// after migration due to old module not implementing. We must wait PHP is able to make

-	// a try catch on Fatal error to manage this correctly.

-	// We need constructor into function unActivateModule into admin.lib.php

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

-	/**

-	 * Enables a module.

-	 * Inserts all informations into database.

-	 *

-	 * @param array  $array_sql 	SQL requests to be executed when enabling module

-	 * @param string $options   	String with options when disabling module:

-	 *                          	- 'noboxes' = Do all actions but do not insert boxes

-	 *                          	- 'newboxdefonly' = Do all actions but for boxes, insert def of boxes only and not boxes activation

-	 * @return int                  1 if OK, 0 if KO

-	 */

-	protected function _init($array_sql, $options = '')

-	{

-		// phpcs:enable

-		global $conf;

-		$err = 0;

-

-		$this->db->begin();

-

-		// Insert activation module constant

-		if (!$err) {

-			$err += $this->_active();

-		}

-

-		// Insert new pages for tabs (into llx_const)

-		if (!$err) {

-			$err += $this->insert_tabs();

-		}

-

-		// Insert activation of module's parts

-		if (!$err) {

-			$err += $this->insert_module_parts();

-		}

-

-		// Insert constant defined by modules (into llx_const)

-		if (!$err && !preg_match('/newboxdefonly/', $options)) {

-			$err += $this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade

-		}

-

-		// Insert boxes def (into llx_boxes_def) and boxes setup (into llx_boxes)

-		if (!$err && !preg_match('/noboxes/', $options)) {

-			$err += $this->insert_boxes($options);

-		}

-

-		// Insert cron job entries (entry in llx_cronjobs)

-		if (!$err) {

-			$err += $this->insert_cronjobs();

-		}

-

-		// Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user.

-		if (!$err) {

-			$err += $this->insert_permissions(1, null, 1);

-		}

-

-		// Insert specific menus entries into database

-		if (!$err) {

-			$err += $this->insert_menus();

-		}

-

-		// Create module's directories

-		if (!$err) {

-			$err += $this->create_dirs();

-		}

-

-		// Execute addons requests

-		$num = count($array_sql);

-		for ($i = 0; $i < $num; $i++) {

-			if (!$err) {

-				$val = $array_sql[$i];

-				$sql = $val;

-				$ignoreerror = 0;

-				if (is_array($val)) {

-					$sql = $val['sql'];

-					$ignoreerror = $val['ignoreerror'];

-				}

-				// Add current entity id

-				$sql = str_replace('__ENTITY__', $conf->entity, $sql);

-

-				dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror, LOG_DEBUG);

-				$result = $this->db->query($sql, $ignoreerror);

-				if (!$result) {

-					if (!$ignoreerror) {

-						$this->error = $this->db->lasterror();

-						$err++;

-					} else {

-						dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING);

-					}

-				}

-			}

-		}

-

-		// Return code

-		if (!$err) {

-			$this->db->commit();

-			return 1;

-		} else {

-			$this->db->rollback();

-			return 0;

-		}

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

-	/**

-	 * Disable function. Deletes the module constants and boxes from the database.

-	 *

-	 * @param string[] $array_sql SQL requests to be executed when module is disabled

-	 * @param string   $options   Options when disabling module:

-	 *

-	 * @return int                     1 if OK, 0 if KO

-	 */

-	protected function _remove($array_sql, $options = '')

-	{

-		// phpcs:enable

-		$err = 0;

-

-		$this->db->begin();

-

-		// Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const)

-		if (!$err) {

-			$err += $this->_unactive();

-		}

-

-		// Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const)

-		if (!$err) {

-			$err += $this->delete_tabs();

-		}

-

-		// Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const)

-		if (!$err) {

-			$err += $this->delete_module_parts();

-		}

-

-		// Remove constants defined by modules

-		if (!$err) {

-			$err += $this->delete_const();

-		}

-

-		// Remove list of module's available boxes (entry in llx_boxes)

-		if (!$err && !preg_match('/(newboxdefonly|noboxes)/', $options)) {

-			$err += $this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only

-		}

-

-		// Remove list of module's cron job entries (entry in llx_cronjobs)

-		if (!$err) {

-			$err += $this->delete_cronjobs();

-		}

-

-		// Remove module's permissions from list of available permissions (entries in llx_rights_def)

-		if (!$err) {

-			$err += $this->delete_permissions();

-		}

-

-		// Remove module's menus (entries in llx_menu)

-		if (!$err) {

-			$err += $this->delete_menus();

-		}

-

-		// Remove module's directories

-		if (!$err) {

-			$err += $this->delete_dirs();

-		}

-

-		// Run complementary sql requests

-		$num = count((array) $array_sql);

-		for ($i = 0; $i < $num; $i++) {

-			if (!$err) {

-				dol_syslog(get_class($this)."::_remove", LOG_DEBUG);

-				$result = $this->db->query($array_sql[$i]);

-				if (!$result) {

-					$this->error = $this->db->error();

-					$err++;

-				}

-			}

-		}

-

-		// Return code

-		if (!$err) {

-			$this->db->commit();

-			return 1;

-		} else {

-			$this->db->rollback();

-			return 0;

-		}

-	}

-

-

-	/**

-	 * Gives the translated module name if translation exists in admin.lang or into language files of module.

-	 * Otherwise return the module key name.

-	 *

-	 * @return string  Translated module name

-	 */

-	public function getName()

-	{

-		global $langs;

-		$langs->load("admin");

-

-		if ($langs->transnoentitiesnoconv("Module".$this->numero."Name") != "Module".$this->numero."Name") {

-			// If module name translation exists

-			return $langs->transnoentitiesnoconv("Module".$this->numero."Name");

-		} else {

-			// If module name translation using it's unique id does not exist, we try to use its name to find translation

-			if (is_array($this->langfiles)) {

-				foreach ($this->langfiles as $val) {

-					if ($val) {

-						$langs->load($val);

-					}

-				}

-			}

-

-			if ($langs->trans("Module".$this->name."Name") != "Module".$this->name."Name") {

-				// If module name translation exists

-				return $langs->transnoentitiesnoconv("Module".$this->name."Name");

-			}

-

-			// Last chance with simple label

-			return $langs->transnoentitiesnoconv($this->name);

-		}

-	}

-

-

-	/**

-	 * Gives the translated module description if translation exists in admin.lang or the default module description

-	 *

-	 * @return string  Translated module description

-	 */

-	public function getDesc()

-	{

-		global $langs;

-		$langs->load("admin");

-

-		if ($langs->transnoentitiesnoconv("Module".$this->numero."Desc") != "Module".$this->numero."Desc") {

-			// If module description translation exists

-			return $langs->transnoentitiesnoconv("Module".$this->numero."Desc");

-		} else {

-			// If module description translation does not exist using its unique id, we can use its name to find translation

-			if (is_array($this->langfiles)) {

-				foreach ($this->langfiles as $val) {

-					if ($val) {

-						$langs->load($val);

-					}

-				}

-			}

-

-			if ($langs->transnoentitiesnoconv("Module".$this->name."Desc") != "Module".$this->name."Desc") {

-				// If module name translation exists

-				return $langs->trans("Module".$this->name."Desc");

-			}

-

-			// Last chance with simple label

-			return $langs->trans($this->description);

-		}

-	}

-

-	/**

-	 * Gives the long description of a module. First check README-la_LA.md then README.md

-	 * If no markdown files found, it returns translated value of the key ->descriptionlong.

-	 *

-	 * @return string     Long description of a module from README.md of from property.

-	 */

-	public function getDescLong()

-	{

-		global $langs;

-		$langs->load("admin");

-

-		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-		include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

-

-		$content='';

-		$pathoffile = $this->getDescLongReadmeFound();

-

-		if ($pathoffile) {     // Mostly for external modules

-			$content = file_get_contents($pathoffile);

-

-			if ((float) DOL_VERSION >= 6.0) {

-				@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';

-

-				$content = dolMd2Html(

-					$content,

-					'parsedown',

-					array(

-						'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1),

-						'img/' => dol_buildpath(strtolower($this->name).'/img/', 1),

-						'images/' => dol_buildpath(strtolower($this->name).'/images/', 1),

-					)

-				);

-

-				$content = preg_replace('/<a href="/', '<a target="_blank" rel="noopener noreferrer" href="', $content);

-			} else {

-				$content = nl2br($content);

-			}

-		} else {

-			// Mostly for internal modules

-			if (!empty($this->descriptionlong)) {

-				if (is_array($this->langfiles)) {

-					foreach ($this->langfiles as $val) {

-						if ($val) {

-							$langs->load($val);

-						}

-					}

-				}

-

-				$content = $langs->transnoentitiesnoconv($this->descriptionlong);

-			}

-		}

-

-		return $content;

-	}

-

-	/**

-	 * Return path of file if a README file was found.

-	 *

-	 * @return string      Path of file if a README file was found.

-	 */

-	public function getDescLongReadmeFound()

-	{

-		global $langs;

-

-		$filefound = false;

-

-		// Define path to file README.md.

-		// First check README-la_LA.md then README-la.md then README.md

-		$pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$langs->defaultlang.'.md', 0);

-		if (dol_is_file($pathoffile)) {

-			$filefound = true;

-		}

-		if (!$filefound) {

-			$tmp = explode('_', $langs->defaultlang);

-			$pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$tmp[0].'.md', 0);

-			if (dol_is_file($pathoffile)) {

-				$filefound = true;

-			}

-		}

-		if (!$filefound) {

-			$pathoffile = dol_buildpath(strtolower($this->name).'/README.md', 0);

-			if (dol_is_file($pathoffile)) {

-				$filefound = true;

-			}

-		}

-

-		return ($filefound ? $pathoffile : '');

-	}

-

-

-	/**

-	 * Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md

-	 *

-	 * @return string  Content of ChangeLog

-	 */

-	public function getChangeLog()

-	{

-		global $langs;

-		$langs->load("admin");

-

-		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-		include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

-

-		$filefound = false;

-

-		// Define path to file README.md.

-		// First check ChangeLog-la_LA.md then ChangeLog.md

-		$pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog-'.$langs->defaultlang.'.md', 0);

-		if (dol_is_file($pathoffile)) {

-			$filefound = true;

-		}

-		if (!$filefound) {

-			$pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog.md', 0);

-			if (dol_is_file($pathoffile)) {

-				$filefound = true;

-			}

-		}

-

-		if ($filefound) {     // Mostly for external modules

-			$content = file_get_contents($pathoffile);

-

-			if ((float) DOL_VERSION >= 6.0) {

-				@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';

-

-				$content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1)));

-			} else {

-				$content = nl2br($content);

-			}

-		}

-

-		return $content;

-	}

-

-	/**

-	 * Gives the publisher name

-	 *

-	 * @return string  Publisher name

-	 */

-	public function getPublisher()

-	{

-		return $this->editor_name;

-	}

-

-	/**

-	 * Gives the publisher url

-	 *

-	 * @return string  Publisher url

-	 */

-	public function getPublisherUrl()

-	{

-		return $this->editor_url;

-	}

-

-	/**

-	 * Gives module version (translated if param $translated is on)

-	 * For 'experimental' modules, gives 'experimental' translation

-	 * For 'dolibarr' modules, gives Dolibarr version

-	 *

-	 * @param  int 		$translated 		1=Special version keys are translated, 0=Special version keys are not translated

-	 * @return string               		Module version

-	 */

-	public function getVersion($translated = 1)

-	{

-		global $langs;

-		$langs->load("admin");

-

-		$ret = '';

-

-		$newversion = preg_replace('/_deprecated/', '', $this->version);

-		if ($newversion == 'experimental') {

-			$ret = ($translated ? $langs->transnoentitiesnoconv("VersionExperimental") : $newversion);

-		} elseif ($newversion == 'development') {

-			$ret = ($translated ? $langs->transnoentitiesnoconv("VersionDevelopment") : $newversion);

-		} elseif ($newversion == 'dolibarr') {

-			$ret = DOL_VERSION;

-		} elseif ($newversion) {

-			$ret = $newversion;

-		} else {

-			$ret = ($translated ? $langs->transnoentitiesnoconv("VersionUnknown") : 'unknown');

-		}

-

-		if (preg_match('/_deprecated/', $this->version)) {

-			$ret .= ($translated ? ' ('.$langs->transnoentitiesnoconv("Deprecated").')' : $this->version);

-		}

-		return $ret;

-	}

-

-	/**

-	 * Gives the module position

-	 *

-	 * @return int  	Module position (an external module should never return a value lower than 100000. 1-100000 are reserved for core)

-	 */

-	public function getModulePosition()

-	{

-		if (in_array($this->version, array('dolibarr', 'experimental', 'development'))) {	// core module

-			return $this->module_position;

-		} else {																			// external module

-			if ($this->module_position >= 100000) {

-				return $this->module_position;

-			} else {

-				return $this->module_position + 100000;

-			}

-		}

-	}

-

-	/**

-	 * Tells if module is core or external.

-	 * 'dolibarr' and 'dolibarr_deprecated' is core

-	 * 'experimental' and 'development' is core

-	 *

-	 * @return string  'core', 'external' or 'unknown'

-	 */

-	public function isCoreOrExternalModule()

-	{

-		if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') {

-			return 'core';

-		}

-		if (!empty($this->version) && !in_array($this->version, array('experimental', 'development'))) {

-			return 'external';

-		}

-		if (!empty($this->editor_name) || !empty($this->editor_url)) {

-			return 'external';

-		}

-		if ($this->numero >= 100000) {

-			return 'external';

-		}

-		return 'unknown';

-	}

-

-

-	/**

-	 * Gives module related language files list

-	 *

-	 * @return string[]    Language files list

-	 */

-	public function getLangFilesArray()

-	{

-		return $this->langfiles;

-	}

-

-	/**

-	 * Gives translated label of an export dataset

-	 *

-	 * @param int $r Dataset index

-	 *

-	 * @return string       Translated databaset label

-	 */

-	public function getExportDatasetLabel($r)

-	{

-		global $langs;

-

-		$langstring = "ExportDataset_".$this->export_code[$r];

-		if ($langs->trans($langstring) == $langstring) {

-			// Translation not found

-			return $langs->trans($this->export_label[$r]);

-		} else {

-			// Translation found

-			return $langs->trans($langstring);

-		}

-	}

-

-

-	/**

-	 * Gives translated label of an import dataset

-	 *

-	 * @param int $r Dataset index

-	 *

-	 * @return string      Translated dataset label

-	 */

-	public function getImportDatasetLabel($r)

-	{

-		global $langs;

-

-		$langstring = "ImportDataset_".$this->import_code[$r];

-		//print "x".$langstring;

-		if ($langs->trans($langstring) == $langstring) {

-			// Translation not found

-			return $langs->transnoentitiesnoconv($this->import_label[$r]);

-		} else {

-			// Translation found

-			return $langs->transnoentitiesnoconv($langstring);

-		}

-	}

-

-

-	/**

-	 * Gives the last date of activation

-	 *

-	 * @return 	int|string       	Date of last activation or '' if module was never activated

-	 */

-	public function getLastActivationDate()

-	{

-		global $conf;

-

-		$err = 0;

-

-		$sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const";

-		$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

-		$sql .= " AND entity IN (0, ".((int) $conf->entity).")";

-

-		dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);

-		$resql = $this->db->query($sql);

-		if (!$resql) {

-			$err++;

-		} else {

-			$obj = $this->db->fetch_object($resql);

-			if ($obj) {

-				return $this->db->jdate($obj->tms);

-			}

-		}

-

-		return '';

-	}

-

-

-	/**

-	 * Gives the last author of activation

-	 *

-	 * @return array       Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation)

-	 */

-	public function getLastActivationInfo()

-	{

-		global $conf;

-

-		$err = 0;

+     */

+    public $depends;

+

+    /**

+     * @var string[] List of module class names to disable if the module is disabled.

+     * @see $depends

+     */

+    public $requiredby;

+

+    /**

+     * @var string[] List of module class names as string this module is in conflict with.

+     * @see $depends

+     */

+    public $conflictwith;

+

+    /**

+     * @var string[] Module language files

+     */

+    public $langfiles;

+

+    /**

+     * @var array<string,string> Array of warnings to show when we activate the module

+     *

+     * array('always'='text') or array('FR'='text')

+     */

+    public $warnings_activation;

+

+    /**

+     * @var array<string,string> Array of warnings to show when we activate an external module

+     *

+     * array('always'='text') or array('FR'='text')

+     */

+    public $warnings_activation_ext;

+

+

+    /**

+     * @var array Minimum version of PHP required by module.

+     * e.g.: PHP ≥ 5.4 = array(5, 4)

+     */

+    public $phpmin;

+

+    /**

+     * @var array Minimum version of Dolibarr required by module.

+     * e.g.: Dolibarr ≥ 3.6 = array(3, 6)

+     */

+    public $need_dolibarr_version;

+

+    /**

+     * @var bool Whether to hide the module.

+     */

+    public $hidden = false;

+

+

+

+

+

+    /**

+     * Constructor. Define names, constants, directories, boxes, permissions

+     *

+     * @param DoliDB $db Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+    }

+    // We should but can't set this as abstract because this will make dolibarr hang

+    // after migration due to old module not implementing. We must wait PHP is able to make

+    // a try catch on Fatal error to manage this correctly.

+    // We need constructor into function unActivateModule into admin.lib.php

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

+    /**

+     * Enables a module.

+     * Inserts all informations into database

+     *

+     * @param array  $array_sql SQL requests to be executed when enabling module

+     * @param string $options   String with options when disabling module:

+     *                          - 'noboxes' = Do not insert boxes -

+     *                          'newboxdefonly' = For boxes, insert def of

+     *                          boxes only and not boxes activation

+     *

+     * @return int                         1 if OK, 0 if KO

+     */

+    protected function _init($array_sql, $options = '')

+    {

+        // phpcs:enable

+        global $conf;

+        $err = 0;

+

+        $this->db->begin();

+

+        // Insert activation module constant

+        if (!$err) {

+            $err += $this->_active();

+        }

+

+        // Insert new pages for tabs (into llx_const)

+        if (!$err) {

+            $err += $this->insert_tabs();

+        }

+

+        // Insert activation of module's parts

+        if (!$err) {

+            $err += $this->insert_module_parts();

+        }

+

+        // Insert constant defined by modules (into llx_const)

+        if (!$err && !preg_match('/newboxdefonly/', $options)) {

+            $err += $this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade

+        }

+

+        // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes)

+        if (!$err && !preg_match('/noboxes/', $options)) {

+            $err += $this->insert_boxes($options);

+        }

+

+        // Insert cron job entries (entry in llx_cronjobs)

+        if (!$err) {

+            $err += $this->insert_cronjobs();

+        }

+

+        // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user.

+        if (!$err) {

+            $err += $this->insert_permissions(1, null, 1);

+        }

+

+        // Insert specific menus entries into database

+        if (!$err) {

+            $err += $this->insert_menus();

+        }

+

+        // Create module's directories

+        if (!$err) {

+            $err += $this->create_dirs();

+        }

+

+        // Execute addons requests

+        $num = count($array_sql);

+        for ($i = 0; $i < $num; $i++)

+        {

+            if (!$err) {

+                $val = $array_sql[$i];

+                $sql = $val;

+                $ignoreerror = 0;

+                if (is_array($val)) {

+                    $sql = $val['sql'];

+                    $ignoreerror = $val['ignoreerror'];

+                }

+                // Add current entity id

+                $sql = str_replace('__ENTITY__', $conf->entity, $sql);

+

+                dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror."", LOG_DEBUG);

+                $result = $this->db->query($sql, $ignoreerror);

+                if (!$result) {

+                    if (!$ignoreerror) {

+                         $this->error = $this->db->lasterror();

+                         $err++;

+                    }

+                    else

+                    {

+                         dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING);

+                    }

+                }

+            }

+        }

+

+        // Return code

+        if (!$err) {

+            $this->db->commit();

+            return 1;

+        }

+        else

+        {

+            $this->db->rollback();

+            return 0;

+        }

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

+    /**

+     * Disable function. Deletes the module constants and boxes from the database.

+     *

+     * @param string[] $array_sql SQL requests to be executed when module is disabled

+     * @param string   $options   Options when disabling module:

+     *

+     * @return int                     1 if OK, 0 if KO

+     */

+    protected function _remove($array_sql, $options = '')

+    {

+        // phpcs:enable

+        $err = 0;

+

+        $this->db->begin();

+

+        // Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const)

+        if (!$err) {

+            $err += $this->_unactive();

+        }

+

+        // Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const)

+        if (!$err) {

+            $err += $this->delete_tabs();

+        }

+

+        // Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const)

+        if (!$err) {

+            $err += $this->delete_module_parts();

+        }

+

+        // Remove constants defined by modules

+        if (!$err) {

+            $err += $this->delete_const();

+        }

+

+        // Remove list of module's available boxes (entry in llx_boxes)

+        if (!$err && !preg_match('/(newboxdefonly|noboxes)/', $options)) {

+            $err += $this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only

+        }

+

+        // Remove list of module's cron job entries (entry in llx_cronjobs)

+        if (!$err) {

+            $err += $this->delete_cronjobs();

+        }

+

+        // Remove module's permissions from list of available permissions (entries in llx_rights_def)

+        if (!$err) {

+            $err += $this->delete_permissions();

+        }

+

+        // Remove module's menus (entries in llx_menu)

+        if (!$err) {

+            $err += $this->delete_menus();

+        }

+

+        // Remove module's directories

+        if (!$err) {

+            $err += $this->delete_dirs();

+        }

+

+        // Run complementary sql requests

+        $num = count($array_sql);

+        for ($i = 0; $i < $num; $i++)

+        {

+            if (!$err) {

+                dol_syslog(get_class($this)."::_remove", LOG_DEBUG);

+                $result = $this->db->query($array_sql[$i]);

+                if (!$result) {

+                    $this->error = $this->db->error();

+                    $err++;

+                }

+            }

+        }

+

+        // Return code

+        if (!$err) {

+            $this->db->commit();

+            return 1;

+        }

+        else

+        {

+            $this->db->rollback();

+            return 0;

+        }

+    }

+

+

+    /**

+     * Gives the translated module name if translation exists in admin.lang or into language files of module.

+     * Otherwise return the module key name.

+     *

+     * @return string  Translated module name

+     */

+    public function getName()

+    {

+        global $langs;

+        $langs->load("admin");

+

+        if ($langs->transnoentitiesnoconv("Module".$this->numero."Name") != ("Module".$this->numero."Name")) {

+            // If module name translation exists

+            return $langs->transnoentitiesnoconv("Module".$this->numero."Name");

+        }

+        else

+        {

+            // If module name translation using it's unique id does not exist, we try to use its name to find translation

+            if (is_array($this->langfiles)) {

+                foreach ($this->langfiles as $val)

+                {

+                    if ($val) { $langs->load($val);

+                    }

+                }

+            }

+

+            if ($langs->trans("Module".$this->name."Name") != ("Module".$this->name."Name")) {

+                // If module name translation exists

+                return $langs->transnoentitiesnoconv("Module".$this->name."Name");

+            }

+

+            // Last chance with simple label

+            return $langs->transnoentitiesnoconv($this->name);

+        }

+    }

+

+

+    /**

+     * Gives the translated module description if translation exists in admin.lang or the default module description

+     *

+     * @return string  Translated module description

+     */

+    public function getDesc()

+    {

+        global $langs;

+        $langs->load("admin");

+

+        if ($langs->transnoentitiesnoconv("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) {

+            // If module description translation exists

+            return $langs->transnoentitiesnoconv("Module".$this->numero."Desc");

+        }

+        else

+        {

+            // If module description translation does not exist using its unique id, we can use its name to find translation

+            if (is_array($this->langfiles)) {

+                foreach ($this->langfiles as $val)

+                {

+                    if ($val) { $langs->load($val);

+                    }

+                }

+            }

+

+            if ($langs->transnoentitiesnoconv("Module".$this->name."Desc") != ("Module".$this->name."Desc")) {

+                // If module name translation exists

+                return $langs->trans("Module".$this->name."Desc");

+            }

+

+            // Last chance with simple label

+            return $langs->trans($this->description);

+        }

+    }

+

+    /**

+     * Gives the long description of a module. First check README-la_LA.md then README.md

+     * If no markdown files found, it returns translated value of the key ->descriptionlong.

+     *

+     * @return string     Long description of a module from README.md of from property.

+     */

+    public function getDescLong()

+    {

+        global $langs;

+        $langs->load("admin");

+

+        include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+        include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

+

+        $pathoffile = $this->getDescLongReadmeFound();

+

+        if ($pathoffile)     // Mostly for external modules

+        {

+            $content = file_get_contents($pathoffile);

+

+            if ((float) DOL_VERSION >= 6.0) {

+                @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';

+

+                $content = dolMd2Html(

+                    $content,

+                    'parsedown',

+                    array(

+                        'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1),

+                        'img/' => dol_buildpath(strtolower($this->name).'/img/', 1),

+                        'images/' => dol_buildpath(strtolower($this->name).'/images/', 1),

+                    )

+                );

+            }

+            else

+            {

+                $content = nl2br($content);

+            }

+        }

+        else

+        {

+            // Mostly for internal modules

+            if (!empty($this->descriptionlong)) {

+                if (is_array($this->langfiles)) {

+                    foreach ($this->langfiles as $val)

+                    {

+                        if ($val) { $langs->load($val);

+                        }

+                    }

+                }

+

+                $content = $langs->transnoentitiesnoconv($this->descriptionlong);

+            }

+        }

+

+        return $content;

+    }

+

+    /**

+     * Return path of file if a README file was found.

+     *

+     * @return string      Path of file if a README file was found.

+     */

+    public function getDescLongReadmeFound()

+    {

+        global $langs;

+

+        $filefound = false;

+

+        // Define path to file README.md.

+        // First check README-la_LA.md then README-la.md then README.md

+        $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$langs->defaultlang.'.md', 0);

+        if (dol_is_file($pathoffile)) {

+            $filefound = true;

+        }

+        if (!$filefound) {

+            $tmp = explode('_', $langs->defaultlang);

+            $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$tmp[0].'.md', 0);

+            if (dol_is_file($pathoffile)) {

+                $filefound = true;

+            }

+        }

+        if (!$filefound) {

+            $pathoffile = dol_buildpath(strtolower($this->name).'/README.md', 0);

+            if (dol_is_file($pathoffile)) {

+                $filefound = true;

+            }

+        }

+

+        return ($filefound ? $pathoffile : '');

+    }

+

+

+    /**

+     * Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md

+     *

+     * @return string  Content of ChangeLog

+     */

+    public function getChangeLog()

+    {

+        global $langs;

+        $langs->load("admin");

+

+        include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+        include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

+

+        $filefound = false;

+

+        // Define path to file README.md.

+        // First check ChangeLog-la_LA.md then ChangeLog.md

+        $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog-'.$langs->defaultlang.'.md', 0);

+        if (dol_is_file($pathoffile)) {

+            $filefound = true;

+        }

+        if (!$filefound) {

+            $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog.md', 0);

+            if (dol_is_file($pathoffile)) {

+                $filefound = true;

+            }

+        }

+

+        if ($filefound)     // Mostly for external modules

+        {

+            $content = file_get_contents($pathoffile);

+

+            if ((float) DOL_VERSION >= 6.0) {

+                @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';

+                $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1)));

+            }

+            else

+            {

+                $content = nl2br($content);

+            }

+        }

+

+        return $content;

+    }

+

+    /**

+     * Gives the publisher name

+     *

+     * @return string  Publisher name

+     */

+    public function getPublisher()

+    {

+        return $this->editor_name;

+    }

+

+    /**

+     * Gives the publisher url

+     *

+     * @return string  Publisher url

+     */

+    public function getPublisherUrl()

+    {

+        return $this->editor_url;

+    }

+

+    /**

+     * Gives module version (translated if param $translated is on)

+     * For 'experimental' modules, gives 'experimental' translation

+     * For 'dolibarr' modules, gives Dolibarr version

+     *

+     * @param  int $translated 1=Special version keys are translated, 0=Special version keys are not translated

+     * @return string                  Module version

+     */

+    public function getVersion($translated = 1)

+    {

+        global $langs;

+        $langs->load("admin");

+

+        $ret = '';

+

+        $newversion = preg_replace('/_deprecated/', '', $this->version);

+        if ($newversion == 'experimental') {

+            $ret = ($translated ? $langs->transnoentitiesnoconv("VersionExperimental") : $newversion);

+        } elseif ($newversion == 'development') {

+            $ret = ($translated ? $langs->transnoentitiesnoconv("VersionDevelopment") : $newversion);

+        } elseif ($newversion == 'dolibarr') {

+            $ret = DOL_VERSION;

+        } elseif ($newversion) {

+            $ret = $newversion;

+        } else {

+            $ret = ($translated ? $langs->transnoentitiesnoconv("VersionUnknown") : 'unknown');

+        }

+

+        if (preg_match('/_deprecated/', $this->version)) {

+            $ret .= ($translated ? ' ('.$langs->transnoentitiesnoconv("Deprecated").')' : $this->version);

+        }

+        return $ret;

+    }

+

+

+    /**

+     * Tells if module is core or external

+     *

+     * @return string  'core', 'external' or 'unknown'

+     */

+    public function isCoreOrExternalModule()

+    {

+        if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') {

+            return 'core';

+        }

+        if (!empty($this->version) && !in_array($this->version, array('experimental', 'development'))) {

+            return 'external';

+        }

+        if (!empty($this->editor_name) || !empty($this->editor_url)) {

+            return 'external';

+        }

+        if ($this->numero >= 100000) {

+            return 'external';

+        }

+        return 'unknown';

+    }

+

+

+    /**

+     * Gives module related language files list

+     *

+     * @return string[]    Language files list

+     */

+    public function getLangFilesArray()

+    {

+        return $this->langfiles;

+    }

+

+    /**

+     * Gives translated label of an export dataset

+     *

+     * @param int $r Dataset index

+     *

+     * @return string       Translated databaset label

+     */

+    public function getExportDatasetLabel($r)

+    {

+        global $langs;

+

+        $langstring = "ExportDataset_".$this->export_code[$r];

+        if ($langs->trans($langstring) == $langstring) {

+            // Translation not found

+            return $langs->trans($this->export_label[$r]);

+        }

+        else

+        {

+            // Translation found

+            return $langs->trans($langstring);

+        }

+    }

+

+

+    /**

+     * Gives translated label of an import dataset

+     *

+     * @param int $r Dataset index

+     *

+     * @return string      Translated dataset label

+     */

+    public function getImportDatasetLabel($r)

+    {

+        global $langs;

+

+        $langstring = "ImportDataset_".$this->import_code[$r];

+        //print "x".$langstring;

+        if ($langs->trans($langstring) == $langstring) {

+            // Translation not found

+            return $langs->transnoentitiesnoconv($this->import_label[$r]);

+        }

+        else

+        {

+            // Translation found

+            return $langs->transnoentitiesnoconv($langstring);

+        }

+    }

+

+

+    /**

+     * Gives the last date of activation

+     *

+     * @return 	int|string       	Date of last activation or '' if module was never activated

+     */

+    public function getLastActivationDate()

+    {

+        global $conf;

+

+        $err = 0;

+

+        $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const";

+        $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

+        $sql .= " AND entity IN (0, ".$conf->entity.")";

+

+        dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);

+        $resql = $this->db->query($sql);

+        if (!$resql)

+        {

+            $err++;

+        }

+        else

+        {

+            $obj = $this->db->fetch_object($resql);

+            if ($obj) {

+                return $this->db->jdate($obj->tms);

+            }

+        }

+

+        return '';

+    }

+

+

+    /**

+     * Gives the last author of activation

+     *

+     * @return array       Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation)

+     */

+    public function getLastActivationInfo()

+    {

+        global $conf;

+

+        $err = 0;

@@ -1009,1441 +943,1340 @@
-		dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);

-		$resql = $this->db->query($sql);

-		if (!$resql) {

-			$err++;

-		} else {

-			$obj = $this->db->fetch_object($resql);

-			if ($obj) {

-				$tmp = array();

-				if ($obj->note) {

-					$tmp = json_decode($obj->note, true);

-				}

-				return array(

-					'authorid' => empty($tmp['authorid']) ? '' : $tmp['authorid'],

-					'ip' => empty($tmp['ip']) ? '' : $tmp['ip'],

-					'lastactivationdate' => $this->db->jdate($obj->tms),

-					'lastactivationversion' => (!empty($tmp['lastactivationversion']) ? $tmp['lastactivationversion'] : 'unknown'),

-				);

-			}

-		}

-

-		return array();

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

-	/**

-	 * Insert constants for module activation

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	protected function _active()

-	{

-		// phpcs:enable

-		global $conf, $user;

-

-		$err = 0;

-

-		// Common module

-		$entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);

-

-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

-		$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

-		$sql .= " AND entity IN (0, ".$entity.")";

-

-		dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG);

-		$resql = $this->db->query($sql);

-		if (!$resql) {

-			$err++;

-		}

-

-		$note = json_encode(

-			array(

-				'authorid' => (is_object($user) ? $user->id : 0),

-				'ip' => (empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']),

-				'lastactivationversion' => $this->version,

-			)

-		);

-

-		$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES";

-		$sql .= " (".$this->db->encrypt($this->const_name);

-		$sql .= ", ".$this->db->encrypt('1');

-		$sql .= ", 0, ".((int) $entity);

-		$sql .= ", '".$this->db->escape($note)."')";

-

-		dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG);

-		$resql = $this->db->query($sql);

-		if (!$resql) {

-			$err++;

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

-	/**

-	 * Module deactivation

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	protected function _unactive()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		// Common module

-		$entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);

-

-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

-		$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

-		$sql .= " AND entity IN (0, ".$entity.")";

-

-		dol_syslog(get_class($this)."::_unactive", LOG_DEBUG);

-		$this->db->query($sql);

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

-	/**

-	 * Create tables and keys required by module:

-	 * - Files table.sql or table-module.sql with create table instructions

-	 * - Then table.key.sql or table-module.key.sql with create keys instructions

-	 * - Then data_xxx.sql (usualy provided by external modules only)

-	 * - Then update_xxx.sql (usualy provided by external modules only)

-	 * Files must be stored in subdirectory 'tables' or 'data' into directory $reldir (Example: '/install/mysql/' or '/module/sql/')

-	 * This function may also be called by :

-	 * - _load_tables('/install/mysql/', 'modulename') into the this->init() of core module descriptors.

-	 * - _load_tables('/mymodule/sql/') into the this->init() of external module descriptors.

-	 *

-	 * @param  	string 	$reldir 			Relative directory where to scan files. Example: '/install/mysql/' or '/module/sql/'

-	 * @param	string	$onlywithsuffix		Only with the defined suffix

-	 * @return 	int             			Return integer <=0 if KO, >0 if OK

-	 */

-	protected function _load_tables($reldir, $onlywithsuffix = '')

-	{

-		// phpcs:enable

-		global $conf;

-

-		$error = 0;

-		$dirfound = 0;

-

-		if (empty($reldir)) {

-			return 1;

-		}

-

-		include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

-

-		$ok = 1;

-		foreach ($conf->file->dol_document_root as $dirroot) {

-			if ($ok) {

-				$dirsql = $dirroot.$reldir;

-				$ok = 0;

-

-				// We will loop on xxx/, xxx/tables/, xxx/data/

-				$listofsubdir = array('', 'tables/', 'data/');

-				if ($this->db->type == 'pgsql') {

-					$listofsubdir[] = '../pgsql/functions/';

-				}

-

-				foreach ($listofsubdir as $subdir) {

-					$dir = $dirsql.$subdir;

-

-					$handle = @opendir($dir); // Dir may not exists

-					if (is_resource($handle)) {

-						$dirfound++;

-

-						// Run llx_mytable.sql files, then llx_mytable_*.sql

-						$files = array();

-						while (($file = readdir($handle)) !== false) {

-							$files[] = $file;

-						}

-						sort($files);

-						foreach ($files as $file) {

-							if ($onlywithsuffix) {

-								if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {

-									//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";

-									continue;

-								} else {

-									//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";

-								}

-							}

-							if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_') {

-								$result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1);

-								if ($result <= 0) {

-									$error++;

-								}

-							}

-						}

-

-						rewinddir($handle);

-

-						// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql

-						$files = array();

-						while (($file = readdir($handle)) !== false) {

-							$files[] = $file;

-						}

-						sort($files);

-						foreach ($files as $file) {

-							if ($onlywithsuffix) {

-								if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {

-									//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";

-									continue;

-								} else {

-									//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";

-								}

-							}

-							if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_') {

-								$result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1);

-								if ($result <= 0) {

-									$error++;

-								}

-							}

-						}

-

-						rewinddir($handle);

-

-						// Run functions-xxx.sql files (Must be done after llx_mytable.key.sql)

-						$files = array();

-						while (($file = readdir($handle)) !== false) {

-							$files[] = $file;

-						}

-						sort($files);

-						foreach ($files as $file) {

-							if ($onlywithsuffix) {

-								if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {

-									//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";

-									continue;

-								} else {

-									//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";

-								}

-							}

-							if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 9) == 'functions') {

-								$result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1);

-								if ($result <= 0) {

-									$error++;

-								}

-							}

-						}

-

-						rewinddir($handle);

-

-						// Run data_xxx.sql files (Must be done after llx_mytable.key.sql)

-						$files = array();

-						while (($file = readdir($handle)) !== false) {

-							$files[] = $file;

-						}

-						sort($files);

-						foreach ($files as $file) {

-							if ($onlywithsuffix) {

-								if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {

-									//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";

-									continue;

-								} else {

-									//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";

-								}

-							}

-							if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') {

-								$result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1);

-								if ($result <= 0) {

-									$error++;

-								}

-							}

-						}

-

-						rewinddir($handle);

-

-						// Run update_xxx.sql files

-						$files = array();

-						while (($file = readdir($handle)) !== false) {

-							$files[] = $file;

-						}

-						sort($files);

-						foreach ($files as $file) {

-							if ($onlywithsuffix) {

-								if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) {

-									//print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded<br>'."\n";

-									continue;

-								} else {

-									//print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it<br>'."\n";

-								}

-							}

-							if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') {

-								$result = run_sql($dir.$file, !getDolGlobalString('MAIN_DISPLAY_SQL_INSTALL_LOG') ? 1 : 0, '', 1);

-								if ($result <= 0) {

-									$error++;

-								}

-							}

-						}

-

-						closedir($handle);

-					}

-				}

-

-				if ($error == 0) {

-					$ok = 1;

-				}

-			}

-		}

-

-		if (!$dirfound) {

-			dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING);

-		}

-		return $ok;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds boxes

-	 *

-	 * @param string $option Options when disabling module ('newboxdefonly'=insert only boxes definition)

-	 *

-	 * @return int             Error count (0 if OK)

-	 */

-	public function insert_boxes($option = '')

-	{

-		// phpcs:enable

-		include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';

-

-		global $conf;

-

-		$err = 0;

-

-		if (is_array($this->boxes)) {

-			dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG);

-

-			$pos_name = InfoBox::getListOfPagesForBoxes();

-

-			foreach ($this->boxes as $key => $value) {

-				$file  = isset($this->boxes[$key]['file']) ? $this->boxes[$key]['file'] : '';

-				$note  = isset($this->boxes[$key]['note']) ? $this->boxes[$key]['note'] : '';

-				$enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton']) ? $this->boxes[$key]['enabledbydefaulton'] : 'Home';

-

-				if (empty($file)) {

-					$file  = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility

-				}

-				if (empty($note)) {

-					$note  = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : ''; // For backward compatibility

-				}

-

-				// Search if boxes def already present

-				$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."boxes_def";

-				$sql .= " WHERE file = '".$this->db->escape($file)."'";

-				$sql .= " AND entity = ".$conf->entity;

-				if ($note) {

-					$sql .= " AND note ='".$this->db->escape($note)."'";

-				}

-

-				$result = $this->db->query($sql);

-				if ($result) {

-					$obj = $this->db->fetch_object($result);

-					if ($obj->nb == 0) {

-						$this->db->begin();

-

-						if (!$err) {

-							$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, entity, note)";

-							$sql .= " VALUES ('".$this->db->escape($file)."', ";

-							$sql .= $conf->entity.", ";

-							$sql .= $note ? "'".$this->db->escape($note)."'" : "null";

-							$sql .= ")";

-

-							dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG);

-							$resql = $this->db->query($sql);

-							if (!$resql) {

-								$err++;

-							}

-						}

-						if (!$err && !preg_match('/newboxdefonly/', $option)) {

-							$lastid = $this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def", "rowid");

-

-							foreach ($pos_name as $key2 => $val2) {

-								//print 'key2='.$key2.'-val2='.$val2."<br>\n";

-								if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {

-									continue; // Not enabled by default onto this page.

-								}

-

-								$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position, box_order, fk_user, entity)";

-								$sql .= " VALUES (".((int) $lastid).", ".((int) $key2).", '0', 0, ".((int) $conf->entity).")";

-

-								dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2, LOG_DEBUG);

-								$resql = $this->db->query($sql);

-								if (!$resql) {

-									$err++;

-								}

-							}

-						}

-

-						if (!$err) {

-							$this->db->commit();

-						} else {

-							$this->error = $this->db->lasterror();

-							$this->db->rollback();

-						}

-					}

-					// else box already registered into database

-				} else {

-					$this->error = $this->db->lasterror();

-					$err++;

-				}

-			}

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes boxes

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function delete_boxes()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		if (is_array($this->boxes)) {

-			foreach ($this->boxes as $key => $value) {

-				//$titre = $this->boxes[$key][0];

-				if (empty($this->boxes[$key]['file'])) {

-					$file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility

-				} else {

-					$file = $this->boxes[$key]['file'];

-				}

-

-				//$note  = $this->boxes[$key][2];

-

-				// TODO If the box is also included by another module and the other module is still on, we should not remove it.

-				// For the moment, we manage this with hard coded exception

-				//print "Remove box ".$file.'<br>';

-				if ($file == 'box_graph_product_distribution.php') {

-					if (isModEnabled("product") || isModEnabled("service")) {

-						dol_syslog("We discard deleting module ".$file." because another module still active requires it.");

-						continue;

-					}

-				}

-

-				if ($this->db->type == 'sqlite3') {

-					// sqlite doesn't support "USING" syntax.

-					// TODO: remove this dependency.

-					$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes ";

-					$sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN (";

-					$sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid ";

-					$sql .= "FROM ".MAIN_DB_PREFIX."boxes_def ";

-					$sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') ";

-					$sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;

-				} else {

-					$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";

-					$sql .= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";

-					$sql .= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";

-					$sql .= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'";

-					$sql .= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;

-				}

-

-				dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);

-				$resql = $this->db->query($sql);

-				if (!$resql) {

-					$this->error = $this->db->lasterror();

-					$err++;

-				}

-

-				$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";

-				$sql .= " WHERE file = '".$this->db->escape($file)."'";

-				$sql .= " AND entity = ".$conf->entity;		// Do not use getEntity here, we want to delete only in current company

-

-				dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);

-				$resql = $this->db->query($sql);

-				if (!$resql) {

-					$this->error = $this->db->lasterror();

-					$err++;

-				}

-			}

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds cronjobs

-	 *

-	 * @return int             Error count (0 if OK)

-	 */

-	public function insert_cronjobs()

-	{

-		// phpcs:enable

-		include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';

-

-		global $conf;

-

-		$err = 0;

-

-		if (is_array($this->cronjobs)) {

-			dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG);

-

-			foreach ($this->cronjobs as $key => $value) {

-				$entity = isset($this->cronjobs[$key]['entity']) ? $this->cronjobs[$key]['entity'] : $conf->entity;

-				$label  = isset($this->cronjobs[$key]['label']) ? $this->cronjobs[$key]['label'] : '';

-				$jobtype = isset($this->cronjobs[$key]['jobtype']) ? $this->cronjobs[$key]['jobtype'] : '';

-				$class  = isset($this->cronjobs[$key]['class']) ? $this->cronjobs[$key]['class'] : '';

-				$objectname  = isset($this->cronjobs[$key]['objectname']) ? $this->cronjobs[$key]['objectname'] : '';

-				$method = isset($this->cronjobs[$key]['method']) ? $this->cronjobs[$key]['method'] : '';

-				$command = isset($this->cronjobs[$key]['command']) ? $this->cronjobs[$key]['command'] : '';

-				$parameters  = isset($this->cronjobs[$key]['parameters']) ? $this->cronjobs[$key]['parameters'] : '';

-				$comment = isset($this->cronjobs[$key]['comment']) ? $this->cronjobs[$key]['comment'] : '';

-				$frequency = isset($this->cronjobs[$key]['frequency']) ? $this->cronjobs[$key]['frequency'] : '';

-				$unitfrequency = isset($this->cronjobs[$key]['unitfrequency']) ? $this->cronjobs[$key]['unitfrequency'] : '';

-				$priority = isset($this->cronjobs[$key]['priority']) ? $this->cronjobs[$key]['priority'] : '';

-				$datestart = isset($this->cronjobs[$key]['datestart']) ? $this->cronjobs[$key]['datestart'] : '';

-				$dateend = isset($this->cronjobs[$key]['dateend']) ? $this->cronjobs[$key]['dateend'] : '';

-				$status = isset($this->cronjobs[$key]['status']) ? $this->cronjobs[$key]['status'] : '';

-				$test = isset($this->cronjobs[$key]['test']) ? $this->cronjobs[$key]['test'] : ''; // Line must be enabled or not (so visible or not)

-

-				// Search if cron entry already present

-				$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob";

-				//$sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'";

-				$sql .= " WHERE label = '".$this->db->escape($label)."'";

-				/*if ($class) {

-					$sql .= " AND classesname = '".$this->db->escape($class)."'";

-				}

-				if ($objectname) {

-					$sql .= " AND objectname = '".$this->db->escape($objectname)."'";

-				}

-				if ($method) {

-					$sql .= " AND methodename = '".$this->db->escape($method)."'";

-				}

-				if ($command) {

-					$sql .= " AND command = '".$this->db->escape($command)."'";

-				}

-				if ($parameters) {

-					$sql .= " AND params = '".$this->db->escape($parameters)."'";

-				}*/

-				$sql .= " AND entity = ".((int) $entity); // Must be exact entity

-

-				$now = dol_now();

-

-				$result = $this->db->query($sql);

-				if ($result) {

-					$obj = $this->db->fetch_object($result);

-					if ($obj->nb == 0) {

-						$this->db->begin();

-

-						if (!$err) {

-							$sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";

-							if (is_int($frequency)) {

-								$sql .= ' frequency,';

-							}

-							if (is_int($unitfrequency)) {

-								$sql .= ' unitfrequency,';

-							}

-							if (is_int($priority)) {

-								$sql .= ' priority,';

-							}

-							if (is_int($status)) {

-								$sql .= ' status,';

-							}

-							$sql .= " entity, test)";

-							$sql .= " VALUES (";

-							$sql .= "'".$this->db->escape(empty($this->rights_class) ? strtolower($this->name) : $this->rights_class)."', ";

-							$sql .= "'".$this->db->idate($now)."', ";

-							$sql .= ($datestart ? "'".$this->db->idate($datestart)."'" : "'".$this->db->idate($now)."'").", ";

-							$sql .= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", ";

-							$sql .= "'".$this->db->escape($label)."', ";

-							$sql .= "'".$this->db->escape($jobtype)."', ";

-							$sql .= ($class ? "'".$this->db->escape($class)."'" : "null").",";

-							$sql .= ($objectname ? "'".$this->db->escape($objectname)."'" : "null").",";

-							$sql .= ($method ? "'".$this->db->escape($method)."'" : "null").",";

-							$sql .= ($command ? "'".$this->db->escape($command)."'" : "null").",";

-							$sql .= ($parameters ? "'".$this->db->escape($parameters)."'" : "null").",";

-							$sql .= ($comment ? "'".$this->db->escape($comment)."'" : "null").",";

-							if (is_int($frequency)) {

-								$sql .= "'".$this->db->escape($frequency)."', ";

-							}

-							if (is_int($unitfrequency)) {

-								$sql .= "'".$this->db->escape($unitfrequency)."', ";

-							}

-							if (is_int($priority)) {

-								$sql .= "'".$this->db->escape($priority)."', ";

-							}

-							if (is_int($status)) {

-								$sql .= ((int) $status).", ";

-							}

-							$sql .= $entity.",";

-							$sql .= "'".$this->db->escape($test)."'";

-							$sql .= ")";

-

-							$resql = $this->db->query($sql);

-							if (!$resql) {

-								$err++;

-							}

-						}

-

-						if (!$err) {

-							$this->db->commit();

-						} else {

-							$this->error = $this->db->lasterror();

-							$this->db->rollback();

-						}

-					}

-					// else box already registered into database

-				} else {

-					$this->error = $this->db->lasterror();

-					$err++;

-				}

-			}

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes boxes

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function delete_cronjobs()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		if (is_array($this->cronjobs)) {

-			$sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob";

-			$sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->name) : $this->rights_class)."'";

-			$sql .= " AND entity = ".$conf->entity;

-			$sql .= " AND test = '1'"; // We delete on lines that are not set with a complete test that is '$conf->module->enabled' so when module is disabled, the cron is also removed.

-			// For crons declared with a '$conf->module->enabled', there is no need to delete the line, so we don't loose setup if we reenable module.

-

-			dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG);

-			$resql = $this->db->query($sql);

-			if (!$resql) {

-				$this->error = $this->db->lasterror();

-				$err++;

-			}

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes tabs

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function delete_tabs()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

-		$sql .= " WHERE ".$this->db->decrypt('name')." like '".$this->db->escape($this->const_name)."_TABS_%'";

-		$sql .= " AND entity = ".$conf->entity;

-

-		dol_syslog(get_class($this)."::delete_tabs", LOG_DEBUG);

-		if (!$this->db->query($sql)) {

-			$this->error = $this->db->lasterror();

-			$err++;

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds tabs

-	 *

-	 * @return int  Error count (0 if ok)

-	 */

-	public function insert_tabs()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		if (!empty($this->tabs)) {

-			dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);

-

-			$i = 0;

-			foreach ($this->tabs as $key => $value) {

-				if (is_array($value) && count($value) == 0) {

-					continue; // Discard empty arrays

-				}

-

-				$entity = $conf->entity;

-				$newvalue = $value;

-

-				if (is_array($value)) {

-					$newvalue = $value['data'];

-					if (isset($value['entity'])) {

-						$entity = $value['entity'];

-					}

-				}

-

-				if ($newvalue) {

-					$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";

-					$sql .= "name";

-					$sql .= ", type";

-					$sql .= ", value";

-					$sql .= ", note";

-					$sql .= ", visible";

-					$sql .= ", entity";

-					$sql .= ")";

-					$sql .= " VALUES (";

-					$sql .= $this->db->encrypt($this->const_name."_TABS_".$i);

-					$sql .= ", 'chaine'";

-					$sql .= ", ".$this->db->encrypt($newvalue);

-					$sql .= ", null";

-					$sql .= ", '0'";

-					$sql .= ", ".((int) $entity);

-					$sql .= ")";

-

-					$resql = $this->db->query($sql);

-					if (!$resql) {

-						dol_syslog($this->db->lasterror(), LOG_ERR);

-						if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') {

-							$this->error = $this->db->lasterror();

-							$this->errors[] = $this->db->lasterror();

-							$err++;

-							break;

-						}

-					}

-				}

-				$i++;

-			}

-		}

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds constants

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function insert_const()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		if (empty($this->const)) {

-			return 0;

-		}

-

-		dol_syslog(get_class($this)."::insert_const", LOG_DEBUG);

-

-		foreach ($this->const as $key => $value) {

-			$name      = $this->const[$key][0];

-			$type      = $this->const[$key][1];

-			$val       = $this->const[$key][2];

-			$note      = isset($this->const[$key][3]) ? $this->const[$key][3] : '';

-			$visible   = isset($this->const[$key][4]) ? $this->const[$key][4] : 0;

-			$entity    = (!empty($this->const[$key][5]) && $this->const[$key][5] != 'current') ? 0 : $conf->entity;

-

-			// Clean

-			if (empty($visible)) {

-				$visible = '0';

-			}

-			if (empty($val) && $val != '0') {

-				$val = '';

-			}

-

-			$sql = "SELECT count(*) as nb";

-			$sql .= " FROM ".MAIN_DB_PREFIX."const";

-			$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'";

-			$sql .= " AND entity = ".((int) $entity);

-

-			$result = $this->db->query($sql);

-			if ($result) {

-				$row = $this->db->fetch_row($result);

-

-				if ($row[0] == 0) {   // If not found

-					$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)";

-					$sql .= " VALUES (";

-					$sql .= $this->db->encrypt($name);

-					$sql .= ",'".$this->db->escape($type)."'";

-					$sql .= ",".(($val != '') ? $this->db->encrypt($val) : "''");

-					$sql .= ",".($note ? "'".$this->db->escape($note)."'" : "null");

-					$sql .= ",'".$this->db->escape($visible)."'";

-					$sql .= ",".$entity;

-					$sql .= ")";

-

-					if (!$this->db->query($sql)) {

-						$err++;

-					}

-				} else {

-					dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_DEBUG);

-				}

-			} else {

-				$err++;

-			}

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes constants tagged 'deleteonunactive'

-	 *

-	 * @return int Return integer <0 if KO, 0 if OK

-	 */

-	public function delete_const()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		if (empty($this->const)) {

-			return 0;

-		}

-

-		foreach ($this->const as $key => $value) {

-			$name = $this->const[$key][0];

-			$deleteonunactive = (!empty($this->const[$key][6])) ? 1 : 0;

-

-			if ($deleteonunactive) {

-				$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

-				$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'";

-				$sql .= " AND entity in (0, ".$conf->entity.")";

-				dol_syslog(get_class($this)."::delete_const", LOG_DEBUG);

-				if (!$this->db->query($sql)) {

-					$this->error = $this->db->lasterror();

-					$err++;

-				}

-			}

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds access rights

-	 *

-	 * @param  int $reinitadminperms 	If 1, we also grant them to all admin users

-	 * @param  int $force_entity     	Force current entity

-	 * @param  int $notrigger        	1=Does not execute triggers, 0= execute triggers

-	 * @return int                     	Error count (0 if OK)

-	 */

-	public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0)

-	{

-		// phpcs:enable

-		global $conf, $user;

-

-		$err = 0;

-		$entity = (!empty($force_entity) ? $force_entity : $conf->entity);

-

-		dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG);

-

-		// Test if module is activated

-		$sql_del = "SELECT ".$this->db->decrypt('value')." as value";

-		$sql_del .= " FROM ".MAIN_DB_PREFIX."const";

-		$sql_del .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

-		$sql_del .= " AND entity IN (0,".$entity.")";

-

-		$resql = $this->db->query($sql_del);

-

-		if ($resql) {

-			$obj = $this->db->fetch_object($resql);

-

-			if ($obj !== null && !empty($obj->value) && !empty($this->rights)) {

-				include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';

-

-				// If the module is active

-				foreach ($this->rights as $key => $value) {

-					$r_id       = $this->rights[$key][0];	// permission id in llx_rights_def (not unique because primary key is couple id-entity)

-					$r_desc     = $this->rights[$key][1];

-					$r_type     = isset($this->rights[$key][2]) ? $this->rights[$key][2] : '';

-					$r_def      = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3];

-					$r_perms    = $this->rights[$key][4];

-					$r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : '';

-					$r_modul = empty($this->rights_class) ? strtolower($this->name) : $this->rights_class;

-

-					if (empty($r_type)) {

-						$r_type = 'w';

-					}

-

-					// Search if perm already present

-					$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";

-					$sql .= " WHERE id = ".((int) $r_id)." AND entity = ".((int) $entity);

-

-					$resqlselect = $this->db->query($sql);

-					if ($resqlselect) {

-						$objcount = $this->db->fetch_object($resqlselect);

-						if ($objcount && $objcount->nb == 0) {

-							if (dol_strlen($r_perms)) {

-								if (dol_strlen($r_subperms)) {

-									$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";

-									$sql .= " (id, entity, libelle, module, type, bydefault, perms, subperms)";

-									$sql .= " VALUES ";

-									$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$this->db->escape($r_modul)."','".$this->db->escape($r_type)."',".$r_def.",'".$this->db->escape($r_perms)."','".$this->db->escape($r_subperms)."')";

-								} else {

-									$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";

-									$sql .= " (id, entity, libelle, module, type, bydefault, perms)";

-									$sql .= " VALUES ";

-									$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$this->db->escape($r_modul)."','".$this->db->escape($r_type)."',".$r_def.",'".$this->db->escape($r_perms)."')";

-								}

-							} else {

-								$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";

-								$sql .= " (id, entity, libelle, module, type, bydefault)";

-								$sql .= " VALUES ";

-								$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$this->db->escape($r_modul)."','".$this->db->escape($r_type)."',".$r_def.")";

-							}

-

-							$resqlinsert = $this->db->query($sql, 1);

-

-							if (!$resqlinsert) {

-								if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") {

-									$this->error = $this->db->lasterror();

-									$err++;

-									break;

-								} else {

-									dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);

-								}

-							}

-

-							$this->db->free($resqlinsert);

-						}

-

-						$this->db->free($resqlselect);

-					}

-

-					// If we want to init permissions on admin users

-					if ($reinitadminperms) {

-						$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1";

-						dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG);

-

-						$resqlseladmin = $this->db->query($sql, 1);

-

-						if ($resqlseladmin) {

-							$num = $this->db->num_rows($resqlseladmin);

-							$i = 0;

-							while ($i < $num) {

-								$obj2 = $this->db->fetch_object($resqlseladmin);

-								dol_syslog(get_class($this)."::insert_permissions Add permission id ".$r_id." to user id=".$obj2->rowid);

-

-								$tmpuser = new User($this->db);

-								$result = $tmpuser->fetch($obj2->rowid);

-								if ($result > 0) {

-									$tmpuser->addrights($r_id, '', '', 0, 1);

-								} else {

-									dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);

-								}

-								$i++;

-							}

-						} else {

-							dol_print_error($this->db);

-						}

-					}

-				}

-

-				if ($reinitadminperms && !empty($user->admin)) {  // Reload permission for current user if defined

-					// We reload permissions

-					$user->clearrights();

-					$user->getrights();

-				}

-			}

-			$this->db->free($resql);

-		} else {

-			$this->error = $this->db->lasterror();

-			$err++;

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes access rights

-	 *

-	 * @return int                     Error count (0 if OK)

-	 */

-	public function delete_permissions()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def";

-		$sql .= " WHERE module = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->name) : $this->rights_class)."'";

-		$sql .= " AND entity = ".$conf->entity;

-		dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG);

-		if (!$this->db->query($sql)) {

-			$this->error = $this->db->lasterror();

-			$err++;

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds menu entries

-	 *

-	 * @return int     Error count (0 if OK)

-	 */

-	public function insert_menus()

-	{

-		// phpcs:enable

-		global $conf, $user;

-

-		if (!is_array($this->menu) || empty($this->menu)) {

-			return 0;

-		}

-

-		include_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';

-

-		dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG);

-

-		$err = 0;

-

-		// Common module

-		$entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);

-

-		$this->db->begin();

-

-		foreach ($this->menu as $key => $value) {

-			$menu = new Menubase($this->db);

-			$menu->menu_handler = 'all';

-

-			//$menu->module=strtolower($this->name);    TODO When right_class will be same than module name

-			$menu->module = (empty($this->rights_class) ? strtolower($this->name) : $this->rights_class);

-

-			if (!$this->menu[$key]['fk_menu']) {

-				$menu->fk_menu = 0;

-			} else {

-				$foundparent = 0;

-				$fk_parent = $this->menu[$key]['fk_menu'];

-				$reg = array();

-				if (preg_match('/^r=/', $fk_parent)) {    // old deprecated method

-					$fk_parent = str_replace('r=', '', $fk_parent);

-					if (isset($this->menu[$fk_parent]['rowid'])) {

-						$menu->fk_menu = $this->menu[$fk_parent]['rowid'];

-						$foundparent = 1;

-					}

-				} elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {

-					$menu->fk_menu = -1;

-					$menu->fk_mainmenu = $reg[1];

-					$menu->fk_leftmenu = $reg[2];

-					$foundparent = 1;

-				} elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {

-					$menu->fk_menu = -1;

-					$menu->fk_mainmenu = $reg[1];

-					$menu->fk_leftmenu = '';

-					$foundparent = 1;

-				}

-				if (!$foundparent) {

-					$this->error = "ErrorBadDefinitionOfMenuArrayInModuleDescriptor";

-					dol_syslog(get_class($this)."::insert_menus ".$this->error." ".$this->menu[$key]['fk_menu'], LOG_ERR);

-					$err++;

-				}

-			}

-			$menu->type = $this->menu[$key]['type'];

-			$menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : '');

-			$menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : '';

-			$menu->title = $this->menu[$key]['titre'];

-			$menu->prefix = isset($this->menu[$key]['prefix']) ? $this->menu[$key]['prefix'] : '';

-			$menu->url = $this->menu[$key]['url'];

-			$menu->langs = isset($this->menu[$key]['langs']) ? $this->menu[$key]['langs'] : '';

-			$menu->position = $this->menu[$key]['position'];

-			$menu->perms = $this->menu[$key]['perms'];

-			$menu->target = isset($this->menu[$key]['target']) ? $this->menu[$key]['target'] : '';

-			$menu->user = $this->menu[$key]['user'];

-			$menu->enabled = isset($this->menu[$key]['enabled']) ? $this->menu[$key]['enabled'] : 0;

-			$menu->position = $this->menu[$key]['position'];

-			$menu->entity = $entity;

-

-			if (!$err) {

-				$result = $menu->create($user); // Save menu entry into table llx_menu

-				if ($result > 0) {

-					$this->menu[$key]['rowid'] = $result;

-				} else {

-					$this->error = $menu->error;

-					dol_syslog(get_class($this).'::insert_menus result='.$result." ".$this->error, LOG_ERR);

-					$err++;

-					break;

-				}

-			}

-		}

-

-		if (!$err) {

-			$this->db->commit();

-		} else {

-			dol_syslog(get_class($this)."::insert_menus ".$this->error, LOG_ERR);

-			$this->db->rollback();

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes menu entries

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function delete_menus()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		//$module=strtolower($this->name);        TODO When right_class will be same than module name

-		$module = empty($this->rights_class) ? strtolower($this->name) : $this->rights_class;

-

-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";

-		$sql .= " WHERE module = '".$this->db->escape($module)."'";

-		$sql .= " AND entity IN (0, ".$conf->entity.")";

-

-		dol_syslog(get_class($this)."::delete_menus", LOG_DEBUG);

-		$resql = $this->db->query($sql);

-		if (!$resql) {

-			$this->error = $this->db->lasterror();

-			$err++;

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Creates directories

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function create_dirs()

-	{

-		// phpcs:enable

-		global $langs, $conf;

-

-		$err = 0;

-		$name = '';

-

-		if (isset($this->dirs) && is_array($this->dirs)) {

-			foreach ($this->dirs as $key => $value) {

-				$addtodatabase = 0;

-

-				if (!is_array($value)) {

-					$dir = $value; // Default simple mode

-				} else {

-					$constname = $this->const_name."_DIR_";

-					$dir       = $this->dirs[$key][1];

-					$addtodatabase = empty($this->dirs[$key][2]) ? '' : $this->dirs[$key][2]; // Create constante in llx_const

-					$subname   = empty($this->dirs[$key][3]) ? '' : strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output)

-					$forcename = empty($this->dirs[$key][4]) ? '' : strtoupper($this->dirs[$key][4]); // Change the module name if different

-

-					if (!empty($forcename)) {

-						$constname = 'MAIN_MODULE_'.$forcename."_DIR_";

-					}

-					if (!empty($subname)) {

-						$constname = $constname.$subname."_";

-					}

-

-					$name = $constname.strtoupper($this->dirs[$key][0]);

-				}

-

-				// Define directory full path ($dir must start with "/")

-				if (!getDolGlobalString('MAIN_MODULE_MULTICOMPANY') || $conf->entity == 1) {

-					$fulldir = DOL_DATA_ROOT.$dir;

-				} else {

-					$fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir;

-				}

-				// Create dir if it does not exists

-				if (!empty($fulldir) && !file_exists($fulldir)) {

-					if (dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {

-						$this->error = $langs->trans("ErrorCanNotCreateDir", $fulldir);

-						dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR);

-						$err++;

-					}

-				}

-

-				// Define the constant in database if requested (not the default mode)

-				if (!empty($addtodatabase) && !empty($name)) {

-					$result = $this->insert_dirs($name, $dir);

-					if ($result) {

-						$err++;

-					}

-				}

-			}

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds directories definitions

-	 *

-	 * @param string $name Name

-	 * @param string $dir  Directory

-	 *

-	 * @return int             Error count (0 if OK)

-	 */

-	public function insert_dirs($name, $dir)

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		$sql = "SELECT count(*)";

-		$sql .= " FROM ".MAIN_DB_PREFIX."const";

-		$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'";

-		$sql .= " AND entity = ".$conf->entity;

-

-		dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);

-		$result = $this->db->query($sql);

-		if ($result) {

-			$row = $this->db->fetch_row($result);

-

-			if ($row[0] == 0) {

-				$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, type, value, note, visible, entity)";

-				$sql .= " VALUES (".$this->db->encrypt($name).", 'chaine', ".$this->db->encrypt($dir).", '".$this->db->escape("Directory for module ".$this->name)."', '0', ".((int) $conf->entity).")";

-

-				dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);

-				$this->db->query($sql);

-			}

-		} else {

-			$this->error = $this->db->lasterror();

-			$err++;

-		}

-

-		return $err;

-	}

-

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes directories

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function delete_dirs()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

-		$sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_DIR_%'";

-		$sql .= " AND entity = ".$conf->entity;

-

-		dol_syslog(get_class($this)."::delete_dirs", LOG_DEBUG);

-		if (!$this->db->query($sql)) {

-			$this->error = $this->db->lasterror();

-			$err++;

-		}

-

-		return $err;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Adds generic parts

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function insert_module_parts()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$error = 0;

-

-		if (is_array($this->module_parts)) {

-			if (empty($this->module_parts['icon']) && !empty($this->picto) && preg_match('/^fa\-/', $this->picto)) {

-				$this->module_parts['icon'] = $this->picto;

-			}

-

-			foreach ($this->module_parts as $key => $value) {

-				if (is_array($value) && count($value) == 0) {

-					continue; // Discard empty arrays

-				}

-

-				$entity = $conf->entity; // Reset the current entity

-				$newvalue = $value;

-

-				// Serialize array parameters

-				if (is_array($value)) {

-					// Can defined other parameters

-					// Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X)

-					if (isset($value['data']) && is_array($value['data'])) {

-						$newvalue = json_encode($value['data']);

-						if (isset($value['entity'])) {

-							$entity = $value['entity'];

-						}

-					} elseif (isset($value['data']) && !is_array($value['data'])) {

-						$newvalue = $value['data'];

-						if (isset($value['entity'])) {

-							$entity = $value['entity'];

-						}

-					} else { // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...)

-						$newvalue = json_encode($value);

-					}

-				}

-

-				if (!empty($newvalue)) {

-					$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";

-					$sql .= "name";

-					$sql .= ", type";

-					$sql .= ", value";

-					$sql .= ", note";

-					$sql .= ", visible";

-					$sql .= ", entity";

-					$sql .= ")";

-					$sql .= " VALUES (";

-					$sql .= " ".$this->db->encrypt($this->const_name."_".strtoupper($key), 1);

-					$sql .= ", 'chaine'";

-					$sql .= ", ".$this->db->encrypt($newvalue, 1);

-					$sql .= ", null";

-					$sql .= ", '0'";

-					$sql .= ", ".((int) $entity);

-					$sql .= ")";

-

-					dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG);

-

-					$resql = $this->db->query($sql, 1);

-					if (!$resql) {

-						if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') {

-							$error++;

-							$this->error = $this->db->lasterror();

-						} else {

-							dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING);

-						}

-					}

-				}

-			}

-		}

-		return $error;

-	}

-

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

-	/**

-	 * Removes generic parts

-	 *

-	 * @return int Error count (0 if OK)

-	 */

-	public function delete_module_parts()

-	{

-		// phpcs:enable

-		global $conf;

-

-		$err = 0;

-

-		if (is_array($this->module_parts)) {

-			dol_syslog(get_class($this)."::delete_module_parts", LOG_DEBUG);

-

-			if (empty($this->module_parts['icon']) && !empty($this->picto) && preg_match('/^fa\-/', $this->picto)) {

-				$this->module_parts['icon'] = $this->picto;

-			}

-

-			foreach ($this->module_parts as $key => $value) {

-				// If entity is defined

-				if (is_array($value) && isset($value['entity'])) {

-					$entity = $value['entity'];

-				} else {

-					$entity = $conf->entity;

-				}

-

-				$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

-				$sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_".strtoupper($key)."'";

-				$sql .= " AND entity = ".((int) $entity);

-

-				if (!$this->db->query($sql)) {

-					$this->error = $this->db->lasterror();

-					$err++;

-				}

-			}

-		}

-		return $err;

-	}

-

-	/**

-	 * Function called when module is enabled.

-	 * The init function adds tabs, constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 * It also creates data directories

-	 *

-	 * @param  string $options Options when enabling module ('', 'newboxdefonly', 'noboxes', 'menuonly')

-	 *                         'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation

-	 * @return int                1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		return $this->_init(array(), $options);

-	}

-

-	/**

-	 * Function called when module is disabled.

-	 * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.

-	 * Data directories are not deleted

-	 *

-	 * @param  string $options Options when enabling module ('', 'noboxes')

-	 * @return int                     1 if OK, 0 if KO

-	 */

-	public function remove($options = '')

-	{

-		return $this->_remove(array(), $options);

-	}

-

-

-	/**

-	 * Return Kanban view of a module

-	 *

-	 * @param	string	$codeenabledisable		HTML code for button to enable/disable module

-	 * @param	string	$codetoconfig			HTML code to go to config page

-	 * @return 	string							HTML code of Kanban view

-	 */

-	public function getKanbanView($codeenabledisable = '', $codetoconfig = '')

-	{

-		global $conf, $langs;

-

-		// Define imginfo

-		$imginfo = "info";

-		if ($this->isCoreOrExternalModule() == 'external') {

-			$imginfo = "info_black";

-		}

-

-		$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($this)));

-

-		$version = $this->getVersion(0);

-		$versiontrans = '';

-		if (preg_match('/development/i', $version)) {

-			$versiontrans .= 'warning';

-		}

-		if (preg_match('/experimental/i', $version)) {

-			$versiontrans .= 'warning';

-		}

-		if (preg_match('/deprecated/i', $version)) {

-			$versiontrans .= 'warning';

-		}

-

-		$return = '

-    	<div class="box-flex-item info-box-module'

-			.(getDolGlobalString($const_name) ? '' : ' --disabled')

-			.($this->isCoreOrExternalModule() == 'external' ? ' --external' : '')

-			.($this->needUpdate ? ' --need-update' : '')

-			.'">

+        dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);

+        $resql = $this->db->query($sql);

+        if (!$resql)

+        {

+            $err++;

+        }

+        else

+        {

+            $obj = $this->db->fetch_object($resql);

+            $tmp = array();

+            if ($obj->note) {

+                $tmp = json_decode($obj->note, true);

+            }

+            if ($obj) {

+                return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms));

+            }

+        }

+

+        return array();

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

+    /**

+     * Insert constants for module activation

+     *

+     * @return int Error count (0 if OK)

+     */

+    protected function _active()

+    {

+        // phpcs:enable

+        global $conf, $user;

+

+        $err = 0;

+

+        // Common module

+        $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);

+

+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

+        $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

+        $sql .= " AND entity IN (0, ".$entity.")";

+

+        dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG);

+        $resql = $this->db->query($sql);

+        if (!$resql) {

+            $err++;

+        }

+

+        $note = json_encode(array('authorid'=>(is_object($user) ? $user->id : 0), 'ip'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'])));

+

+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES";

+        $sql .= " (".$this->db->encrypt($this->const_name, 1);

+        $sql .= ", ".$this->db->encrypt('1', 1);

+        $sql .= ", 0, ".$entity;

+        $sql .= ", '".$this->db->escape($note)."')";

+

+        dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG);

+        $resql = $this->db->query($sql);

+        if (!$resql) { $err++;

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

+    /**

+     * Module deactivation

+     *

+     * @return int Error count (0 if OK)

+     */

+    protected function _unactive()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        // Common module

+        $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);

+

+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

+        $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

+        $sql .= " AND entity IN (0, ".$entity.")";

+

+        dol_syslog(get_class($this)."::_unactive", LOG_DEBUG);

+        $this->db->query($sql);

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

+    /**

+     * Create tables and keys required by module.

+     * Files module.sql and module.key.sql with create table and create keys

+     * commands must be stored in directory reldir='/module/sql/'

+     * This function is called by this->init

+     *

+     * @param  string $reldir Relative directory where to scan files

+     * @return int             <=0 if KO, >0 if OK

+     */

+    protected function _load_tables($reldir)

+    {

+        // phpcs:enable

+        global $conf;

+

+        $error = 0;

+        $dirfound = 0;

+

+        if (empty($reldir)) {

+            return 1;

+        }

+

+        include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

+

+        $ok = 1;

+        foreach ($conf->file->dol_document_root as $dirroot)

+        {

+            if ($ok) {

+                $dir = $dirroot.$reldir;

+                $ok = 0;

+

+                $handle = @opendir($dir); // Dir may not exists

+                if (is_resource($handle)) {

+                    $dirfound++;

+

+                    // Run llx_mytable.sql files, then llx_mytable_*.sql

+                    $files = array();

+                    while (($file = readdir($handle)) !== false)

+                    {

+                        $files[] = $file;

+                    }

+                    sort($files);

+                    foreach ($files as $file)

+                    {

+                        if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') {

+                            $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);

+                            if ($result <= 0) { $error++;

+                            }

+                        }

+                    }

+

+                    rewinddir($handle);

+

+                    // Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql

+                    $files = array();

+                    while (($file = readdir($handle)) !== false)

+                    {

+                        $files[] = $file;

+                    }

+                    sort($files);

+                    foreach ($files as $file)

+                    {

+                        if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') {

+                            $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);

+                            if ($result <= 0) { $error++;

+                            }

+                        }

+                    }

+

+                    rewinddir($handle);

+

+                    // Run data_xxx.sql files (Must be done after llx_mytable.key.sql)

+                    $files = array();

+                    while (($file = readdir($handle)) !== false)

+                    {

+                               $files[] = $file;

+                    }

+                    sort($files);

+                    foreach ($files as $file)

+                    {

+                        if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') {

+                            $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);

+                            if ($result <= 0) { $error++;

+                            }

+                        }

+                    }

+

+                    rewinddir($handle);

+

+                    // Run update_xxx.sql files

+                    $files = array();

+                    while (($file = readdir($handle)) !== false)

+                    {

+                               $files[] = $file;

+                    }

+                    sort($files);

+                    foreach ($files as $file)

+                    {

+                        if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') {

+                            $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1);

+                            if ($result <= 0) { $error++;

+                            }

+                        }

+                    }

+

+                    closedir($handle);

+                }

+

+                if ($error == 0) {

+                    $ok = 1;

+                }

+            }

+        }

+

+        if (!$dirfound) {

+            dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING);

+        }

+        return $ok;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds boxes

+     *

+     * @param string $option Options when disabling module ('newboxdefonly'=insert only boxes definition)

+     *

+     * @return int             Error count (0 if OK)

+     */

+    public function insert_boxes($option = '')

+    {

+        // phpcs:enable

+        include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';

+

+        global $conf;

+

+        $err = 0;

+

+        if (is_array($this->boxes)) {

+            dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG);

+

+            $pos_name = InfoBox::getListOfPagesForBoxes();

+

+            foreach ($this->boxes as $key => $value)

+            {

+                $file  = isset($this->boxes[$key]['file']) ? $this->boxes[$key]['file'] : '';

+                $note  = isset($this->boxes[$key]['note']) ? $this->boxes[$key]['note'] : '';

+                $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton']) ? $this->boxes[$key]['enabledbydefaulton'] : 'Home';

+

+                if (empty($file)) { $file  = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility

+                }

+                if (empty($note)) { $note  = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : ''; // For backward compatibility

+                }

+

+                // Search if boxes def already present

+                $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."boxes_def";

+                $sql .= " WHERE file = '".$this->db->escape($file)."'";

+                $sql .= " AND entity = ".$conf->entity;

+                if ($note) { $sql .= " AND note ='".$this->db->escape($note)."'";

+                }

+

+                $result = $this->db->query($sql);

+                if ($result) {

+                    $obj = $this->db->fetch_object($result);

+                    if ($obj->nb == 0) {

+                        $this->db->begin();

+

+                        if (!$err) {

+                            $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, entity, note)";

+                            $sql .= " VALUES ('".$this->db->escape($file)."', ";

+                            $sql .= $conf->entity.", ";

+                            $sql .= $note ? "'".$this->db->escape($note)."'" : "null";

+                            $sql .= ")";

+

+                            dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG);

+                            $resql = $this->db->query($sql);

+                            if (!$resql) { $err++;

+                            }

+                        }

+                        if (!$err && !preg_match('/newboxdefonly/', $option)) {

+                            $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def", "rowid");

+

+                            foreach ($pos_name as $key2 => $val2)

+                            {

+                                    //print 'key2='.$key2.'-val2='.$val2."<br>\n";

+                                if ($enabledbydefaulton && $val2 != $enabledbydefaulton) { continue; // Not enabled by default onto this page.

+                                }

+

+                                $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)";

+                                $sql .= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")";

+

+                                dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG);

+                                $resql = $this->db->query($sql);

+                                if (!$resql) { $err++;

+                                }

+                            }

+                        }

+

+                        if (!$err) {

+                            $this->db->commit();

+                        }

+                        else

+                        {

+                                  $this->error = $this->db->lasterror();

+                                  $this->db->rollback();

+                        }

+                    }

+                    // else box already registered into database

+                }

+                else

+                {

+                    $this->error = $this->db->lasterror();

+                    $err++;

+                }

+            }

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes boxes

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function delete_boxes()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        if (is_array($this->boxes)) {

+            foreach ($this->boxes as $key => $value)

+            {

+                //$titre = $this->boxes[$key][0];

+                $file = $this->boxes[$key]['file'];

+                //$note  = $this->boxes[$key][2];

+

+                // TODO If the box is also included by another module and the other module is still on, we should not remove it.

+                // For the moment, we manage this with hard coded exception

+                //print "Remove box ".$file.'<br>';

+                if ($file == 'box_graph_product_distribution.php') {

+                    if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {

+                        dol_syslog("We discard disabling of module ".$file." because another module still active require it.");

+                        continue;

+                    }

+                }

+

+                if (empty($file)) { $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility

+                }

+

+                if ($this->db->type == 'sqlite3') {

+                    // sqlite doesn't support "USING" syntax.

+                    // TODO: remove this dependency.

+                    $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes ";

+                    $sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN (";

+                    $sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid ";

+                    $sql .= "FROM ".MAIN_DB_PREFIX."boxes_def ";

+                    $sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') ";

+                    $sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;

+                } else {

+                    $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";

+                    $sql .= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";

+                    $sql .= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";

+                    $sql .= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'";

+                    $sql .= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;

+                }

+

+                dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);

+                $resql = $this->db->query($sql);

+                if (!$resql) {

+                    $this->error = $this->db->lasterror();

+                    $err++;

+                }

+

+                $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";

+                $sql .= " WHERE file = '".$this->db->escape($file)."'";

+                $sql .= " AND entity = ".$conf->entity;

+

+                dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);

+                $resql = $this->db->query($sql);

+                if (!$resql) {

+                    $this->error = $this->db->lasterror();

+                    $err++;

+                }

+            }

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds cronjobs

+     *

+     * @return int             Error count (0 if OK)

+     */

+    public function insert_cronjobs()

+    {

+        // phpcs:enable

+        include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';

+

+        global $conf;

+

+        $err = 0;

+

+        if (is_array($this->cronjobs)) {

+            dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG);

+

+            foreach ($this->cronjobs as $key => $value)

+            {

+                $entity = isset($this->cronjobs[$key]['entity']) ? $this->cronjobs[$key]['entity'] : $conf->entity;

+                $label  = isset($this->cronjobs[$key]['label']) ? $this->cronjobs[$key]['label'] : '';

+                $jobtype = isset($this->cronjobs[$key]['jobtype']) ? $this->cronjobs[$key]['jobtype'] : '';

+                $class  = isset($this->cronjobs[$key]['class']) ? $this->cronjobs[$key]['class'] : '';

+                $objectname  = isset($this->cronjobs[$key]['objectname']) ? $this->cronjobs[$key]['objectname'] : '';

+                $method = isset($this->cronjobs[$key]['method']) ? $this->cronjobs[$key]['method'] : '';

+                $command = isset($this->cronjobs[$key]['command']) ? $this->cronjobs[$key]['command'] : '';

+                $parameters  = isset($this->cronjobs[$key]['parameters']) ? $this->cronjobs[$key]['parameters'] : '';

+                $comment = isset($this->cronjobs[$key]['comment']) ? $this->cronjobs[$key]['comment'] : '';

+                $frequency = isset($this->cronjobs[$key]['frequency']) ? $this->cronjobs[$key]['frequency'] : '';

+                $unitfrequency = isset($this->cronjobs[$key]['unitfrequency']) ? $this->cronjobs[$key]['unitfrequency'] : '';

+                $priority = isset($this->cronjobs[$key]['priority']) ? $this->cronjobs[$key]['priority'] : '';

+                $datestart = isset($this->cronjobs[$key]['datestart']) ? $this->cronjobs[$key]['datestart'] : '';

+                $dateend = isset($this->cronjobs[$key]['dateend']) ? $this->cronjobs[$key]['dateend'] : '';

+                $status = isset($this->cronjobs[$key]['status']) ? $this->cronjobs[$key]['status'] : '';

+                $test = isset($this->cronjobs[$key]['test']) ? $this->cronjobs[$key]['test'] : ''; // Line must be enabled or not (so visible or not)

+

+                // Search if cron entry already present

+                $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob";

+                $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'";

+                if ($class) {

+                    $sql .= " AND classesname = '".$this->db->escape($class)."'";

+                }

+                if ($objectname) {

+                    $sql .= " AND objectname = '".$this->db->escape($objectname)."'";

+                }

+                if ($method) {

+                    $sql .= " AND methodename = '".$this->db->escape($method)."'";

+                }

+                if ($command) {

+                    $sql .= " AND command = '".$this->db->escape($command)."'";

+                }

+                $sql .= " AND entity = ".$entity; // Must be exact entity

+

+                $now = dol_now();

+

+                $result = $this->db->query($sql);

+                if ($result) {

+                    $obj = $this->db->fetch_object($result);

+                    if ($obj->nb == 0) {

+                        $this->db->begin();

+

+                        if (!$err) {

+                            $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";

+                            if (is_int($frequency)) { $sql .= ' frequency,'; }

+                            if (is_int($unitfrequency)) { $sql .= ' unitfrequency,'; }

+                            if (is_int($priority)) { $sql .= ' priority,'; }

+                            if (is_int($status)) { $sql .= ' status,'; }

+                            $sql .= " entity, test)";

+                            $sql .= " VALUES (";

+                            $sql .= "'".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."', ";

+                            $sql .= "'".$this->db->idate($now)."', ";

+                            $sql .= ($datestart ? "'".$this->db->idate($datestart)."'" : "'".$this->db->idate($now)."'").", ";

+                            $sql .= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", ";

+                            $sql .= "'".$this->db->escape($label)."', ";

+                            $sql .= "'".$this->db->escape($jobtype)."', ";

+                            $sql .= ($class ? "'".$this->db->escape($class)."'" : "null").",";

+                            $sql .= ($objectname ? "'".$this->db->escape($objectname)."'" : "null").",";

+                            $sql .= ($method ? "'".$this->db->escape($method)."'" : "null").",";

+                            $sql .= ($command ? "'".$this->db->escape($command)."'" : "null").",";

+                            $sql .= ($parameters ? "'".$this->db->escape($parameters)."'" : "null").",";

+                            $sql .= ($comment ? "'".$this->db->escape($comment)."'" : "null").",";

+                            if (is_int($frequency)) { $sql .= "'".$this->db->escape($frequency)."', ";

+                            }

+                            if (is_int($unitfrequency)) { $sql .= "'".$this->db->escape($unitfrequency)."', ";

+                            }

+                            if (is_int($priority)) {$sql .= "'".$this->db->escape($priority)."', ";

+                            }

+                            if (is_int($status)) { $sql .= "'".$this->db->escape($status)."', ";

+                            }

+                            $sql .= $entity.",";

+                            $sql .= "'".$this->db->escape($test)."'";

+                            $sql .= ")";

+

+                            $resql = $this->db->query($sql);

+                            if (!$resql) { $err++;

+                            }

+                        }

+

+                        if (!$err) {

+                            $this->db->commit();

+                        }

+                        else

+                        {

+                            $this->error = $this->db->lasterror();

+                            $this->db->rollback();

+                        }

+                    }

+                    // else box already registered into database

+                }

+                else

+                {

+                    $this->error = $this->db->lasterror();

+                    $err++;

+                }

+            }

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes boxes

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function delete_cronjobs()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        if (is_array($this->cronjobs)) {

+            $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob";

+            $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'";

+            $sql .= " AND entity = ".$conf->entity;

+            $sql .= " AND test = '1'"; // We delete on lines that are not set with a complete test that is '$conf->module->enabled' so when module is disabled, the cron is also removed.

+              // For crons declared with a '$conf->module->enabled', there is no need to delete the line, so we don't loose setup if we reenable module.

+

+            dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG);

+            $resql = $this->db->query($sql);

+            if (!$resql) {

+                $this->error = $this->db->lasterror();

+                $err++;

+            }

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes tabs

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function delete_tabs()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

+        $sql .= " WHERE ".$this->db->decrypt('name')." like '".$this->db->escape($this->const_name)."_TABS_%'";

+        $sql .= " AND entity = ".$conf->entity;

+

+        dol_syslog(get_class($this)."::delete_tabs", LOG_DEBUG);

+        if (!$this->db->query($sql)) {

+            $this->error = $this->db->lasterror();

+            $err++;

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds tabs

+     *

+     * @return int  Error count (0 if ok)

+     */

+    public function insert_tabs()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        if (!empty($this->tabs)) {

+            dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);

+

+            $i = 0;

+            foreach ($this->tabs as $key => $value)

+            {

+                if (is_array($value) && count($value) == 0) { continue; // Discard empty arrays

+                }

+

+                $entity = $conf->entity;

+                $newvalue = $value;

+

+                if (is_array($value)) {

+                    $newvalue = $value['data'];

+                    if (isset($value['entity'])) { $entity = $value['entity'];

+                    }

+                }

+

+                if ($newvalue) {

+                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";

+                    $sql .= "name";

+                    $sql .= ", type";

+                    $sql .= ", value";

+                    $sql .= ", note";

+                    $sql .= ", visible";

+                    $sql .= ", entity";

+                    $sql .= ")";

+                    $sql .= " VALUES (";

+                    $sql .= $this->db->encrypt($this->const_name."_TABS_".$i, 1);

+                    $sql .= ", 'chaine'";

+                    $sql .= ", ".$this->db->encrypt($newvalue, 1);

+                    $sql .= ", null";

+                    $sql .= ", '0'";

+                    $sql .= ", ".$entity;

+                    $sql .= ")";

+

+                    $resql = $this->db->query($sql);

+                    if (!$resql) {

+                         dol_syslog($this->db->lasterror(), LOG_ERR);

+                        if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') {

+                            $this->error = $this->db->lasterror();

+                            $this->errors[] = $this->db->lasterror();

+                            $err++;

+                            break;

+                        }

+                    }

+                }

+                $i++;

+            }

+        }

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds constants

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function insert_const()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        if (empty($this->const)) { return 0;

+        }

+

+        dol_syslog(get_class($this)."::insert_const", LOG_DEBUG);

+

+        foreach ($this->const as $key => $value)

+        {

+            $name      = $this->const[$key][0];

+            $type      = $this->const[$key][1];

+            $val       = $this->const[$key][2];

+            $note      = isset($this->const[$key][3]) ? $this->const[$key][3] : '';

+            $visible   = isset($this->const[$key][4]) ? $this->const[$key][4] : 0;

+            $entity    = (!empty($this->const[$key][5]) && $this->const[$key][5] != 'current') ? 0 : $conf->entity;

+

+            // Clean

+            if (empty($visible)) { $visible = '0';

+            }

+            if (empty($val) && $val != '0') { $val = '';

+            }

+

+            $sql = "SELECT count(*)";

+            $sql .= " FROM ".MAIN_DB_PREFIX."const";

+            $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'";

+            $sql .= " AND entity = ".$entity;

+

+            $result = $this->db->query($sql);

+            if ($result) {

+                $row = $this->db->fetch_row($result);

+

+                if ($row[0] == 0)   // If not found

+                {

+                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)";

+                    $sql .= " VALUES (";

+                    $sql .= $this->db->encrypt($name, 1);

+                    $sql .= ",'".$type."'";

+                    $sql .= ",".(($val != '') ? $this->db->encrypt($val, 1) : "''");

+                    $sql .= ",".($note ? "'".$this->db->escape($note)."'" : "null");

+                    $sql .= ",'".$visible."'";

+                    $sql .= ",".$entity;

+                    $sql .= ")";

+

+                    if (!$this->db->query($sql)) {

+                        $err++;

+                    }

+                }

+                else

+                {

+                    dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_WARNING);

+                }

+            }

+            else

+            {

+                $err++;

+            }

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes constants tagged 'deleteonunactive'

+     *

+     * @return int <0 if KO, 0 if OK

+     */

+    public function delete_const()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        if (empty($this->const)) { return 0;

+        }

+

+        foreach ($this->const as $key => $value)

+        {

+            $name = $this->const[$key][0];

+            $deleteonunactive = (!empty($this->const[$key][6])) ? 1 : 0;

+

+            if ($deleteonunactive) {

+                $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

+                $sql .= " WHERE ".$this->db->decrypt('name')." = '".$name."'";

+                $sql .= " AND entity in (0, ".$conf->entity.")";

+                dol_syslog(get_class($this)."::delete_const", LOG_DEBUG);

+                if (!$this->db->query($sql)) {

+                    $this->error = $this->db->lasterror();

+                    $err++;

+                }

+            }

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds access rights

+     *

+     * @param  int $reinitadminperms If 1, we also grant them to all admin users

+     * @param  int $force_entity     Force current entity

+     * @param  int $notrigger        1=Does not execute triggers, 0= execute triggers

+     * @return int                     Error count (0 if OK)

+     */

+    public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0)

+    {

+        // phpcs:enable

+        global $conf, $user;

+

+        $err = 0;

+        $entity = (!empty($force_entity) ? $force_entity : $conf->entity);

+

+        dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG);

+

+        // Test if module is activated

+        $sql_del = "SELECT ".$this->db->decrypt('value')." as value";

+        $sql_del .= " FROM ".MAIN_DB_PREFIX."const";

+        $sql_del .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";

+        $sql_del .= " AND entity IN (0,".$entity.")";

+

+        $resql = $this->db->query($sql_del);

+

+        if ($resql) {

+            $obj = $this->db->fetch_object($resql);

+            if ($obj !== null && !empty($obj->value) && !empty($this->rights)) {

+                // If the module is active

+                foreach ($this->rights as $key => $value)

+                {

+                    $r_id       = $this->rights[$key][0];

+                    $r_desc     = $this->rights[$key][1];

+                    $r_type     = isset($this->rights[$key][2]) ? $this->rights[$key][2] : '';

+                    $r_def      = $this->rights[$key][3];

+                    $r_perms    = $this->rights[$key][4];

+                    $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : '';

+                    $r_modul = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class;

+

+                    if (empty($r_type)) { $r_type = 'w'; }

+                    if (empty($r_def)) { $r_def = 0; }

+

+                    // Search if perm already present

+                    $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";

+                    $sql .= " WHERE id = ".$r_id." AND entity = ".$entity;

+

+                    $resqlselect = $this->db->query($sql);

+                    if ($resqlselect) {

+                        $objcount = $this->db->fetch_object($resqlselect);

+                        if ($objcount && $objcount->nb == 0) {

+                            if (dol_strlen($r_perms)) {

+                                if (dol_strlen($r_subperms)) {

+                                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";

+                                    $sql .= " (id, entity, libelle, module, type, bydefault, perms, subperms)";

+                                    $sql .= " VALUES ";

+                                    $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";

+                                }

+                                else

+                                   {

+                                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";

+                                    $sql .= " (id, entity, libelle, module, type, bydefault, perms)";

+                                    $sql .= " VALUES ";

+                                    $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";

+                                }

+                            }

+                            else

+                            {

+                                 $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";

+                                 $sql .= " (id, entity, libelle, module, type, bydefault)";

+                                 $sql .= " VALUES ";

+                                 $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";

+                            }

+

+                            $resqlinsert = $this->db->query($sql, 1);

+

+                            if (!$resqlinsert) {

+                                if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") {

+                                    $this->error = $this->db->lasterror();

+                                    $err++;

+                                    break;

+                                }

+                                else { dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);

+                                }

+                            }

+

+                            $this->db->free($resqlinsert);

+                        }

+

+                        $this->db->free($resqlselect);

+                    }

+

+                    // If we want to init permissions on admin users

+                    if ($reinitadminperms) {

+                        if (!class_exists('User')) {

+                            include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';

+                        }

+                        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1";

+                        dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG);

+                        $resqlseladmin = $this->db->query($sql, 1);

+                        if ($resqlseladmin) {

+                            $num = $this->db->num_rows($resqlseladmin);

+                            $i = 0;

+                            while ($i < $num)

+                            {

+                                  $obj2 = $this->db->fetch_object($resqlseladmin);

+                                  dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid);

+

+                                  $tmpuser = new User($this->db);

+                                  $result = $tmpuser->fetch($obj2->rowid);

+                                if ($result > 0) {

+                                    $tmpuser->addrights($r_id, '', '', 0, 1);

+                                }

+                                else

+                                 {

+                                    dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);

+                                }

+                                 $i++;

+                            }

+                        }

+                        else

+                        {

+                            dol_print_error($this->db);

+                        }

+                    }

+                }

+

+                if ($reinitadminperms && !empty($user->admin))  // Reload permission for current user if defined

+                {

+                    // We reload permissions

+                    $user->clearrights();

+                    $user->getrights();

+                }

+            }

+            $this->db->free($resql);

+        }

+        else

+        {

+            $this->error = $this->db->lasterror();

+            $err++;

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes access rights

+     *

+     * @return int                     Error count (0 if OK)

+     */

+    public function delete_permissions()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def";

+        $sql .= " WHERE module = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'";

+        $sql .= " AND entity = ".$conf->entity;

+        dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG);

+        if (!$this->db->query($sql)) {

+            $this->error = $this->db->lasterror();

+            $err++;

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds menu entries

+     *

+     * @return int     Error count (0 if OK)

+     */

+    public function insert_menus()

+    {

+        // phpcs:enable

+        global $user;

+

+        if (!is_array($this->menu) || empty($this->menu)) { return 0;

+        }

+

+        include_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';

+

+        dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG);

+

+        $err = 0;

+

+        $this->db->begin();

+

+        foreach ($this->menu as $key => $value)

+        {

+            $menu = new Menubase($this->db);

+            $menu->menu_handler = 'all';

+

+            //$menu->module=strtolower($this->name);    TODO When right_class will be same than module name

+            $menu->module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class;

+

+            if (!$this->menu[$key]['fk_menu']) {

+                $menu->fk_menu = 0;

+            }

+            else

+            {

+                $foundparent = 0;

+                $fk_parent = $this->menu[$key]['fk_menu'];

+                if (preg_match('/^r=/', $fk_parent))    // old deprecated method

+                {

+                    $fk_parent = str_replace('r=', '', $fk_parent);

+                    if (isset($this->menu[$fk_parent]['rowid'])) {

+                        $menu->fk_menu = $this->menu[$fk_parent]['rowid'];

+                        $foundparent = 1;

+                    }

+                }

+                elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {

+                    $menu->fk_menu = -1;

+                    $menu->fk_mainmenu = $reg[1];

+                    $menu->fk_leftmenu = $reg[2];

+                    $foundparent = 1;

+                }

+                elseif (preg_match('/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {

+                    $menu->fk_menu = -1;

+                    $menu->fk_mainmenu = $reg[1];

+                    $menu->fk_leftmenu = '';

+                    $foundparent = 1;

+                }

+                if (!$foundparent) {

+                    $this->error = "ErrorBadDefinitionOfMenuArrayInModuleDescriptor";

+                    dol_syslog(get_class($this)."::insert_menus ".$this->error." ".$this->menu[$key]['fk_menu'], LOG_ERR);

+                    $err++;

+                }

+            }

+            $menu->type = $this->menu[$key]['type'];

+            $menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : '');

+            $menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : '';

+            $menu->titre = $this->menu[$key]['titre']; // deprecated

+            $menu->title = $this->menu[$key]['titre'];

+            $menu->url = $this->menu[$key]['url'];

+            $menu->langs = $this->menu[$key]['langs'];

+            $menu->position = $this->menu[$key]['position'];

+            $menu->perms = $this->menu[$key]['perms'];

+            $menu->target = isset($this->menu[$key]['target']) ? $this->menu[$key]['target'] : '';

+            $menu->user = $this->menu[$key]['user'];

+            $menu->enabled = isset($this->menu[$key]['enabled']) ? $this->menu[$key]['enabled'] : 0;

+            $menu->position = $this->menu[$key]['position'];

+

+            if (!$err) {

+                $result = $menu->create($user); // Save menu entry into table llx_menu

+                if ($result > 0) {

+                    $this->menu[$key]['rowid'] = $result;

+                }

+                else

+                {

+                    $this->error = $menu->error;

+                    dol_syslog(get_class($this).'::insert_menus result='.$result." ".$this->error, LOG_ERR);

+                    $err++;

+                    break;

+                }

+            }

+        }

+

+        if (!$err) {

+            $this->db->commit();

+        }

+        else

+        {

+            dol_syslog(get_class($this)."::insert_menus ".$this->error, LOG_ERR);

+            $this->db->rollback();

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes menu entries

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function delete_menus()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        //$module=strtolower($this->name);        TODO When right_class will be same than module name

+        $module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class;

+

+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";

+        $sql .= " WHERE module = '".$this->db->escape($module)."'";

+        $sql .= " AND entity = ".$conf->entity;

+

+        dol_syslog(get_class($this)."::delete_menus", LOG_DEBUG);

+        $resql = $this->db->query($sql);

+        if (!$resql) {

+            $this->error = $this->db->lasterror();

+            $err++;

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Creates directories

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function create_dirs()

+    {

+        // phpcs:enable

+        global $langs, $conf;

+

+        $err = 0;

+

+        if (isset($this->dirs) && is_array($this->dirs)) {

+            foreach ($this->dirs as $key => $value)

+            {

+                $addtodatabase = 0;

+

+                if (!is_array($value)) { $dir = $value; // Default simple mode

+                } else {

+                    $constname = $this->const_name."_DIR_";

+                    $dir       = $this->dirs[$key][1];

+                    $addtodatabase = empty($this->dirs[$key][2]) ? '' : $this->dirs[$key][2]; // Create constante in llx_const

+                    $subname   = empty($this->dirs[$key][3]) ? '' : strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output)

+                    $forcename = empty($this->dirs[$key][4]) ? '' : strtoupper($this->dirs[$key][4]); // Change the module name if different

+

+                    if (!empty($forcename)) { $constname = 'MAIN_MODULE_'.$forcename."_DIR_";

+                    }

+                    if (!empty($subname)) {   $constname = $constname.$subname."_";

+                    }

+

+                    $name = $constname.strtoupper($this->dirs[$key][0]);

+                }

+

+                // Define directory full path ($dir must start with "/")

+                if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) { $fulldir = DOL_DATA_ROOT.$dir;

+                } else { $fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir;

+                }

+                // Create dir if it does not exists

+                if (!empty($fulldir) && !file_exists($fulldir)) {

+                    if (dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {

+                         $this->error = $langs->trans("ErrorCanNotCreateDir", $fulldir);

+                         dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR);

+                         $err++;

+                    }

+                }

+

+                // Define the constant in database if requested (not the default mode)

+                if (!empty($addtodatabase)) {

+                    $result = $this->insert_dirs($name, $dir);

+                    if ($result) { $err++;

+                    }

+                }

+            }

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds directories definitions

+     *

+     * @param string $name Name

+     * @param string $dir  Directory

+     *

+     * @return int             Error count (0 if OK)

+     */

+    public function insert_dirs($name, $dir)

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        $sql = "SELECT count(*)";

+        $sql .= " FROM ".MAIN_DB_PREFIX."const";

+        $sql .= " WHERE ".$this->db->decrypt('name')." = '".$name."'";

+        $sql .= " AND entity = ".$conf->entity;

+

+        dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);

+        $result = $this->db->query($sql);

+        if ($result) {

+            $row = $this->db->fetch_row($result);

+

+            if ($row[0] == 0) {

+                $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)";

+                $sql .= " VALUES (".$this->db->encrypt($name, 1).",'chaine',".$this->db->encrypt($dir, 1).",'Directory for module ".$this->name."','0',".$conf->entity.")";

+

+                dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);

+                $this->db->query($sql);

+            }

+        }

+        else

+        {

+            $this->error = $this->db->lasterror();

+            $err++;

+        }

+

+        return $err;

+    }

+

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes directories

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function delete_dirs()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+

+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

+        $sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_DIR_%'";

+        $sql .= " AND entity = ".$conf->entity;

+

+        dol_syslog(get_class($this)."::delete_dirs", LOG_DEBUG);

+        if (!$this->db->query($sql)) {

+            $this->error = $this->db->lasterror();

+            $err++;

+        }

+

+        return $err;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Adds generic parts

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function insert_module_parts()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $error = 0;

+

+        if (is_array($this->module_parts) && !empty($this->module_parts)) {

+            foreach ($this->module_parts as $key => $value)

+            {

+                if (is_array($value) && count($value) == 0) { continue; // Discard empty arrays

+                }

+

+                $entity = $conf->entity; // Reset the current entity

+                $newvalue = $value;

+

+                // Serialize array parameters

+                if (is_array($value)) {

+                    // Can defined other parameters

+                    // Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X)

+                    if (isset($value['data']) && is_array($value['data'])) {

+                        $newvalue = json_encode($value['data']);

+                        if (isset($value['entity'])) { $entity = $value['entity'];

+                        }

+                    }

+                    elseif (isset($value['data']) && !is_array($value['data'])) {

+                        $newvalue = $value['data'];

+                        if (isset($value['entity'])) { $entity = $value['entity'];

+                        }

+                    }

+                    else    // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...)

+                    {

+                        $newvalue = json_encode($value);

+                    }

+                }

+

+                $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";

+                $sql .= "name";

+                $sql .= ", type";

+                $sql .= ", value";

+                $sql .= ", note";

+                $sql .= ", visible";

+                $sql .= ", entity";

+                $sql .= ")";

+                $sql .= " VALUES (";

+                $sql .= $this->db->encrypt($this->const_name."_".strtoupper($key), 1);

+                $sql .= ", 'chaine'";

+                $sql .= ", ".$this->db->encrypt($newvalue, 1);

+                $sql .= ", null";

+                $sql .= ", '0'";

+                $sql .= ", ".$entity;

+                $sql .= ")";

+

+                dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG);

+

+                $resql = $this->db->query($sql, 1);

+                if (!$resql) {

+                    if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') {

+                         $error++;

+                         $this->error = $this->db->lasterror();

+                    }

+                    else

+                    {

+                         dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING);

+                    }

+                }

+            }

+        }

+        return $error;

+    }

+

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    /**

+     * Removes generic parts

+     *

+     * @return int Error count (0 if OK)

+     */

+    public function delete_module_parts()

+    {

+        // phpcs:enable

+        global $conf;

+

+        $err = 0;

+        $entity = $conf->entity;

+

+        if (is_array($this->module_parts) && !empty($this->module_parts)) {

+            foreach ($this->module_parts as $key => $value)

+            {

+                // If entity is defined

+                if (is_array($value) && isset($value['entity'])) { $entity = $value['entity'];

+                }

+

+                $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

+                $sql .= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->db->escape($this->const_name)."_".strtoupper($key)."'";

+                $sql .= " AND entity = ".$entity;

+

+                dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG);

+                if (!$this->db->query($sql)) {

+                    $this->error = $this->db->lasterror();

+                    $err++;

+                }

+            }

+        }

+        return $err;

+    }

+

+    /**

+     * Function called when module is enabled.

+     * The init function adds tabs, constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     * It also creates data directories

+     *

+     * @param  string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')

+     *                         'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes,

+     *                         insert def of boxes only and not boxes activation

+     * @return int                1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        return $this->_init(array(), $options);

+    }

+

+    /**

+     * Function called when module is disabled.

+     * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.

+     * Data directories are not deleted

+     *

+     * @param  string $options Options when enabling module ('', 'noboxes')

+     * @return int                     1 if OK, 0 if KO

+     */

+    public function remove($options = '')

+    {

+        return $this->_remove(array(), $options);

+    }

+

+

+    /**

+     * Return Kanban view of a module

+     *

+     * @param	string	$codeenabledisable		HTML code for button to enable/disable module

+     * @param	string	$codetoconfig			HTML code to go to config page

+     * @return 	string							HTML code of Kanban view

+     */

+    public function getKanbanView($codeenabledisable = '', $codetoconfig = '')

+    {

+    	global $conf, $langs;

+

+    	// Define imginfo

+    	$imginfo = "info";

+    	if ($this->isCoreOrExternalModule() == 'external')

+    	{

+    		$imginfo = "info_black";

+    	}

+

+    	$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($this)));

+

+		print '

+    	<div class="box-flex-item info-box-module'.(empty($conf->global->$const_name) ? ' info-box-module-disabled' : '').($this->isCoreOrExternalModule() == 'external' ? ' info-box-module-external' : '').'">

@@ -2451 +2284 @@
-	    <div class="info-box-icon'.(!getDolGlobalString($const_name) ? '' : ' info-box-icon-module-enabled'.($versiontrans ? ' info-box-icon-module-warning' : '')).'">';

+	    <div class="info-box-icon">';

@@ -2456,8 +2289,4 @@
-		if (!empty($this->picto)) {

-			if (preg_match('/^\//i', $this->picto)) {

-				$return .= img_picto($alttext, $this->picto, 'class="inline-block valignmiddle"', 1);

-			} else {

-				$return .= img_object($alttext, $this->picto, 'class="inline-block valignmiddle"');

-			}

-		} else {

-			$return .= img_object($alttext, 'generic', 'class="inline-block valignmiddle"');

+		if (!empty($this->picto))

+		{

+			if (preg_match('/^\//i', $this->picto)) print img_picto($alttext, $this->picto, 'class="inline-block valignmiddle"', 1);

+			else print img_object($alttext, $this->picto, 'class="inline-block valignmiddle"');

@@ -2465 +2294,10 @@
-

+		else

+		{

+			print img_object($alttext, 'generic', 'class="inline-block valignmiddle"');

+		}

+

+		$version = $this->getVersion(0);

+		$versiontrans = '';

+		if (preg_match('/development/i', $version))  $versiontrans .= 'warning';

+		if (preg_match('/experimental/i', $version)) $versiontrans .= 'warning';

+		if (preg_match('/deprecated/i', $version))   $versiontrans .= 'warning';

@@ -2467,8 +2305,3 @@
-			$versionTitle =  $langs->trans("Version").' '.$this->getVersion(1);

-			if ($this->needUpdate) {

-				$versionTitle.= '<br>'.$langs->trans('ModuleUpdateAvailable').' : '.$this->lastVersion;

-			}

-

-			$return .=  '<span class="info-box-icon-version'.($versiontrans ? ' '.$versiontrans : '').' classfortooltip" title="'.dol_escape_js($versionTitle).'" >';

-			$return .=  $this->getVersion(1);

-			$return .=  '</span>';

+			print '<span class="info-box-icon-version'.($versiontrans? ' '.$versiontrans : '').'" title="'.$langs->trans("Version").' '.$this->getVersion(1).'">';

+			print $this->getVersion(1);

+			print '</span>';

@@ -2477,2 +2310,14 @@
-		$return .=  '</div>

-	    <div class="info-box-content info-box-text-module'.(!getDolGlobalString($const_name) ? '' : ' info-box-module-enabled'.($versiontrans ? ' info-box-content-warning' : '')).'">

+		/*print '<span class="info-box-icon-action">';

+		print '<div class="valignmiddle inline-block">';

+		print '<div class="valignmiddle inline-block">';

+		print $codeenabledisable;

+		print '</div>';

+		print '<div class="valignmiddle inline-block marginleftonly">';

+		print $codetoconfig;

+		print '</div>';

+		print '</div>';

+		print '</span>';

+		*/

+

+		print '</div>

+	    <div class="info-box-content info-box-text-module">

@@ -2482,15 +2327,18 @@
-		$return .=  '<div class="valignmiddle inline-block info-box-more">';

-		//if ($versiontrans) print img_warning($langs->trans("Version").' '.$this->getVersion(1)).' ';

-		$return .=  '<a class="valignmiddle inline-block" href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.((int) $this->numero).'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule").' - ' : '').$langs->trans("ClickToShowDescription"), $imginfo).'</a>';

-		$return .=  '</div><br>';

-

-		$return .=  '<div class="valignmiddle inline-block info-box-actions">';

-		$return .=  '<div class="valignmiddle inline-block info-box-setup">';

-		$return .=  $codetoconfig;

-		$return .=  '</div>';

-		$return .=  '<div class="valignmiddle inline-block marginleftonly marginrightonly">';

-		$return .=  $codeenabledisable;

-		$return .=  '</div>';

-		$return .=  '</div>';

-

-		$return .=  '

+		/*print '<span class="info-box-icon-version" title="'.$langs->trans("Version").' '.$this->getVersion(1).'">';

+		print $this->getVersion(1);

+		print '</span>'; */

+

+		print '<div class="valignmiddle inline-block info-box-more">';

+		print '<a class="valignmiddle inline-block" href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.$this->numero.'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule").' - ' : '').$langs->trans("ClickToShowDescription"), $imginfo).'</a>';

+		print '</div><br>';

+

+		print '<div class="valignmiddle inline-block info-box-actions">';

+		print '<div class="valignmiddle inline-block info-box-setup">';

+		print $codetoconfig;

+		print '</div>';

+		print '<div class="valignmiddle inline-block marginleftonly marginrightonly">';

+		print $codeenabledisable;

+		print '</div>';

+		print '</div>';

+

+		print '

@@ -2500,32 +2348 @@
-

-		return $return;

-	}

-

-	/**

-	 * Check for module update

-	 * TODO : store results for $this->url_last_version and $this->needUpdate

-	 * Add a cron task to monitor for updates

-	 *

-	 * @return int Return integer <0 if Error, 0 == no update needed,  >0 if need update

-	 */

-	public function checkForUpdate()

-	{

-		require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

-		if (!empty($this->url_last_version)) {

-			$lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0);	// Accept http or https links on external remote server only

-			if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {

-				// Security warning :  be careful with remote data content, the module editor could be hacked (or evil) so limit to a-z A-Z 0-9 _ . -

-				$this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/", "", $lastVersion['content']);

-				if (version_compare($this->lastVersion, $this->version) > 0) {

-					$this->needUpdate = true;

-					return 1;

-				} else {

-					$this->needUpdate = false;

-					return 0;

-				}

-			} else {

-				return -1;

-			}

-		}

-		return 0;

-	}

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modAccounting.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAccounting.class.php
@@ -2,6 +2,6 @@
-/* Copyright (C) 2013-2014	Olivier Geffroy		<jeff@jeffinfo.com>

- * Copyright (C) 2013-2021	Alexandre Spangaro	<aspangaro@open-dsi.fr>

- * Copyright (C) 2014		Ari Elbaz (elarifr)	<github@accedinfo.com>

- * Copyright (C) 2014		Florian Henry		<florian.henry@open-concept.pro>

- * Copyright (C) 2016-2017	Laurent Destailleur	<eldy@users.sourceforge.net>

- * Copyright (C) 2017-2021	Open-DSI			<support@open-dsi.fr>

+/* Copyright (C) 2013-2014 Olivier Geffroy		 <jeff@jeffinfo.com>

+ * Copyright (C) 2013-2019 Alexandre Spangaro	 <aspangaro@open-dsi.fr>

+ * Copyright (C) 2014      Ari Elbaz (elarifr)  <github@accedinfo.com>

+ * Copyright (C) 2014 	    Florian Henry        <florian.henry@open-concept.pro>

+ * Copyright (C) 2016-2017 Laurent Destailleur  <eldy@users.sourceforge.net>

+ * Copyright (C) 2017      Open-DSI             <support@open-dsi.fr>

@@ -31 +31 @@
- * Class to describe and enable double entry accounting module

+ * Description and activation class for module accounting expert

@@ -57 +57 @@
-		$this->picto = 'accountancy';

+		$this->picto = 'accounting';

@@ -60 +60 @@
-		$this->dirs = array('/accounting/temp', '/accounting/export');

+		$this->dirs = array('/accounting/temp');

@@ -63 +63 @@
-		$this->config_page_url = array('accounting.php?mainmenu=accountancy&leftmenu=accountancy_admin');

+		$this->config_page_url = array();

@@ -69 +69 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -126,0 +127,12 @@
+		$this->const[9] = array(

+				"ACCOUNTING_LIST_SORT_VENTILATION_TODO",

+				"yesno",

+				"1",

+				"", 0, 'current', 0

+		);

+		$this->const[10] = array(

+				"ACCOUNTING_LIST_SORT_VENTILATION_DONE",

+				"yesno",

+				"1",

+				"", 0, 'current', 0

+		);

@@ -130 +142 @@
-				"%Y-%m-%d",

+				"%d%m%Y",

@@ -164,9 +176,9 @@
-		$this->rights[$r][0] = 50440;

-		$this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'chartofaccount';

-		$this->rights[$r][5] = '';

-		$r++;

-

-		$this->rights[$r][0] = 50401;

+        $this->rights[$r][0] = 50440;

+        $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'chartofaccount';

+        $this->rights[$r][5] = '';

+        $r++;

+

+        $this->rights[$r][0] = 50401;

@@ -196,23 +208,23 @@
-		$this->rights[$r][0] = 50414;

-		$this->rights[$r][1] = 'Delete operations in Ledger';

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'mouvements';

-		$this->rights[$r][5] = 'supprimer';

-		$r++;

-

-		$this->rights[$r][0] = 50415;

-		$this->rights[$r][1] = 'Delete all operations by year and journal in Ledger';

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'mouvements';

-		$this->rights[$r][5] = 'supprimer_tous';

-		$r++;

-

-		$this->rights[$r][0] = 50418;

-		$this->rights[$r][1] = 'Export operations of the Ledger';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'mouvements';

-		$this->rights[$r][5] = 'export';

-		$r++;

+        $this->rights[$r][0] = 50414;

+        $this->rights[$r][1] = 'Delete operations in Ledger';

+        $this->rights[$r][2] = 'd';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'mouvements';

+        $this->rights[$r][5] = 'supprimer';

+        $r++;

+

+        $this->rights[$r][0] = 50415;

+        $this->rights[$r][1] = 'Delete all operations by year and journal in Ledger';

+        $this->rights[$r][2] = 'd';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'mouvements';

+        $this->rights[$r][5] = 'supprimer_tous';

+        $r++;

+

+        $this->rights[$r][0] = 50418;

+        $this->rights[$r][1] = 'Export operations of the Ledger';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'mouvements';

+        $this->rights[$r][5] = 'export';

+        $r++;

@@ -247 +259 @@
-		$this->export_icon[$r] = $this->picto;

+		$this->export_icon[$r] = 'accounting';

@@ -249,3 +261,3 @@
-		$this->export_fields_array[$r] = array('ac.rowid'=>'ChartofaccountsId', 'ac.pcg_version'=>'Chartofaccounts', 'aa.rowid'=>'ID', 'aa.account_number'=>"AccountAccounting", 'aa.label'=>"Label", 'aa2.account_number'=>"Accountparent", 'aa.pcg_type'=>"Pcgtype", 'aa.active'=>'Status');

-		$this->export_TypeFields_array[$r] = array('ac.rowid'=>'List:accounting_system:pcg_version', 'ac.pcg_version'=>'Text', 'aa.rowid'=>'Numeric', 'aa.account_number'=>"Text", 'aa.label'=>"Text", 'aa2.account_number'=>"Text", 'aa.pcg_type'=>'Text', 'aa.active'=>'Status');

-		$this->export_entities_array[$r] = array(); // We define here only fields that use another picto

+		$this->export_fields_array[$r] = array('ac.rowid'=>'ChartofaccountsId', 'ac.pcg_version'=>'Chartofaccounts', 'aa.rowid'=>'Id', 'aa.account_number'=>"AccountAccounting", 'aa.label'=>"Label", 'aa.account_parent'=>"Accountparent", 'aa.pcg_type'=>"Pcgtype", 'aa.active'=>'Status');

+		$this->export_TypeFields_array[$r] = array('ac.rowid'=>'List:accounting_system:pcg_version', 'aa.account_number'=>"Text", 'aa.label'=>"Text", 'aa.account_parent'=>"Text", 'aa.pcg_type'=>'Text', 'aa.active'=>'Status');

+		$this->export_entities_array[$r] = array('ac.rowid'=>"Accounting", 'ac.pcg_version'=>"Accounting", 'aa.rowid'=>'Accounting', 'aa.account_number'=>"Accounting", 'aa.label'=>"Accounting", 'aa.accountparent'=>"Accounting", 'aa.pcg_type'=>"Accounting", 'aa_active'=>"Accounting");

@@ -255,4 +267,2 @@
-		$this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_system as ac';

-		$this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_account as aa2';

-		$this->export_sql_end[$r] .= ' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').')';

-		$this->export_sql_end[$r] .= ' AND aa2.rowid = aa.account_parent AND aa2.active = 1 AND ac.pcg_version = aa2.fk_pcg_version AND aa2.entity IN ('.getEntity('accounting').')';

+        $this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_system as ac';

+		$this->export_sql_end[$r] .= ' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').') ';

@@ -264,18 +273,0 @@
-

-		// Chart of accounts

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = "Chartofaccounts"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account');

-		$this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id

-		$this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation");

-		$this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$');

-		$this->import_convertvalue_array[$r] = array(

-			'aa.account_number'=>array('rule'=>'accountingaccount'),

-			'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'),

-			'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'),

-		);

-		$this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28");

-		$this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting');

@@ -295,11 +287,10 @@
-			'b.code_journal'=>'Codejournal',

-			'b.journal_label'=>'JournalLabel',

-			'b.numero_compte'=>'AccountAccounting',

-			'b.label_compte'=>'LabelAccount',

-			'b.subledger_account'=>'SubledgerAccount',

-			'b.subledger_label'=>'SubledgerAccountLabel',

-			'b.label_operation'=>'LabelOperation',

-			'b.debit'=>"Debit",

-			'b.credit'=>"Credit",

-			'b.sens'=>'Direction'	// This field is still used by accounting export. We can remove it once it has been replaced into accountancyexport.class.php by a detection using ->debit and ->credit

-		);

+            'b.code_journal'=>'Codejournal',

+            //'b.journal_label'=>'JournalLabel',

+            'b.numero_compte'=>'AccountAccounting',

+            //'b.label_compte'=>'LabelAccount',

+            'b.subledger_account'=>'SubledgerAccount',

+            'b.subledger_label'=>'SubledgerAccountLabel',

+            'b.label_operation'=>'LabelOperation',

+            'b.debit'=>"Debit",

+            'b.credit'=>"Credit"

+        );

@@ -308,4 +298,0 @@
-		$this->import_convertvalue_array[$r] = array(

-			'b.numero_compte' => array('rule' => 'accountingaccount'),

-			'b.subledger_account' => array('rule' => 'accountingaccount')

-		);

@@ -313 +300 @@
-			'b.piece_num'=>'123 (!!! use next value not already used)',

+		    'b.piece_num'=>'123 (!!! use next value not already used)',

@@ -317,13 +304,12 @@
-			'b.code_journal'=>"VTE",

-			'b.journal_label'=>"Sale journal",

-			'b.numero_compte'=>"707",

-			'b.label_compte'=>'Product account 707',

-			'b.subledger_account'=>'',

-			'b.subledger_label'=>'',

-			'b.label_operation'=>"Sale of ABC",

-			'b.debit'=>"0",

-			'b.credit'=>"100",

-			'b.sens'=>'C'	// This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit

-		);

-

-		// General ledger - File FEC

+            'b.code_journal'=>"VTE",

+            //'b.journal_label'=>"Sale journal",

+            'b.numero_compte'=>"707",

+            //'b.label_compte'=>'Product account 707',

+            'b.subledger_account'=>'',

+            'b.subledger_label'=>'',

+            'b.label_operation'=>"Sale of ABC",

+            'b.debit'=>"0",

+            'b.credit'=>"100"

+        );

+

+		// Chart of accounts

@@ -332 +318 @@
-		$this->import_label[$r] = 'ImportAccountingEntriesFECFormat';

+		$this->import_label[$r] = "Chartofaccounts"; // Translation key

@@ -335,69 +321,10 @@
-		$this->import_tables_array[$r] = array('b'=>MAIN_DB_PREFIX.'accounting_bookkeeping'); // List of tables to insert into (insert done in same order)

-		$this->import_fields_array[$r] = array(

-			'b.code_journal'=>'FECFormatJournalCode*',

-			'b.journal_label'=>'FECFormatJournalLabel',

-			'b.piece_num'=>'FECFormatEntryNum*',

-			'b.doc_date'=>'FECFormatEntryDate*',

-			'b.numero_compte'=>'FECFormatGeneralAccountNumber*',

-			'b.label_compte'=>'FECFormatGeneralAccountLabel*',

-			'b.subledger_account'=>'FECFormatSubledgerAccountNumber',

-			'b.subledger_label'=>'FECFormatSubledgerAccountLabel',

-			'b.doc_ref'=>'FECFormatPieceRef*',

-			'b.date_creation'=>'FECFormatPieceDate',

-			'b.label_operation'=>'FECFormatLabelOperation',

-			'b.debit'=>'FECFormatDebit*',

-			'b.credit'=>'FECFormatCredit*',

-			'b.lettering_code'=>'FECFormatReconcilableCode',

-			'b.date_lettering'=>'FECFormatReconcilableDate',

-			'b.date_validated'=>'FECFormatValidateDate',

-			'b.multicurrency_amount'=>'FECFormatMulticurrencyAmount',

-			'b.multicurrency_code'=>'FECFormatMulticurrencyCode'

-		);

-		$this->import_fieldshidden_array[$r] = array(

-			'b.doc_type'=>'const-import_from_external',

-			'b.fk_doc'=>'const-0',

-			'b.fk_docdet'=>'const-0',

-			'b.fk_user_author'=>'user->id',

-			'b.montant'=>'rule-computeAmount',

-			'b.sens'=>'rule-computeDirection'

-		); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

-		$this->import_convertvalue_array[$r]=array(

-			'b.piece_num' => array('rule' => 'compute', 'type' => 'int', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanValue', 'element' => 'Accountancy'),

-			'b.numero_compte'=>array('rule'=>'accountingaccount'),

-			'b.subledger_account'=>array('rule'=>'accountingaccount'),

-			'b.debit' => array('rule' => 'compute', 'type' => 'double', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),

-			'b.credit' => array('rule' => 'compute', 'type' => 'double', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),

-			'b.multicurrency_amount' => array('rule' => 'compute', 'type' => 'double', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),

-			'b.montant' => array('rule' => 'compute', 'type' => 'double', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeAmount', 'element' => 'Accountancy'),

-			'b.sens' => array('rule' => 'compute', 'type' => 'varchar', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeDirection', 'element' => 'Accountancy'),

-		);

-		$this->import_regex_array[$r] = array(

-			//'b.doc_date'=>'^\d{4}\d{2}\d{2}$',

-			'b.doc_ref'=>'^.{1,300}$',

-			'b.numero_compte'=>'^.{1,32}$',

-			'b.label_compte'=>'^.{1,255}$',

-			'b.subledger_compte'=>'^.{1,32}$',

-			'b.subledger_label'=>'^.{1,255}$',

-			'b.label_operation'=>'^.{1,255}$',

-			//'b.sens'=>'^[D|C]$',

-		);

-		$this->import_examplevalues_array[$r] = array(

-			'b.code_journal'=>"VT",

-			'b.journal_label'=>"Sale journal",

-			'b.piece_num'=>'123 (!!! use next value not already used)',

-			'b.doc_date'=>dol_print_date(dol_now(), "%Y%m%d"),

-			'b.numero_compte'=>"707",

-			'b.label_compte'=>'Sale',

-			'b.subledger_account'=>'',

-			'b.subledger_label'=>'',

-			'b.doc_ref'=>'My document ABC',

-			'b.date_creation'=>dol_print_date(dol_now(), "%Y%m%d"),

-			'b.label_operation'=>"Sale of ABC",

-			'b.debit'=>"0",

-			'b.credit'=>"100",

-			'b.lettering_code'=>'ABC',

-			'b.date_lettering'=>dol_print_date(dol_now(), "%Y%m%d"),

-			'b.date_validated'=>dol_print_date(dol_now(), "%Y%m%d"),

-			'b.multicurrency_amount'=>"90 (Necessary if devise is different than EUR)",

-			'b.multicurrency_code'=>"US (Necessary if devise is different than EUR)",

-		);

+		$this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account');

+		$this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id

+		$this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation");

+		$this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$');

+		$this->import_convertvalue_array[$r] = array(

+		    'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'),

+		    'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'),

+		);

+		$this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28");

+		$this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting');

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modAdherent.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAdherent.class.php
@@ -30 +30 @@
- *      \brief      Description and activation file for the module member

+ *      \brief      File descriptor or module Member

@@ -39,26 +39,148 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		global $conf;

-

-		$this->db = $db;

-		$this->numero = 310;

-

-		$this->family = "hr";

-		$this->module_position = '06';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Management of members of a foundation or association";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		$this->picto = 'member';

-

-		// Data directories to create when module is enabled

-		$this->dirs = array(

-			"/adherent/temp",

-			"/doctemplates/members",

+

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        global $conf;

+

+        $this->db = $db;

+        $this->numero = 310;

+

+        $this->family = "hr";

+        $this->module_position = '06';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Management of members of a foundation or association";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        $this->picto = 'member';

+

+        // Data directories to create when module is enabled

+        $this->dirs = array("/adherent/temp");

+

+        // Config pages

+        $this->config_page_url = array("adherent.php@adherents");

+

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

+        $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled

+        $this->requiredby = array(); // List of module ids to disable if this one is disabled

+        $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with

+        $this->langfiles = array("members", "companies");

+        $this->phpmin = array(5, 4); // Minimum version of PHP required by module

+

+        // Constants

+        $this->const = array();

+        $r = 0;

+

+        $this->const[$r][0] = "ADHERENT_ADDON_PDF";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "standard";

+        $this->const[$r][3] = 'Name of PDF model of member';

+        $this->const[$r][4] = 0;

+        $r++;

+

+        // For emails

+        $this->const[$r][0] = "ADHERENT_MAIL_FROM";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "";

+        $this->const[$r][3] = "From des mails";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER";

+        $this->const[$r][1] = "emailtemplate:member";

+        $this->const[$r][2] = "(SendingEmailOnAutoSubscription)";

+        $this->const[$r][3] = "";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION";

+        $this->const[$r][1] = "emailtemplate:member";

+        $this->const[$r][2] = "(SendingEmailOnNewSubscription)";

+        $this->const[$r][3] = "";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION";

+        $this->const[$r][1] = "emailtemplate:member";

+        $this->const[$r][2] = "(SendingReminderForExpiredSubscription)";

+        $this->const[$r][3] = "";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_CANCELATION";

+        $this->const[$r][1] = "emailtemplate:member";

+        $this->const[$r][2] = "(SendingEmailOnCancelation)";

+        $this->const[$r][3] = "";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        // For cards

+        $this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "__YEAR__";

+        $this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "__COMPANY__";

+        $this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_CARD_TEXT";

+        $this->const[$r][1] = "texte";

+        $this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__";

+        $this->const[$r][3] = "Text to print on member cards";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_MAILMAN_ADMINPW";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "";

+        $this->const[$r][3] = "Mot de passe Admin des liste mailman";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "L7163";

+        $this->const[$r][3] = "Type of address sheets";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT";

+        $this->const[$r][1] = "texte";

+        $this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY%";

+        $this->const[$r][3] = "Text to print on member address sheets";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        // For subscriptions

+        $this->const[$r][0] = "ADHERENT_BANK_ACCOUNT";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "";

+        $this->const[$r][3] = "ID of bank account to use";

+        $this->const[$r][4] = 0;

+        $r++;

+

+        $this->const[$r][0] = "ADHERENT_BANK_CATEGORIE";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "";

+        $this->const[$r][3] = "ID of bank transaction category to use";

+        $this->const[$r][4] = 0;

+        $r++;

+

+

+        // Boxes

+        //-------

+        $this->boxes = array(

+			0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'),

+			2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home')

@@ -67,234 +189,98 @@
-		// Config pages

-		$this->config_page_url = array("member.php@adherents");

-

-		// Dependencies

-		$this->hidden = false; // A condition to hide module

-		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled

-		$this->requiredby = array(); // List of module ids to disable if this one is disabled

-		$this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with

-		$this->langfiles = array("members", "companies");

-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-

-		// Constants

-		$this->const = array();

-		$r = 0;

-

-		$this->const[$r][0] = "ADHERENT_ADDON_PDF";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "standard";

-		$this->const[$r][3] = 'Name of PDF model of member';

-		$this->const[$r][4] = 0;

-		$r++;

-

-		// For emails

-		$this->const[$r][0] = "ADHERENT_MAIL_FROM";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "";

-		$this->const[$r][3] = "From des mails";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER";

-		$this->const[$r][1] = "emailtemplate:member";

-		$this->const[$r][2] = "(SendingEmailOnAutoSubscription)";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION";

-		$this->const[$r][1] = "emailtemplate:member";

-		$this->const[$r][2] = "(SendingEmailOnNewSubscription)";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION";

-		$this->const[$r][1] = "emailtemplate:member";

-		$this->const[$r][2] = "(SendingReminderForExpiredSubscription)";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_CANCELATION";

-		$this->const[$r][1] = "emailtemplate:member";

-		$this->const[$r][2] = "(SendingEmailOnCancelation)";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		// For cards

-		$this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "__YEAR__";

-		$this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "__COMPANY__";

-		$this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_CARD_TEXT";

-		$this->const[$r][1] = "texte";

-		$this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__";

-		$this->const[$r][3] = "Text to print on member cards";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_MAILMAN_ADMIN_PASSWORD";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "";

-		$this->const[$r][3] = "Mot de passe Admin des liste mailman";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "L7163";

-		$this->const[$r][3] = "Type of address sheets";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT";

-		$this->const[$r][1] = "texte";

-		$this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";

-		$this->const[$r][3] = "Text to print on member address sheets";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		// For subscriptions

-		$this->const[$r][0] = "ADHERENT_BANK_ACCOUNT";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "";

-		$this->const[$r][3] = "ID of bank account to use";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "ADHERENT_BANK_CATEGORIE";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "";

-		$this->const[$r][3] = "ID of bank transaction category to use";

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->const[$r][0] = "MEMBER_ADDON_PDF_ODT_PATH";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/members";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

-

-		// Boxes

-		//-------

-		$this->boxes = array(

-			0 => array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'),

-			2 => array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'),

-			3 => array('file'=>'box_members_last_modified.php', 'enabledbydefaulton'=>'membersindex'),

-			4 => array('file'=>'box_members_last_subscriptions.php', 'enabledbydefaulton'=>'membersindex'),

-			5 => array('file'=>'box_members_subscriptions_by_year.php', 'enabledbydefaulton'=>'membersindex'),

-			6 => array('file'=>'box_members_by_type.php', 'enabledbydefaulton'=>'membersindex'),

-			7 => array('file'=>'box_members_by_tags.php', 'enabledbydefaulton'=>'membersindex'),

-		);

-

-		// Permissions

-		//------------

-		$this->rights = array();

-		$this->rights_class = 'adherent';

-		$r = 0;

-

-		// $this->rights[$r][0]     Id permission (unique tous modules confondus)

-		// $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

-		// $this->rights[$r][2]     Non utilise

-		// $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

-		// $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

-		// $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

-

-		$r++;

-		$this->rights[$r][0] = 71;

-		$this->rights[$r][1] = 'Read members\' card';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'lire';

-

-		$r++;

-		$this->rights[$r][0] = 72;

-		$this->rights[$r][1] = 'Create/modify members (need also user module permissions if member linked to a user)';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'creer';

-

-		$r++;

-		$this->rights[$r][0] = 74;

-		$this->rights[$r][1] = 'Remove members';

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'supprimer';

-

-		$r++;

-		$this->rights[$r][0] = 76;

-		$this->rights[$r][1] = 'Export members';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'export';

-

-		$r++;

-		$this->rights[$r][0] = 75;

-		$this->rights[$r][1] = 'Setup types of membership';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'configurer';

-

-		$r++;

-		$this->rights[$r][0] = 78;

-		$this->rights[$r][1] = 'Read membership fees';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'cotisation';

-		$this->rights[$r][5] = 'lire';

-

-		$r++;

-		$this->rights[$r][0] = 79;

-		$this->rights[$r][1] = 'Create/modify/remove membership fees';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'cotisation';

-		$this->rights[$r][5] = 'creer';

-

-

-		// Menus

-		//-------

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

-

-

-		// Exports

-		//--------

-		$r = 0;

-

-		// $this->export_code[$r]          Unique code identifying the export (all modules combined)

-		// $this->export_label[$r]         Libelle by default if translation of key "ExportXXX" not found (XXX = Code)

-		// $this->export_permission[$r]    List of permission codes required to export

-		// $this->export_fields_sql[$r]    List of exportable fields in SQL codiffication

-		// $this->export_fields_name[$r]   List of exportable fields in translation codiffication

-		// $this->export_sql[$r]           SQL query that offers data for export

-

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_'.$r;

-		$this->export_label[$r] = 'MembersAndSubscriptions';

-		$this->export_permission[$r] = array(array("adherent", "export"));

-		$this->export_fields_array[$r] = array(

-			'a.rowid'=>'MemberId', 'a.ref'=>'MemberRef', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'MemberNature',

-			'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.code_departement'=>'StateCode', 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country",

-			'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status",

-			'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation',

-			'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel',

-			'c.rowid'=>'SubscriptionId', 'c.dateadh'=>'DateSubscription', 'c.datef'=>'DateEndSubscription', 'c.subscription'=>'Amount'

-		);

-		$this->export_TypeFields_array[$r] = array(

-			'a.civility'=>"Text", 'a.lastname'=>"Text", 'a.firstname'=>"Text", 'a.login'=>"Text", 'a.gender'=>'Text', 'a.morphy'=>'Text', 'a.societe'=>'Text', 'a.address'=>"Text",

-			'a.zip'=>"Text", 'a.town'=>"Text", 'd.nom'=>"Text", 'co.code'=>'Text', 'co.label'=>"Text", 'a.phone'=>"Text", 'a.phone_perso'=>"Text", 'a.phone_mobile'=>"Text",

-			'a.email'=>"Text", 'a.birth'=>"Date", 'a.statut'=>"Status", 'a.note_public'=>"Text", 'a.note_private'=>"Text", 'a.datec'=>'Date', 'a.datevalid'=>'Date',

-			'a.tms'=>'Date', 'a.datefin'=>'Date', 'ta.rowid'=>'List:adherent_type:libelle::member_type', 'ta.libelle'=>'Text',

+        // Permissions

+        //------------

+        $this->rights = array();

+        $this->rights_class = 'adherent';

+        $r = 0;

+

+        // $this->rights[$r][0]     Id permission (unique tous modules confondus)

+        // $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

+        // $this->rights[$r][2]     Non utilise

+        // $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

+        // $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

+        // $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

+

+        $r++;

+        $this->rights[$r][0] = 71;

+        $this->rights[$r][1] = 'Read members\' card';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'lire';

+

+        $r++;

+        $this->rights[$r][0] = 72;

+        $this->rights[$r][1] = 'Create/modify members (need also user module permissions if member linked to a user)';

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'creer';

+

+        $r++;

+        $this->rights[$r][0] = 74;

+        $this->rights[$r][1] = 'Remove members';

+        $this->rights[$r][2] = 'd';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'supprimer';

+

+        $r++;

+        $this->rights[$r][0] = 76;

+        $this->rights[$r][1] = 'Export members';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'export';

+

+        $r++;

+        $this->rights[$r][0] = 75;

+        $this->rights[$r][1] = 'Setup types of membership';

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'configurer';

+

+        $r++;

+        $this->rights[$r][0] = 78;

+        $this->rights[$r][1] = 'Read subscriptions';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'cotisation';

+        $this->rights[$r][5] = 'lire';

+

+        $r++;

+        $this->rights[$r][0] = 79;

+        $this->rights[$r][1] = 'Create/modify/remove subscriptions';

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'cotisation';

+        $this->rights[$r][5] = 'creer';

+

+

+        // Menus

+        //-------

+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.

+

+

+        // Exports

+        //--------

+        $r = 0;

+

+        // $this->export_code[$r]          Unique code identifying the export (all modules combined)

+        // $this->export_label[$r]         Libelle by default if translation of key "ExportXXX" not found (XXX = Code)

+        // $this->export_permission[$r]    List of permission codes required to export

+        // $this->export_fields_sql[$r]    List of exportable fields in SQL codiffication

+        // $this->export_fields_name[$r]   List of exportable fields in translation codiffication

+        // $this->export_sql[$r]           SQL query that offers data for export

+

+        $r++;

+        $this->export_code[$r] = $this->rights_class.'_'.$r;

+        $this->export_label[$r] = 'MembersAndSubscriptions';

+        $this->export_permission[$r] = array(array("adherent", "export"));

+        $this->export_fields_array[$r] = array(

+            'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'Nature',

+            'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country",

+            'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status",

+            'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation',

+            'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel',

+            'c.rowid'=>'SubscriptionId', 'c.dateadh'=>'DateSubscription', 'c.datef'=>'DateEndSubscription', 'c.subscription'=>'Amount'

+        );

+        $this->export_TypeFields_array[$r] = array(

+            'a.civility'=>"Text", 'a.lastname'=>"Text", 'a.firstname'=>"Text", 'a.login'=>"Text", 'a.gender'=>'Text', 'a.morphy'=>'Text', 'a.societe'=>'Text', 'a.address'=>"Text",

+            'a.zip'=>"Text", 'a.town'=>"Text", 'd.nom'=>"Text", 'co.code'=>'Text', 'co.label'=>"Text", 'a.phone'=>"Text", 'a.phone_perso'=>"Text", 'a.phone_mobile'=>"Text",

+            'a.email'=>"Text", 'a.birth'=>"Date", 'a.statut'=>"Status", 'a.note_public'=>"Text", 'a.note_private'=>"Text", 'a.datec'=>'Date', 'a.datevalid'=>'Date',

+            'a.tms'=>'Date', 'a.datefin'=>'Date', 'ta.rowid'=>'List:adherent_type:libelle::member_type', 'ta.libelle'=>'Text',

@@ -302,7 +288,7 @@
-		);

-		$this->export_entities_array[$r] = array(

-			'a.rowid'=>'member', 'a.ref'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member',

-			'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member",

-			'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member",

-			'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member',

-			'a.datefin'=>'member', 'ta.rowid'=>'member_type', 'ta.libelle'=>'member_type',

+        );

+        $this->export_entities_array[$r] = array(

+            'a.rowid'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member',

+            'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member",

+            'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member",

+            'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member',

+            'a.datefin'=>'member', 'ta.rowid'=>'member_type', 'ta.libelle'=>'member_type',

@@ -310,153 +296,122 @@
-		);

-		// Add extra fields

-		$keyforselect = 'adherent';

-		$keyforelement = 'member';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		// End add axtra fields

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid';

-		$this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';

-		$this->export_dependencies_array[$r] = array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

-

-		// Imports

-		//--------

-		$r = 0;

-

-		$now = dol_now();

-		require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';

-

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = "Members"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields');

-		$this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'a.ref' => 'MemberRef*',

-			'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password",

-			"a.fk_adherent_type"=>"MemberTypeId*", 'a.morphy'=>'MemberNature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town",

-			'a.state_id'=>'StateId|StateCode', 'a.country'=>"CountryId|CountryCode", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile",

-			'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate",

-			'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription'

-		);

-		if (isModEnabled("societe")) {

-			$this->import_fields_array[$r]['a.fk_soc'] = "ThirdParty";

-		}

-		// Add extra fields

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-			}

-		}

-		// End add extra fields

-		$this->import_convertvalue_array[$r] = array(

-			'a.ref'=>array(

-				'rule'=>'getrefifauto',

-				'class'=>(!getDolGlobalString('MEMBER_ADDON') ? 'mod_member_simple' : $conf->global->MEMBER_ADDON),

-				'path'=>"/core/modules/member/".(!getDolGlobalString('MEMBER_ADDON') ? 'mod_member_simple' : $conf->global->MEMBER_ADDON).'.php'

-			),

-			'a.state_id' => array(

-				'rule' => 'fetchidfromcodeid',

-				'classfile' => '/core/class/cstate.class.php',

-				'class' => 'Cstate',

-				'method' => 'fetch',

-				'dict' => 'DictionaryStateCode'

-			),

-			'a.country' => array(

-				'rule' => 'fetchidfromcodeid',

-				'classfile' => '/core/class/ccountry.class.php',

-				'class' => 'Ccountry',

-				'method' => 'fetch',

-				'dict' => 'DictionaryCountry'

-			)

-		);

-		if (isModEnabled("societe")) {

-			$this->import_convertvalue_array[$r]['a.fk_soc'] = array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty');

-		}

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

-		$this->import_regex_array[$r] = array(

-			'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy'=>'(phy|mor)',

-			'a.statut'=>'^[0|1]', 'a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');

-		$this->import_examplevalues_array[$r] = array(

-			'a.ref'=>"auto or MEM2010-1234",

-			'a.civility'=>"MR", 'a.lastname'=>'Smith', 'a.firstname'=>'John', 'a.gender'=>'man or woman', 'a.login'=>'jsmith', 'a.pass'=>'passofjsmith', 'a.fk_adherent_type'=>'1',

-			'a.morphy'=>'"mor" or "phy"', 'a.societe'=>'JS company', 'a.address'=>'21 jump street', 'a.zip'=>'55000', 'a.town'=>'New York', 'a.country'=>'1',

-			'a.email'=>'jsmith@example.com', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member",

-			'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')

-		);

-		if (isModEnabled("societe")) {

-			$this->import_examplevalues_array[$r]['a.fk_soc'] = "rowid or name";

-		}

-		$this->import_updatekeys_array[$r] = array('a.ref'=>'MemberRef', 'a.login'=>'Login');

-

-		// Cronjobs

-		$arraydate = dol_getdate(dol_now());

-		$datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);

-		$this->cronjobs = array(

-			0=>array(

-				'label'=>'SendReminderForExpiredSubscriptionTitle',

-				'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php',

-				'objectname'=>'Adherent',

-				'method'=>'sendReminderForExpiredSubscription',

-				'parameters'=>'10;0',

-				'comment'=>'SendReminderForExpiredSubscription',

-				'frequency'=>1,

-				'unitfrequency'=> 3600 * 24,

-				'priority'=>50,

-				'status'=>1,

-				'test'=>'$conf->adherent->enabled',

-				'datestart'=>$datestart

-			),

-		);

-	}

-

-

-	/**

-	 *		Function called when module is enabled.

-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *		It also creates data directories

-	 *

-	 *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

-	 *      @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf, $langs;

-

-		// Permissions

-		$this->remove($options);

-

-		// ODT template

-		/*

-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';

-		$dirodt=DOL_DATA_ROOT.'/doctemplates/orders';

-		$dest=$dirodt.'/template_order.odt';

-

-		if (file_exists($src) && ! file_exists($dest)) {

-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-			dol_mkdir($dirodt);

-			$result=dol_copy($src,$dest,0,0);

-			if ($result < 0) {

-				$langs->load("errors");

-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);

-				return 0;

-			}

-		}*/

-

-		$sql = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".((int) $conf->entity).")"

-		);

-

-		return $this->_init($sql, $options);

-	}

+        );

+        // Add extra fields

+        $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra';

+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+        // End add axtra fields

+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';

+        $this->export_sql_end[$r]  = ' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid';

+        $this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';

+        $this->export_dependencies_array[$r] = array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

+

+        // Imports

+        //--------

+        $r = 0;

+

+        $now = dol_now();

+        require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';

+

+        $r++;

+        $this->import_code[$r] = $this->rights_class.'_'.$r;

+        $this->import_label[$r] = "Members"; // Translation key

+        $this->import_icon[$r] = $this->picto;

+        $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

+        $this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields');

+        $this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id

+        $this->import_fields_array[$r] = array(

+            'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password",

+            "a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'Nature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town",

+            'a.state_id'=>'StateId', 'a.country'=>"CountryId", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile",

+            'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate",

+            'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription'

+        );

+        // Add extra fields

+        $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";

+        $resql = $this->db->query($sql);

+        if ($resql)    // This can fail when class is used on old database (during migration for example)

+        {

+            while ($obj = $this->db->fetch_object($resql))

+            {

+                $fieldname = 'extra.'.$obj->name;

+                $fieldlabel = ucfirst($obj->label);

+                $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

+            }

+        }

+        // End add extra fields

+        $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

+        $this->import_regex_array[$r] = array(

+            'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy'=>'(phy|mor)',

+            'a.statut'=>'^[0|1]', 'a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');

+        $this->import_examplevalues_array[$r] = array(

+            'a.civility'=>"MR", 'a.lastname'=>'Smith', 'a.firstname'=>'John', 'a.login'=>'jsmith', 'a.pass'=>'passofjsmith', 'a.fk_adherent_type'=>'1',

+            'a.morphy'=>'"mor" or "phy"', 'a.societe'=>'JS company', 'a.address'=>'21 jump street', 'a.zip'=>'55000', 'a.town'=>'New York', 'a.country'=>'1',

+            'a.email'=>'jsmith@example.com', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member",

+            'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')

+        );

+

+        // Cronjobs

+        $arraydate = dol_getdate(dol_now());

+        $datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);

+        $this->cronjobs = array(

+            0=>array(

+                'label'=>'SendReminderForExpiredSubscriptionTitle',

+                'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php',

+                'objectname'=>'Adherent',

+                'method'=>'sendReminderForExpiredSubscription',

+                'parameters'=>'10;0',

+                'comment'=>'SendReminderForExpiredSubscription',

+                'frequency'=>1,

+                'unitfrequency'=> 3600 * 24,

+                'priority'=>50,

+                'status'=>1,

+                'test'=>'$conf->adherent->enabled',

+                'datestart'=>$datestart

+            ),

+        );

+    }

+

+

+    /**

+     *		Function called when module is enabled.

+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *		It also creates data directories

+     *

+     *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

+     *      @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf, $langs;

+

+        // Permissions

+        $this->remove($options);

+

+        //ODT template

+        /*

+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';

+        $dirodt=DOL_DATA_ROOT.'/doctemplates/orders';

+        $dest=$dirodt.'/template_order.odt';

+

+        if (file_exists($src) && ! file_exists($dest))

+        {

+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+            dol_mkdir($dirodt);

+            $result=dol_copy($src,$dest,0,0);

+            if ($result < 0)

+            {

+                $langs->load("errors");

+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);

+                return 0;

+            }

+        }*/

+

+        $sql = array(

+            "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".$conf->entity,

+            "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".$conf->entity.")"

+        );

+

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modAgenda.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAgenda.class.php
@@ -31 +31 @@
- *      \brief      Description and activation file for the module agenda

+ *      \brief      File of class to describe and enable/disable module Agenda

@@ -39,0 +40 @@
+

@@ -53 +54 @@
-		$this->module_position = '16';

+		$this->module_position = '15';

@@ -75 +76 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -78 +79 @@
-		$this->module_parts = array();

+        $this->module_parts = array();

@@ -81,5 +82,5 @@
-		//-----------

-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

-		// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),

-		//                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)

-		// );

+        //-----------

+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

+        // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),

+        //                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)

+        // );

@@ -90,11 +91,13 @@
-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				//if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue;    // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).

-				if (preg_match('/^TASK_/', $obj->code)) {

-					continue; // We don't track such events by default.

-				}

-				//if (preg_match('/^_MODIFY/',$obj->code)) continue;    // We don't track such events by default.

-				$this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');

-			}

-		} else {

-			dol_print_error($this->db->lasterror());

+		if ($resql)

+		{

+		    while ($obj = $this->db->fetch_object($resql))

+		    {

+		        //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue;    // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).

+		        if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.

+		        //if (preg_match('/^_MODIFY/',$obj->code)) continue;    // We don't track such events by default.

+		        $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');

+		    }

+		}

+		else

+		{

+		    dol_print_error($this->db->lasterror());

@@ -109,4 +112 @@
-		$this->boxes = array(

-			0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home'),

-			1=>array('file'=>'box_actions_future.php', 'enabledbydefaulton'=>'Home')

-		);

+		$this->boxes = array(0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home'));

@@ -118 +118 @@
-			0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'isModEnabled("agenda")', 'datestart'=>$datestart),

+			0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart),

@@ -208,14 +208,13 @@
-			'fk_menu'=>0,

-			'type'=>'top',

-			'titre'=>'TMenuAgenda',

-			'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth"'),

-			'mainmenu'=>'agenda',

-			'url'=>'/comm/action/index.php',

-			'langs'=>'agenda',

-			'position'=>86,

-			'perms'=>'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',

-			'enabled'=>'isModEnabled("agenda") || isModEnabled("resource")',

-			'target'=>'',

-			'user'=>2,

-		);

-		$r++;

+            'fk_menu'=>0,

+            'type'=>'top',

+            'titre'=>'TMenuAgenda',

+            'mainmenu'=>'agenda',

+            'url'=>'/comm/action/index.php',

+            'langs'=>'agenda',

+            'position'=>86,

+            'perms'=>'$user->rights->agenda->myactions->read',

+            'enabled'=>'$conf->agenda->enabled',

+            'target'=>'',

+            'user'=>2,

+        );

+        $r++;

@@ -227 +225,0 @@
-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

@@ -232,2 +230,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -246,2 +244,2 @@
-			'perms'=>'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)',

+			'enabled'=>'$conf->agenda->enabled',

@@ -261,2 +259,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -275,2 +273,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -289,2 +287,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -303,2 +301,2 @@
-			'perms'=>'$user->hasRight("agenda", "allactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->allactions->read',

+			'enabled'=>'$user->rights->agenda->allactions->read',

@@ -317,2 +315,2 @@
-			'perms'=>'$user->hasRight("agenda", "allactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->allactions->read',

+			'enabled'=>'$user->rights->agenda->allactions->read',

@@ -330 +328 @@
-			'url'=>'/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda',

+			'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda',

@@ -333,2 +331,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -344 +342 @@
-			'url'=>'/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',

+			'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',

@@ -347,2 +345,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -358 +356 @@
-			'url'=>'/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',

+			'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',

@@ -361,2 +359,2 @@
-			'perms'=>'$user->hasRight("agenda", "myactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->myactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -372 +370 @@
-			'url'=>'/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',

+			'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',

@@ -375,2 +373,2 @@
-			'perms'=>'$user->hasRight("agenda", "allactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->allactions->read',

+			'enabled'=>'$user->rights->agenda->allactions->read',

@@ -386 +384 @@
-			'url'=>'/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',

+			'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',

@@ -389,2 +387,2 @@
-			'perms'=>'$user->hasRight("agenda", "allactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->allactions->read',

+			'enabled'=>'$user->rights->agenda->allactions->read',

@@ -404,2 +402,2 @@
-			'perms'=>'$user->hasRight("agenda", "allactions", "read")',

-			'enabled'=>'isModEnabled("agenda")',

+			'perms'=>'$user->rights->agenda->allactions->read',

+			'enabled'=>'$conf->agenda->enabled',

@@ -419,2 +417,2 @@
-			'perms' => '$user->hasRight("agenda", "allactions", "read")',

-			'enabled' => 'isModEnabled("categorie")',

+			'perms' => '$user->rights->agenda->allactions->read',

+			'enabled' => '$conf->categorie->enabled&&$conf->categorie->enabled',

@@ -461,5 +458,0 @@
-		$keyforselect = 'actioncomm';

-		$keyforelement = 'action';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

@@ -468 +460,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra ON ac.id = extra.fk_object';

@@ -470,3 +462 @@
-		if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';

-		}

+		if (!empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';

@@ -475,3 +465 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (!empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -481,6 +469,2 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';

-		}

-		if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {

-			$this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);

-		}

+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';

+		if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modApi.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modApi.class.php
@@ -23,2 +23 @@
- *  \brief      Module for API (REST) management

- *

+ *  \brief      Descriptor file for Api modulee

@@ -27 +26 @@
- *  \brief      Description and activation file for the module Api

+ *  \brief      Description and activation file for module Api

@@ -44,3 +43,3 @@
-		global $langs, $conf;

-

-		$this->db = $db;

+        global $langs, $conf;

+

+        $this->db = $db;

@@ -85 +84 @@
-		$this->requiredby = array('modZapier'); // List of modules id to disable if this one is disabled

+		$this->requiredby = array(); // List of modules id to disable if this one is disabled

@@ -87 +86 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -99,2 +98,2 @@
-		//                              'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@api:$user->rights->othermodule->read:/api/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		//                              'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //                              'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@api:$user->rights->othermodule->read:/api/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        //                              'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

@@ -111 +110 @@
-		// 'order'            to add a tab in sales order view

+		// 'order'            to add a tab in customer order view

@@ -121,7 +120,8 @@
-		$this->tabs = array();

-

-		// Dictionaries

-		if (!isset($conf->api->enabled)) {

-			$conf->api = new stdClass();

-			$conf->api->enabled = 0;

-		}

+        $this->tabs = array();

+

+        // Dictionaries

+	    if (!isset($conf->api->enabled))

+        {

+        	$conf->api = new stdClass();

+        	$conf->api->enabled = 0;

+        }

@@ -130 +130 @@
-		// Boxes

+        // Boxes

@@ -132 +132 @@
-		$this->boxes = array(); // List of boxes

+        $this->boxes = array(); // List of boxes

@@ -138,2 +137,0 @@
-		$this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)

-

@@ -144,6 +142,6 @@
-		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)

-		$this->rights[$r][1] = 'Generate/modify users API key';	// Permission label

-		$this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'apikey';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		$this->rights[$r][5] = 'generate';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		$r++;

+		// $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)

+		// $this->rights[$r][1] = 'Permision label';	// Permission label

+		// $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

+		// $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+		// $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+		// $r++;

@@ -156,13 +154,31 @@
-		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools',

-			'type'=>'left',

-			'titre'=>'ApiExplorer',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

-			'mainmenu'=>'tools',

-			'leftmenu'=>'devtools_api',

-			'url'=>'/api/index.php/explorer',

-			'langs'=>'modulebuilder',

-			'position'=>100,

-			'perms'=>'1',

-			'enabled'=>'isModEnabled("api")',

-			'target'=>'_apiexplorer',

-			'user'=>0);

+		// Add here entries to declare new menus

+		//

+		// Example to declare a new Top Menu entry and its Left menu entry:

+		// $this->menu[$r]=array(	'fk_menu'=>0,			                // Put 0 if this is a top menu

+		//							'type'=>'top',			                // This is a Top menu entry

+		//							'titre'=>'Api top menu',

+		//							'mainmenu'=>'api',

+		//							'leftmenu'=>'api',

+		//							'url'=>'/api/pagetop.php',

+		//							'langs'=>'mylangfile@api',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+		//							'position'=>100,

+		//							'enabled'=>'$conf->api->enabled',	// Define condition to show or hide menu entry. Use '$conf->api->enabled' if entry must be visible if module is enabled.

+		//							'perms'=>'1',			                // Use 'perms'=>'$user->rights->api->level1->level2' if you want your menu with a permission rules

+		//							'target'=>'',

+		//							'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both

+		// $r++;

+		//

+		// Example to declare a Left Menu entry into an existing Top menu entry:

+		// $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=xxx',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+		//							'type'=>'left',			                // This is a Left menu entry

+		//							'titre'=>'Api left menu',

+		//							'mainmenu'=>'xxx',

+		//							'leftmenu'=>'api',

+		//							'url'=>'/api/pagelevel2.php',

+		//							'langs'=>'mylangfile@api',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+		//							'position'=>100,

+		//							'enabled'=>'$conf->api->enabled',  // Define condition to show or hide menu entry. Use '$conf->api->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+		//							'perms'=>'1',			                // Use 'perms'=>'$user->rights->api->level1->level2' if you want your menu with a permission rules

+		//							'target'=>'',

+		//							'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both

+		// $r++;

@@ -177 +193 @@
-		// $this->export_enabled[$r]='1';                               // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.

+        // $this->export_enabled[$r]='1';                               // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.

@@ -183 +199 @@
-		//	'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

+		//	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

@@ -191 +207 @@
-		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",

+		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",

@@ -209 +225 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -212,6 +228,8 @@
-	public function init($options = '')

-	{

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

+    public function init($options = '')

+    {

+        $sql = array();

+

+        $result = $this->_load_tables('/api/sql/');

+

+        return $this->_init($sql, $options);

+    }

@@ -231,2 +249,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_API'),		// API can't be enabled per environment. Why ?

-			"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('API_PRODUCTION_MODE')	// Not in production mode by default at activation

+			"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_API', 1),

+			"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('API_PRODUCTION_MODE', 1)

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modAsset.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modAsset.class.php
@@ -25 +25 @@
- *  \brief      Description and activation file for the module assets

+ *  \brief      Description and activation file for module Assets

@@ -61 +61 @@
-		$this->description = "Asset module";

+		$this->description = "Assets module";

@@ -63 +63 @@
-		$this->descriptionlong = "Asset module to manage assets module and depreciation charge on Dolibarr";

+		$this->descriptionlong = "Assets module to manage assets module and depreciation charge on Dolibarr";

@@ -72 +72 @@
-		$this->picto = 'asset';

+		$this->picto = 'accounting';

@@ -82,3 +82,3 @@
-		$this->dirs = array("/asset/temp");

-

-		// Config pages. Put here list of php page, stored into asset/admin directory, to use to setup module.

+		$this->dirs = array();

+

+		// Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module.

@@ -93 +93 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -106,12 +106,4 @@
-		$this->const[1] = array(

-			"ASSET_DEPRECIATION_DURATION_PER_YEAR",

-			"chaine",

-			"365",

-			"Duration per year to calculate depreciation. In some case, can be 360 days",

-			0,

-			'current',

-			1

-		);

-

-

-		if (!isset($conf->asset) || !isset($conf->asset->enabled)) {

+

+

+		if (!isset($conf->asset) || !isset($conf->asset->enabled))

+		{

@@ -126,2 +118,2 @@
-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/asset/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/asset/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/assets/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

+		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/assets/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

@@ -140 +132 @@
-		// 'order'            to add a tab in sales order view

+		// 'order'            to add a tab in customer order view

@@ -157 +149 @@
-		// Add here list of php file(s) stored in asset/core/boxes that contains class to show a widget.

+		// Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget.

@@ -177,5 +169,5 @@
-		$this->rights_class = 'asset';

-		$r = 0;

-

-		$r++;

-		$this->rights[$r][0] = 51001; // Permission id (must not be already used)

+        $this->rights_class = 'asset';

+        $r = 0;

+

+        $r++;

+        $this->rights[$r][0] = 51001; // Permission id (must not be already used)

@@ -183,2 +175,2 @@
-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)

@@ -191,2 +183,2 @@
-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)

@@ -199,2 +191,2 @@
-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+        $this->rights[$r][2] = 'd';

+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)

@@ -204,27 +196,11 @@
-		$r++;

-		$this->rights[$r][0] = 51004; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read asset models'; // Permission label

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'model_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

-

-		$r++;

-		$this->rights[$r][0] = 51005; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Create/Update asset models'; // Permission label

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'model_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

-		$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

-

-		$r++;

-		$this->rights[$r][0] = 51006; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Delete asset models'; // Permission label

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'model_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

-		$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

-

-		// Menus

-		//-------

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

+        $r++;

+        $this->rights[$r][0] = 51005; // Permission id (must not be already used)

+        $this->rights[$r][1] = 'Setup types of asset'; // Permission label

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+        $this->rights[$r][4] = 'setup_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

+        $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)

+

+        // Menus

+        //-------

+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.

@@ -241,14 +217,9 @@
-	public function init($options = '')

-	{

-		$result = $this->_load_tables('/install/mysql/', 'asset');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Permissions

-		$this->remove($options);

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

+    public function init($options = '')

+    {

+        // Permissions

+        $this->remove($options);

+

+        $sql = array();

+

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modBanque.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBanque.class.php
@@ -27 +27 @@
- *	\brief      Description and activation file for the module bank

+ *	\brief      Fichier de description et activation du module Banque

@@ -37,0 +38 @@
+

@@ -73 +74 @@
-		$this->langfiles = array("banks", "compta", "bills", "companies", "accounting");

+		$this->langfiles = array("banks", "compta", "bills", "companies");

@@ -153 +154 @@
-			'b.num_releve'=>'AccountStatement', 'b.rappro'=>'BankLineReconciled', 'b.datec'=>"DateCreation", "bu.url_id"=>"IdThirdParty",

+			'b.num_releve'=>'AccountStatement', 'b.rappro'=>'Conciliated', 'b.datec'=>"DateCreation", "bu.url_id"=>"IdThirdParty",

@@ -164 +165,2 @@
-		if (!isModEnabled('supplier_order') && !isModEnabled('supplier_invoice')) {

+		if (empty($conf->fournisseur->enabled) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || empty($conf->supplier_order->enabled) || empty($conf->supplier_invoice->enabled))

+		{

@@ -203,36 +204,0 @@
-

-		// Various Payment

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_'.$r;

-		$this->export_label[$r] = 'VariousPayment';

-		$this->export_permission[$r] = array(array("banque", "export"));

-		$this->export_fields_array[$r] = array(

-			'v.rowid'=>'VariousPaymentId', 'v.label'=>'VariousPaymentLabel', 'v.datev'=>'DateValue', 'v.datep'=>'DateOperation',

-			'v.num_payment'=>'ChequeOrTransferNumber', 'v.amount'=>'Amount', 'v.sens'=>'Sens',

-			'cp.id'=>"PaymentMode",

-			'v.accountancy_code'=>'AccountAccounting', 'v.subledger_account'=>'SubledgerAccount',

-			'v.note'=>'Note', 'v.datec'=>'DateCreation',

-			'p.ref'=>'ProjectRef', 'p.title'=>'ProjectLabel'

-		);

-		$this->export_TypeFields_array[$r] = array(

-			'v.rowid'=>'Text', 'v.label'=>'Text', 'v.datep'=>'Date', 'v.datev'=>'Date',

-			'v.num_payment'=>'Text', 'v.amount'=>'Numeric', 'v.sens'=>'Numeric',

-			'cp.id'=>'List:c_paiement:code:id:code',

-			"v.accountancy_code"=>"Text", "v.subledger_account"=>"Text",

-			"v.note"=>"Text", 'v.datec'=>"Date",

-			"p.ref"=>"Text", "p.title"=>"Text"

-		);

-		$this->export_entities_array[$r] = array(

-			'v.rowid'=>'payment', 'v.label'=>'payment', 'v.datev'=>'payment', 'v.datep'=>'payment',

-			'v.num_payment'=>'payment', 'v.amount'=>'payment', 'v.sens'=>'payment',

-			'cp.id'=>'payment',

-			'v.accountancy_code'=>'payment', 'v.subledger_account'=>"payment",

-			'v.note'=>"payment", 'v.datec'=>"payment",

-			"p.ref"=>"project", "p.title"=>"project"

-		);

-		$this->export_sql_start[$r] = 'SELECT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'payment_various as v';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet as p ON v.fk_projet = p.rowid";

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_paiement as cp ON v.fk_typepayment = cp.id";

-		$this->export_sql_end[$r] .= ' WHERE v.entity IN ('.getEntity('payment_various').')';

-		$this->export_sql_order[$r] = ' ORDER BY v.datep';

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modBarcode.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBarcode.class.php
@@ -25,2 +25,2 @@
- *	\ingroup    barcode, product

- *	\brief      Description and activation file for the module barcode

+ *	\ingroup    barcode,produit

+ *	\brief      Fichier de description et activation du module Barcode

@@ -35,0 +36 @@
+

@@ -80 +80,0 @@
-		$r = 0;

@@ -82,5 +82,26 @@
-		$this->rights[$r][0] = 301; // id de la permission

-		$this->rights[$r][1] = 'Generate PDF sheets of barcodes'; // libelle de la permission

-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'read';

+		$this->rights[1][0] = 300; // id de la permission

+		$this->rights[1][1] = 'Read barcodes'; // libelle de la permission

+		$this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)

+		$this->rights[1][3] = 1; // La permission est-elle une permission par defaut

+		$this->rights[1][4] = 'lire_advance';

+

+		$this->rights[2][0] = 301; // id de la permission

+		$this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission

+		$this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)

+		$this->rights[2][3] = 0; // La permission est-elle une permission par defaut

+		$this->rights[2][4] = 'creer_advance';

+

+        // Main menu entries

+        $r = 0;

+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+						        'mainmenu'=>'tools',

+        						'leftmenu'=>'barcodeprint',

+        						'type'=>'left', // This is a Left menu entry

+						        'titre'=>'BarCodePrintsheet',

+						        'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',

+						        'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+						        'position'=>200,

+						        'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+						        'target'=>'',

+						        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

@@ -89,48 +110,10 @@
-		$this->rights[$r][0] = 304; // id de la permission

-		$this->rights[$r][1] = 'Read barcodes'; // libelle de la permission

-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'lire_advance';

-		$r++;

-

-		$this->rights[$r][0] = 305; // id de la permission

-		$this->rights[$r][1] = 'Create/modify barcodes'; // libelle de la permission

-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'creer_advance';

-		$r++;

-

-		// Main menu entries

-		$r = 0;

-

-		// A menu entry for the Tools top menu

-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'mainmenu'=>'tools',

-			'leftmenu'=>'barcodeprint',

-			'type'=>'left', // This is a Left menu entry

-			'titre'=>'BarCodePrintsheet',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

-			'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',

-			'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>200,

-			'enabled'=>'isModEnabled("barcode")', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'$user->hasRight("barcode", "read")',

-			'target'=>'',

-			'user'=>0, // 0=Menu for internal users, 1=external users, 2=both

-		);

-		$r++;

-

-		// A menu entry for the left menu

-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'type'=>'left', // This is a Left menu entry

-			'titre'=>'MassBarcodeInit',

-			'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',

-			'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>300,

-			'enabled'=>'isModEnabled("barcode") && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'$user->admin',

-			'target'=>'',

-			'user'=>0, // 0=Menu for internal users, 1=external users, 2=both

-		);

+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+								'type'=>'left', // This is a Left menu entry

+								'titre'=>'MassBarcodeInit',

+								'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',

+								'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+								'position'=>300,

+								'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+								'target'=>'',

+								'user'=>0); // 0=Menu for internal users, 1=external users, 2=both

@@ -141,6 +124,6 @@
-	/**

-	 *      Function called when module is enabled.

-	 *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *      It also creates data directories.

-	 *

-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+    /**

+     *      Function called when module is enabled.

+     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *      It also creates data directories.

+     *

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -155,8 +138,8 @@
-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),

-			array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)", 'ignoreerror'=>1)

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),

+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)", 'ignoreerror'=>1)

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modBlockedLog.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBlockedLog.class.php
@@ -23 +23 @@
- *  \brief      Description and activation file for the module BlockedLog

+ *  \brief      Description and activation file for module BlockedLog

@@ -32,213 +32,217 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf, $mysoc;

-

-		$this->db = $db;

-		$this->numero = 3200;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'blockedlog';

-

-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "base";

-		// Module position in the family on 2 digits ('01', '10', '20', ...)

-		$this->module_position = '76';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries.";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'technic';

-

-		// Data directories to create when module is enabled

-		$this->dirs = array();

-

-		// Config pages

-		//-------------

-		$this->config_page_url = array('blockedlog.php?withtab=1@blockedlog');

-

-		// Dependancies

-		//-------------

-		$this->hidden = false; // A condition to disable module

-		$this->depends = array('always'=>'modFacture'); // 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(); // List of modules id this module is in conflict with

-		$this->langfiles = array('blockedlog');

-

-		$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		$this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation');

-

-		// Currently, activation is not automatic because only companies (in France) making invoices to non business customers must

-		// enable this module.

-		/*if (!empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))

-		{

-			$tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);

-			$this->automatic_activation = array();

-			foreach($tmp as $key)

-			{

-				$this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation';

-			}

-		}*/

-		//var_dump($this->automatic_activation);

-

-		$this->always_enabled = (!empty($conf->blockedlog->enabled)

-			&& getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY')

-			&& in_array((empty($mysoc->country_code) ? '' : $mysoc->country_code), explode(',', getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY')))

-			&& $this->alreadyUsed());

-

-		// Constants

-		//-----------

-		$this->const = array(

-			1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0)

-		);

-

-		// New pages on tabs

-		// -----------------

-		$this->tabs = array();

-

-		// Boxes

-		//------

-		$this->boxes = array();

-

-		// Permissions

-		// -----------------

-		$this->rights = array(); // Permission array used by this module

-

-		$r = 1;

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)

-		$this->rights[$r][5] = '';

-

-		// Main menu entries

-		// -----------------

-		$r = 0;

-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'mainmenu'=>'tools',

-			'leftmenu'=>'blockedlogbrowser',

-			'type'=>'left', // This is a Left menu entry

-			'titre'=>'BrowseBlockedLog',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

-			'url'=>'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser',

-			'langs'=>'blockedlog', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>200,

-			'enabled'=>'$conf->blockedlog->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'$user->rights->blockedlog->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-			'target'=>'',

-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both

-		);

-		$r++;

-	}

-

-

-	/**

-	 * Check if module was already used before unactivation linked to warnings_unactivation property

-	 *

-	 * @return	boolean		True if already used, otherwise False

-	 */

-	public function alreadyUsed()

-	{

-		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';

-		$b = new BlockedLog($this->db);

-		return $b->alreadyUsed(1);

-	}

-

-

-	/**

-	 *      Function called when module is enabled.

-	 *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *      It also creates data directories.

-	 *

-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *      @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf, $user;

-

-		$sql = array();

-

-		// If already used, we add an entry to show we enable module

-		require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php';

-

-		$object = new stdClass();

-		$object->id = 1;

-		$object->element = 'module';

-		$object->ref = 'systemevent';

-		$object->entity = $conf->entity;

-		$object->date = dol_now();

-

-		$b = new BlockedLog($this->db);

-		$result = $b->setObjectData($object, 'MODULE_SET', 0);

-		if ($result < 0) {

-			$this->error = $b->error;

-			$this->errors = $b->errors;

-			return 0;

-		}

-

-		$res = $b->create($user);

-		if ($res <= 0) {

-			$this->error = $b->error;

-			$this->errors = $b->errors;

-			return $res;

-		}

-

-		return $this->_init($sql, $options);

-	}

-

-	/**

-	 * Function called when module is disabled.

-	 * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.

-	 * Data directories are not deleted

-	 *

-	 * @param      string	$options    Options when enabling module ('', 'noboxes')

-	 * @return     int             		1 if OK, 0 if KO

-	 */

-	public function remove($options = '')

-	{

-		global $conf, $user;

-

-		$sql = array();

-

-		// If already used, we add an entry to show we enable module

-		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';

-

-		$object = new stdClass();

-		$object->id = 1;

-		$object->element = 'module';

-		$object->ref = 'systemevent';

-		$object->entity = $conf->entity;

-		$object->date = dol_now();

-

-		$b = new BlockedLog($this->db);

-		$result = $b->setObjectData($object, 'MODULE_RESET', 0);

-		if ($result < 0) {

-			$this->error = $b->error;

-			$this->errors = $b->errors;

-			return 0;

-		}

-

-		if ($b->alreadyUsed(1)) {

-			$res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error

-		} else {

-			$res = $b->create($user);

-		}

-		if ($res <= 0) {

-			$this->error = $b->error;

-			$this->errors = $b->errors;

-			return $res;

-		}

-

-		return $this->_remove($sql, $options);

-	}

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        global $langs, $conf, $mysoc;

+

+        $this->db = $db;

+        $this->numero = 3200;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'blockedlog';

+

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "base";

+        // Module position in the family on 2 digits ('01', '10', '20', ...)

+        $this->module_position = '75';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries.";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'technic';

+

+        // Data directories to create when module is enabled

+        $this->dirs = array();

+

+        // Config pages

+        //-------------

+        $this->config_page_url = array('blockedlog.php?withtab=1@blockedlog');

+

+        // Dependancies

+        //-------------

+        $this->hidden = false; // A condition to disable module

+        $this->depends = array('always'=>'modFacture'); // 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(); // List of modules id this module is in conflict with

+        $this->langfiles = array('blockedlog');

+

+        $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation');

+

+        // Currently, activation is not automatic because only companies (in France) making invoices to non business customers must

+        // enable this module.

+        /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))

+        {

+            $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);

+            $this->automatic_activation = array();

+            foreach($tmp as $key)

+            {

+                $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation';

+            }

+        }*/

+        //var_dump($this->automatic_activation);

+

+        $this->always_enabled = (!empty($conf->blockedlog->enabled)

+            && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)

+            && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))

+            && $this->alreadyUsed());

+

+        // Constants

+        //-----------

+        $this->const = array(

+            1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0)

+        );

+

+        // New pages on tabs

+        // -----------------

+        $this->tabs = array();

+

+        // Boxes

+        //------

+        $this->boxes = array();

+

+        // Permissions

+        // -----------------

+        $this->rights = array(); // Permission array used by this module

+

+        $r = 0;

+        $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

+        $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label

+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+        $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)

+        $this->rights[$r][5] = '';

+

+        // Main menu entries

+        // -----------------

+        $r = 0;

+        $this->menu[$r] = array(

+        'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+        'mainmenu'=>'tools',

+        'leftmenu'=>'blockedlogbrowser',

+        'type'=>'left', // This is a Left menu entry

+        'titre'=>'BrowseBlockedLog',

+        'url'=>'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser',

+        'langs'=>'blockedlog', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        'position'=>200,

+        'enabled'=>'$conf->blockedlog->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+        'perms'=>'$user->rights->blockedlog->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        'target'=>'',

+        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

+        $r++;

+    }

+

+

+    /**

+     * Check if module was already used before unactivation linked to warnings_unactivation property

+     *

+     * @return	boolean		True if already used, otherwise False

+     */

+    public function alreadyUsed()

+    {

+        require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';

+        $b = new BlockedLog($this->db);

+        return $b->alreadyUsed(1);

+    }

+

+

+    /**

+     *      Function called when module is enabled.

+     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *      It also creates data directories.

+     *

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf, $user;

+

+        $sql = array();

+

+        // If already used, we add an entry to show we enable module

+           require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';

+

+           $object = new stdClass();

+        $object->id = 1;

+        $object->element = 'module';

+        $object->ref = 'systemevent';

+        $object->entity = $conf->entity;

+        $object->date = dol_now();

+

+        $b = new BlockedLog($this->db);

+        $result = $b->setObjectData($object, 'MODULE_SET', 0);

+        if ($result < 0)

+        {

+            $this->error = $b->error;

+            $this->errors = $b->erros;

+            return 0;

+        }

+

+        $res = $b->create($user);

+        if ($res <= 0) {

+            $this->error = $b->error;

+            $this->errors = $b->errors;

+            return $res;

+        }

+

+        return $this->_init($sql, $options);

+    }

+

+    /**

+     * Function called when module is disabled.

+     * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.

+     * Data directories are not deleted

+     *

+     * @param      string	$options    Options when enabling module ('', 'noboxes')

+     * @return     int             		1 if OK, 0 if KO

+     */

+    public function remove($options = '')

+    {

+

+        global $conf, $user;

+

+        $sql = array();

+

+        // If already used, we add an entry to show we enable module

+        require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';

+

+        $object = new stdClass();

+        $object->id = 1;

+        $object->element = 'module';

+        $object->ref = 'systemevent';

+        $object->entity = $conf->entity;

+        $object->date = dol_now();

+

+        $b = new BlockedLog($this->db);

+        $result = $b->setObjectData($object, 'MODULE_RESET', 0);

+        if ($result < 0)

+        {

+            $this->error = $b->error;

+            $this->errors = $b->erros;

+            return 0;

+        }

+

+        if ($b->alreadyUsed(1))

+        {

+            $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error

+        }

+        else

+        {

+            $res = $b->create($user);

+        }

+        if ($res <= 0) {

+            $this->error = $b->error;

+            $this->errors = $b->errors;

+            return $res;

+        }

+

+        return $this->_remove($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modBom.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBom.class.php
@@ -5 +4,0 @@
- * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>

@@ -27 +26 @@
- *  \brief      Description and activation file for the module Bom

+ *  \brief      Description and activation file for module Bom

@@ -58 +57 @@
-		$this->module_position = '65';

+		$this->module_position = '60';

@@ -84 +83 @@
-			'triggers' => 1,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)

+		    'triggers' => 1,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)

@@ -89 +88 @@
-			'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)

+		    'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)

@@ -92,2 +91,2 @@
-			'css' => array('/bom/css/bom.css.php'),				// Set this to relative path of css file if module has its own css file

-			 'js' => array('/bom/js/bom.js.php'),				// Set this to relative path of js file if module must load a js on all pages

+			'css' => array('/bom/css/bom.css.php'),	// Set this to relative path of css file if module has its own css file

+	 		'js' => array('/bom/js/bom.js.php'),          // Set this to relative path of js file if module must load a js on all pages

@@ -96 +95 @@
-			*/

+		    */

@@ -108,4 +107,3 @@
-		// List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))

-		$this->depends = array('modProduct');

-		$this->requiredby = array('modMrp');

-		$this->conflictwith = array();

+		$this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)

+		$this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)

+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

@@ -113 +111 @@
-		//$this->phpmin = array(7, 0));					// Minimum version of PHP required by module

+		//$this->phpmin = array(5,4);					// Minimum version of PHP required by module

@@ -137 +135,2 @@
-		if (!isset($conf->bom) || !isset($conf->bom->enabled)) {

+		if (!isset($conf->bom) || !isset($conf->bom->enabled))

+		{

@@ -160 +159 @@
-		// 'order'            to add a tab in sales order view

+		// 'order'            to add a tab in customer order view

@@ -173,0 +173,14 @@
+		/* Example:

+        $this->dictionaries=array(

+            'langs'=>'mylangfile@bom',

+            'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),		// List of tables we want to see into dictonnary editor

+            'tablib'=>array("Table1","Table2","Table3"),													// Label of tables

+            'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),	// Request to select fields

+            'tabsqlsort'=>array("label ASC","label ASC","label ASC"),																					// Sort order

+            'tabfield'=>array("code,label","code,label","code,label"),																					// List of fields (result of select to show dictionary)

+            'tabfieldvalue'=>array("code,label","code,label","code,label"),																				// List of fields (list of fields to edit a record)

+            'tabfieldinsert'=>array("code,label","code,label","code,label"),																			// List of fields (list of fields for insert)

+            'tabrowid'=>array("rowid","rowid","rowid"),																									// Name of columns with primary key (try to always name it 'rowid')

+            'tabcond'=>array($conf->bom->enabled,$conf->bom->enabled,$conf->bom->enabled)												// Condition to show each dictionary

+        );

+        */

@@ -196 +209 @@
-		$r = 1;

+		$r = 0;

@@ -237 +250 @@
-		*/

+        */

@@ -277 +289,0 @@
-		$this->export_permission[$r] = array(array("bom", "read"));

@@ -279,3 +291 @@
-		$keyforclass = 'BOM';

-		$keyforclassfile = '/bom/class/bom.class.php';

-		$keyforelement = 'bom';

+		$keyforclass = 'BOM'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bom';

@@ -283,4 +293 @@
-		$keyforclass = 'BOMLine';

-		$keyforclassfile = '/bom/class/bom.class.php';

-		$keyforelement = 'bomline';

-		$keyforalias = 'tl';

+		$keyforclass = 'BOMLine'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bomline'; $keyforalias = 'tl';

@@ -289,3 +296 @@
-		$keyforselect = 'bom_bom';

-		$keyforaliasextra = 'extra';

-		$keyforelement = 'bom';

+		$keyforselect = 'bom_bom'; $keyforaliasextra = 'extra'; $keyforelement = 'bom';

@@ -293,3 +298 @@
-		$keyforselect = 'bom_bomline';

-		$keyforaliasextra = 'extraline';

-		$keyforelement = 'bomline';

+		$keyforselect = 'bom_bomline'; $keyforaliasextra = 'extraline'; $keyforelement = 'bomline';

@@ -300 +302,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)';

@@ -306,137 +307,0 @@
-

-		// Imports

-		//--------

-		$r = 0;

-		//Import BOM Header

-

-		$r++;

-		$this->import_code[$r] = 'bom_'.$r;

-		$this->import_label[$r] = 'BillOfMaterials';

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array();

-		$this->import_tables_array[$r] = array('b' => MAIN_DB_PREFIX.'bom_bom', 'extra' => MAIN_DB_PREFIX.'bom_bom_extrafields');

-		$this->import_tables_creator_array[$r] = array('b' => 'fk_user_creat'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'b.ref'               => 'Ref*',

-			'b.label'             => 'Label*',

-			'b.fk_product'        => 'ProductRef*',

-			'b.description'       => 'Description',

-			'b.note_public'       => 'Note',

-			'b.note_private'      => 'NotePrivate',

-			'b.fk_warehouse'      => 'WarehouseRef',

-			'b.qty'               => 'Qty',

-			'b.efficiency'        => 'Efficiency',

-			'b.duration'          => 'Duration',

-			'b.date_creation'     => 'DateCreation',

-			'b.date_valid'        => 'DateValid',

-			'b.fk_user_modif'     => 'ModifiedById',

-			'b.fk_user_valid'     => 'ValidatedById',

-			'b.model_pdf'         => 'Model',

-			'b.status'         	  => 'Status*',

-			'b.bomtype'       	  => 'Type*'

-		);

-		$import_sample = array();

-

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bom');

-		$this->import_regex_array[$r] = array(

-			'b.ref' => ''

-		);

-

-		$this->import_updatekeys_array[$r] = array('b.ref' => 'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'b.fk_product' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/product/class/product.class.php',

-				'class'   => 'Product',

-				'method'  => 'fetch',

-				'element' => 'Product'

-			),

-			'b.fk_warehouse' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/product/stock/class/entrepot.class.php',

-				'class'   => 'Entrepot',

-				'method'  => 'fetch',

-				'element' => 'Warehouse'

-			),

-			'b.fk_user_valid' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/user/class/user.class.php',

-				'class'   => 'User',

-				'method'  => 'fetch',

-				'element' => 'user'

-			),

-			'b.fk_user_modif' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/user/class/user.class.php',

-				'class'   => 'User',

-				'method'  => 'fetch',

-				'element' => 'user'

-			),

-		);

-

-		//Import BOM Lines

-		$r++;

-		$this->import_code[$r] = 'bom_lines_'.$r;

-		$this->import_label[$r] = 'BillOfMaterialsLines';

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array();

-		$this->import_tables_array[$r] = array('bd' => MAIN_DB_PREFIX.'bom_bomline', 'extra' => MAIN_DB_PREFIX.'bom_bomline_extrafields');

-		$this->import_fields_array[$r] = array(

-			'bd.fk_bom'         => 'BOM*',

-			'bd.fk_product'     => 'ProductRef',

-			'bd.fk_bom_child'   => 'BOMChild',

-			'bd.description'    => 'Description',

-			'bd.qty'            => 'LineQty',

-			'bd.qty_frozen'     => 'LineIsFrozen',

-			'bd.disable_stock_change' => 'Disable Stock Change',

-			'bd.efficiency'     => 'Efficiency',

-			'bd.position'       => 'LinePosition'

-		);

-

-		// Add extra fields

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-			}

-		}

-		// End add extra fields

-

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bomline');

-		$this->import_regex_array[$r] = array();

-		$this->import_updatekeys_array[$r] = array('bd.fk_bom' => 'BOM Id', 'bd.fk_product' => 'ProductRef');

-		$this->import_convertvalue_array[$r] = array(

-			'bd.fk_bom' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/bom/class/bom.class.php',

-				'class'   => 'BOM',

-				'method'  => 'fetch',

-				'element' => 'bom'

-			),

-			'bd.fk_product' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/product/class/product.class.php',

-				'class'   => 'Product',

-				'method'  => 'fetch',

-				'element' => 'Product'

-			),

-		);

@@ -456,0 +322,3 @@
+		$result = $this->_load_tables('/bom/sql/');

+		if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')

+

@@ -477 +345,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -481 +350,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -489,2 +359,2 @@
-			//"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".((int) $conf->entity),

-			//"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".((int) $conf->entity).")"

+			//"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity,

+			//"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")"

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modBookmark.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modBookmark.class.php
@@ -24 +24 @@
- *	\brief      Description and activation file for the module Bookmarks

+ *	\brief      Fichier de description et activation du module Bookmarks

@@ -34,0 +35 @@
+

@@ -71,3 +72 @@
-		$this->boxes = array(

-			0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home')

-		);

+		$this->boxes = array(0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home'));

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modCashDesk.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCashDesk.class.php
@@ -0,0 +1,144 @@
+<?php

+/* Copyright (C) 2008-2011 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

+ * 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 <https://www.gnu.org/licenses/>.

+ */

+

+/**

+ *      \defgroup   pos       Module points of sale

+ *      \brief      Module to manage points of sale

+ *      \file       htdocs/core/modules/modCashDesk.class.php

+ *      \ingroup    pos

+ *      \brief      File to enable/disable module Point Of Sales

+ */

+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';

+

+

+/**

+ *	Class to describe and enable module Point Of Sales

+ */

+class modCashDesk extends DolibarrModules

+{

+	/**

+	 *   Constructor. Define names, constants, directories, boxes, permissions

+	 *

+	 *   @param      DoliDB		$db      Database handler

+	 */

+	public function __construct($db)

+	{

+		$this->db = $db;

+

+		// Id for module (must be unique).

+		// Use here a free id (See in Home -> System information -> Dolibarr for list of used module id).

+		$this->numero = 50100;

+		// Key text used to identify module (for permission, menus, etc...)

+		$this->rights_class = 'cashdesk';

+

+		$this->family = "portal";

+		$this->module_position = '55';

+		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+		$this->name = preg_replace('/^mod/i', '', get_class($this));

+		$this->description = "CashDesk module";

+

+		$this->revision = '1.27';

+		$this->version = 'dolibarr';

+

+		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+		$this->picto = 'cash-register';

+

+		// Data directories to create when module is enabled

+		$this->dirs = array();

+

+		// Config pages. Put here list of php page names stored in admmin directory used to setup module.

+		$this->config_page_url = array("cashdesk.php@cashdesk");

+

+		// Dependencies

+		$this->hidden = false; // A condition to hide module

+		$this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // 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->phpmin = array(5, 4); // Minimum version of PHP required by module

+		$this->need_dolibarr_version = array(2, 4); // Minimum version of Dolibarr required by module

+		$this->langfiles = array("cashdesk");

+		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')

+		//$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw');  // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')

+

+		// Constants

+		$this->const = array();

+

+		// Boxes

+		$this->boxes = array();

+

+		// Permissions

+		$this->rights = array();

+		$r = 0;

+

+		$r++;

+		$this->rights[$r][0] = 50101;

+		$this->rights[$r][1] = 'Use Point of sale';

+		$this->rights[$r][2] = 'a';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'run';

+

+		// Main menu entries

+		$this->menus = array(); // List of menus to add

+		$r = 0;

+

+		// This is to declare the Top Menu entry:

+		$this->menu[$r] = array('fk_menu'=>0, // Put 0 if this is a top menu

+									'type'=>'top', // This is a Top menu entry

+									'titre'=>'PointOfSaleShort',

+									'mainmenu'=>'cashdesk',

+									'url'=>'/cashdesk/index.php?user=__USER_LOGIN__',

+									'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+									'position'=>900,

+                                    'enabled'=>'$conf->cashdesk->enabled',

+		                            'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules

+									'target'=>'pointofsale',

+									'user'=>0); // 0=Menu for internal users, 1=external users, 2=both

+

+		$r++;

+

+		// This is to declare a Left Menu entry:

+		// $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the top menu entry

+		//							'type'=>'left',			// This is a Left menu entry

+		//							'titre'=>'Title left menu',

+		//							'mainmenu'=>'mymodule',

+		//							'url'=>'/comm/action/index2.php',

+		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+		//							'position'=>100,

+		//							'perms'=>'$user->rights->mymodule->level1->level2',		// Use 'perms'=>'1' if you want your menu with no permission rules

+		//							'target'=>'',

+		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+		// $r++;

+    }

+

+

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        $sql = array();

+

+        // Remove permissions and default values

+        $this->remove($options);

+

+        return $this->_init($sql, $options);

+    }

+}

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modCategorie.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCategorie.class.php
@@ -5 +4,0 @@
- * Copyright (C) 2020      Stéphane Lesage		<stephane.lesage@ateis.com>

@@ -26 +25 @@
- *      \brief      Description and activation file for the module Category

+ *      \brief      Fichier de description et activation du module Categorie

@@ -29 +27,0 @@
-include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';

@@ -44 +42 @@
-		global $conf;

+	    global $conf;

@@ -50 +48 @@
-		$this->module_position = '25';

+		$this->module_position = '20';

@@ -69 +67 @@
-		$this->langfiles = array("products", "companies", "categories", "members", "stocks", "website");

+		$this->langfiles = array("products", "companies", "categories", "members");

@@ -121,85 +119,2 @@
-		// All Categories List

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_list';

-		$this->export_label[$r] = 'CatListAll';

-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'true';

-		$this->export_permission[$r] = array(array("categorie", "lire"));

-

-		$typeexample = "";

-		if (isModEnabled("product") || isModEnabled("service")) {

-			$typeexample .= ($typeexample ? " / " : "")."0=Product-Service";

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$typeexample .= ($typeexample ? "/" : "")."1=Supplier";

-		}

-		if (isModEnabled("societe")) {

-			$typeexample .= ($typeexample ? " / " : "")."2=Customer-Prospect";

-		}

-		if (isModEnabled('adherent')) {

-			$typeexample .= ($typeexample ? " / " : "")."3=Member";

-		}

-		if (isModEnabled("societe")) {

-			$typeexample .= ($typeexample ? " / " : "")."4=Contact";

-		}

-		if (isModEnabled('bank')) {

-			$typeexample .= ($typeexample ? " / " : "")."5=Bank account";

-		}

-		if (isModEnabled('project')) {

-			$typeexample .= ($typeexample ? " / " : "")."6=Project";

-		}

-		if (isModEnabled('user')) {

-			$typeexample .= ($typeexample ? " / " : "")."7=User";

-		}

-		if (isModEnabled('bank')) {

-			$typeexample .= ($typeexample ? " / " : "")."8=Bank line";

-		}

-		if (isModEnabled('stock')) {

-			$typeexample .= ($typeexample ? " / " : "")."9=Warehouse";

-		}

-		if (isModEnabled('agenda')) {

-			$typeexample .= ($typeexample ? " / " : "")."10=Agenda event";

-		}

-		if (isModEnabled('website')) {

-			$typeexample .= ($typeexample ? " / " : "")."11=Website page";

-		}

-

-		// Definition of vars

-		$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification");

-		$this->export_TypeFields_array[$r] = array('cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.type'=>"Numeric", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text');

-		$this->export_entities_array[$r] = array(); // We define here only fields that use another picto

-		$this->export_help_array[$r] = array('cat.type'=>$typeexample);

-

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-

-		// 0 Products

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0];

-		$this->export_label[$r] = 'CatProdList';

-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'isModEnabled("product") || isModEnabled("service")';

-		$this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "export"));

-		$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref', 'p.label'=>'Label');

-		$this->export_TypeFields_array[$r] = array('cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.label'=>'Text');

-		$this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'); // We define here only fields that use another picto

-

-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = cp.fk_product';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 0';

-

-		// 1 Suppliers

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1];

+		$r++;

+		$this->export_code[$r] = 'category_'.$r;

@@ -207,2 +122,2 @@
-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'isModEnabled("supplier_order") || isModEnabled("supplier_invoice")';

+		$this->export_icon[$r] = 'category';

+		$this->export_enabled[$r] = '!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)';

@@ -211,7 +126,5 @@
-			'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel",

-			'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification",

-			's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_fournisseur'=>"SupplierCode",

-			's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode",

-			's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",

-			's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic",

-			't.libelle'=>'ThirdPartyType'

+			'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix",

+			's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address",

+			's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",

+			's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital",

+			's.note_public'=>"NotePublic"

@@ -220,6 +133,4 @@
-			'cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text',

-			's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.fournisseur'=>"Text", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_fournisseur'=>"Text",

-			's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",

-			's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",

-			's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text",

-			't.libelle'=>'List:c_typent:libelle:code'

+			'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date",

+			's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",

+			's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text",

+			's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text"

@@ -228,5 +139,4 @@
-			's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.fournisseur'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_fournisseur'=>"company",

-			's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",

-			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company",

-			's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company",

-			't.libelle'=>'company'

+			's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company",

+			's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",

+			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company",

+			's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company"

@@ -234,6 +143,0 @@
-

-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

@@ -241,13 +145,9 @@
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_fournisseur as cf ON cf.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = cf.fk_soc';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 1';

-

-		// 2 Customers/Prospects

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2];

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';

+		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, ';

+		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';

+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';

+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';

+		$this->export_sql_end[$r] .= ' AND u.type = 1'; // Supplier categories

+

+		$r++;

+		$this->export_code[$r] = 'category_'.$r;

@@ -255,3 +155,3 @@
-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'isModEnabled("societe")';

-		$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export"));

+		$this->export_icon[$r] = 'category';

+        $this->export_enabled[$r] = '$conf->societe->enabled';

+		$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire"));

@@ -259,7 +159,5 @@
-			'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel",

-			'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification",

-			's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode",

-			's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode",

-			's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",

-			's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic",

-			't.libelle'=>'ThirdPartyType', 'pl.code'=>'ProspectLevel', 'st.code'=>'ProspectStatus'

+			'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix",

+			's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address",

+			's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",

+			's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital",

+			's.note_public'=>"NotePublic", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus'

@@ -268,6 +166,5 @@
-			'cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text',

-			's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text",

-			's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",

-			's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",

-			's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text",

-			't.libelle'=>'List:c_typent:libelle:code', 'pl.code'=>'List:c_prospectlevel:label:code', 'st.code'=>'List:c_stcomm:libelle:code'

+			'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text",

+			's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label",

+			'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text",

+			's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',

+			's.fk_stcomm'=>'List:c_stcomm:libelle:code'

@@ -276,5 +173,5 @@
-			's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_client'=>"company",

-			's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",

-			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company",

-			's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company",

-			't.libelle'=>'company', 'pl.code'=>'company', 'st.code'=>'company'

+			's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company",

+			's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",

+			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company",

+			's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company',

+			's.fk_stcomm'=>'company'

@@ -282,6 +178,0 @@
-

-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

@@ -289,15 +180,66 @@
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = cs.fk_soc';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_prospectlevel as pl ON s.fk_prospectlevel = pl.code';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 2';

-

-		// 3 Members

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3];

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';

+		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';

+		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object ';

+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';

+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';

+		$this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories

+

+        // Add extra fields

+        $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";

+        $resql = $this->db->query($sql);

+        if ($resql)    // This can fail when class is used on old database (during migration for example)

+        {

+            while ($obj = $this->db->fetch_object($resql))

+            {

+                $fieldname = 'extra.'.$obj->name;

+                $fieldlabel = ucfirst($obj->label);

+                $typeFilter = "Text";

+                switch ($obj->type)

+                {

+                    case 'int':

+                    case 'double':

+                    case 'price':

+                        $typeFilter = "Numeric";

+                        break;

+                    case 'date':

+                    case 'datetime':

+                        $typeFilter = "Date";

+                        break;

+                    case 'boolean':

+                        $typeFilter = "Boolean";

+                        break;

+                    case 'sellist':

+                        $typeFilter = "List:".$obj->param;

+                        break;

+                    case 'select':

+                        $typeFilter = "Select:".$obj->param;

+                        break;

+                }

+                $this->export_fields_array[$r][$fieldname] = $fieldlabel;

+                $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+                $this->export_entities_array[$r][$fieldname] = 'company';

+            }

+        }

+        // End add axtra fields

+

+

+

+

+

+		$r++;

+		$this->export_code[$r] = 'category_'.$r;

+		$this->export_label[$r] = 'CatProdList';

+		$this->export_icon[$r] = 'category';

+        $this->export_enabled[$r] = '$conf->product->enabled || $conf->service->enabled';

+		$this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "lire"));

+		$this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref');

+		$this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.ref'=>'Text');

+		$this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product'); // We define here only fields that use another picto

+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';

+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid';

+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';

+		$this->export_sql_end[$r] .= ' AND u.type = 0'; // Supplier categories

+

+		$r++;

+		$this->export_code[$r] = 'category_'.$r;

@@ -305,5 +247,5 @@
-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'isModEnabled("adherent")';

-		$this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "export"));

-		$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname');

-		$this->export_TypeFields_array[$r] = array('cat.rowid'=>"Numeric", 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text');

+		$this->export_icon[$r] = 'category';

+        $this->export_enabled[$r] = '$conf->adherent->enabled';

+		$this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "lire"));

+		$this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname');

+		$this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.lastname'=>'Text', 'p.firstname'=>'Text');

@@ -311,6 +252,0 @@
-

-		$keyforselect = 'adherent';

-		$keyforelement = 'member';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

@@ -318,11 +254,7 @@
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_member as cm ON cm.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'adherent as p ON p.rowid = cm.fk_member';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON cat.rowid = extra.fk_object ';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 3';

-

-		// 4 Contacts

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4];

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p';

+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';

+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';

+		$this->export_sql_end[$r] .= ' AND u.type = 3'; // Member categories

+

+		$r++;

+		$this->export_code[$r] = 'category_'.$r;

@@ -330,3 +262,3 @@
-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'isModEnabled("societe")';

-		$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export"));

+		$this->export_icon[$r] = 'category';

+		$this->export_enabled[$r] = '$conf->societe->enabled';

+		$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire"));

@@ -334,10 +266,33 @@
-			'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel",

-			'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification",

-			'p.rowid' => 'ContactId', 'civ.label' => 'UserTitle', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname',

-			'p.address' => 'Address', 'p.zip' => 'Zip', 'p.town' => 'Town', 'c.code' => 'CountryCode', 'c.label' => 'Country',

-			'p.birthday' => 'DateOfBirth', 'p.poste' => 'PostOrFunction',

-			'p.phone' => 'Phone', 'p.phone_perso' => 'PhonePerso', 'p.phone_mobile' => 'PhoneMobile', 'p.fax' => 'Fax', 'p.email' => 'Email',

-			'p.note_private' => 'NotePrivate', 'p.note_public' => 'NotePublic', 'p.statut' => 'Status',

-			's.nom'=>"Name", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.status'=>"Status",

-			's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town",

-			's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email"

+			'u.rowid' => "CategId",

+			'u.label' => "Label",

+			'u.description' => "Description",

+			'p.rowid' => 'ContactId',

+			'p.civility' => 'UserTitle',

+			'p.lastname' => 'LastName',

+			'p.firstname' => 'Firstname',

+			'p.address' => 'Address',

+			'p.zip' => 'Zip',

+			'p.town' => 'Town',

+			'country.code' => 'CountryCode',

+			'country.label' => 'Country',

+			'p.birthday' => 'DateToBirth',

+			'p.poste' => 'PostOrFunction',

+			'p.phone' => 'Phone',

+			'p.phone_perso' => 'PhonePerso',

+			'p.phone_mobile' => 'PhoneMobile',

+			'p.fax' => 'Fax',

+			'p.email' => 'Email',

+			'p.note_private' => 'NotePrivate',

+			'p.note_public' => 'NotePublic',

+            'p.statut' => 'Status',

+			's.nom'=>"Name",

+			's.client'=>"Customer",

+			's.fournisseur'=>"Supplier",

+			's.status'=>"Status",

+			's.address'=>"Address",

+			's.zip'=>"Zip",

+			's.town'=>"Town",

+			's.phone'=>"Phone",

+			's.fax'=>"Fax",

+			's.url'=>"Url",

+			's.email'=>"Email"

@@ -346,9 +301,14 @@
-			'cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text',

-			'civ.label' => 'List:c_civility:label:label', 'p.rowid'=>'Numeric', 'p.lastname' => 'Text', 'p.firstname' => 'Text',

-			'p.address' => 'Text', 'p.zip' => 'Text', 'p.town' => 'Text', 'c.code' => 'Text', 'c.label' => 'List:c_country:label:label',

-			'p.birthday' => 'Date', 'p.poste' => 'Text',

-			'p.phone' => 'Text', 'p.phone_perso' => 'Text', 'p.phone_mobile' => 'Text', 'p.fax' => 'Text', 'p.email' => 'Text',

-			'p.note_private' => 'Text', 'p.note_public' => 'Text', 'p.statut' => 'Boolean',

-			's.nom'=>"Text", 's.client'=>"Boolean", 's.fournisseur'=>"Boolean", 's.status'=>"Boolean",

-			's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text",

-			's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text"

+			'u.label' => "Text",

+			'u.description' => "Text",

+			'p.lastname' => 'Text',

+			'p.firstname' => 'Text',

+            'p.statut'=>"Numeric",

+			's.nom'=>"Text",

+			's.status'=>"Text",

+			's.address'=>"Text",

+			's.zip'=>"Text",

+			's.town'=>"Text",

+			's.phone'=>"Text",

+			's.fax'=>"Text",

+			's.url'=>"Text",

+			's.email'=>"Text"

@@ -357,8 +317,33 @@
-			'p.rowid' => 'contact', 'civ.label' => 'contact', 'p.lastname' => 'contact', 'p.firstname' => 'contact',

-			'p.address' => 'contact', 'p.zip' => 'contact', 'p.town' => 'contact', 'c.code' => 'contact', 'c.label' => 'contact',

-			'p.birthday' => 'contact', 'p.poste' => 'contact',

-			'p.phone' => 'contact', 'p.phone_perso' => 'contact', 'p.phone_mobile' => 'contact', 'p.fax' => 'contact', 'p.email' => 'contact',

-			'p.note_private' => 'contact', 'p.note_public' => 'contact', 'p.statut' => 'contact',

-			's.nom'=>"company", 's.client'=>"company", 's.fournisseur'=>"company", 's.status'=>"company",

-			's.address'=>"company", 's.zip'=>"company", 's.town'=>"company",

-			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company"

+			'u.rowid' => "category",

+			'u.label' => "category",

+			'u.description' => "category",

+			'p.rowid' => 'contact',

+			'p.civility' => 'contact',

+			'p.lastname' => 'contact',

+			'p.firstname' => 'contact',

+			'p.address' => 'contact',

+			'p.zip' => 'contact',

+			'p.town' => 'contact',

+			'country.code' => 'contact',

+			'country.label' => 'contact',

+			'p.birthday' => 'contact',

+			'p.poste' => 'contact',

+			'p.phone' => 'contact',

+			'p.phone_perso' => 'contact',

+			'p.phone_mobile' => 'contact',

+			'p.fax' => 'contact',

+			'p.email' => 'contact',

+			'p.note_private' => 'contact',

+			'p.note_public' => 'contact',

+            'p.statut' => 'contact',

+			's.nom'=>"company",

+			's.client'=>"company",

+			's.fournisseur'=>"company",

+			's.status'=>"company",

+			's.address'=>"company",

+			's.zip'=>"company",

+			's.town'=>"company",

+			's.phone'=>"company",

+			's.fax'=>"company",

+			's.url'=>"company",

+			's.email'=>"company"

@@ -367,4 +352,37 @@
-		$keyforselect = 'socpeople';

-		$keyforelement = 'contact';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+        // Add extra fields

+        $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";

+        $resql = $this->db->query($sql);

+        if ($resql)    // This can fail when class is used on old database (during migration for example)

+        {

+        	while ($obj = $this->db->fetch_object($resql))

+        	{

+        		$fieldname = 'extra.'.$obj->name;

+        		$fieldlabel = ucfirst($obj->label);

+        		$typeFilter = "Text";

+        		switch ($obj->type)

+        		{

+        			case 'int':

+        			case 'double':

+        			case 'price':

+        				$typeFilter = "Numeric";

+        				break;

+        			case 'date':

+        			case 'datetime':

+        				$typeFilter = "Date";

+        				break;

+        			case 'boolean':

+        				$typeFilter = "Boolean";

+        				break;

+        			case 'sellist':

+        				$typeFilter = "List:".$obj->param;

+        				break;

+					case 'select':

+						$typeFilter = "Select:".$obj->param;

+						break;

+        		}

+        		$this->export_fields_array[$r][$fieldname] = $fieldlabel;

+        		$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+        		$this->export_entities_array[$r][$fieldname] = 'contact';

+        	}

+        }

+        // End add axtra fields

@@ -373,7 +391,2 @@
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_contact as cc ON cc.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'socpeople as p ON p.rowid = cc.fk_socpeople';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_civility as civ ON civ.code = p.civility';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON c.rowid = p.fk_pays';

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_contact as cp, '.MAIN_DB_PREFIX.'socpeople as p';

+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country ON p.fk_pays = country.rowid';

@@ -381,63 +394,3 @@
-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 4';

-

-		// 5 Bank accounts, TODO ?

-

-		// 6 Projects

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6];

-		$this->export_label[$r] = 'CatProjectsList';

-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = "isModEnabled('project')";

-		$this->export_permission[$r] = array(array("categorie", "lire"), array("projet", "export"));

-		$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', 's.rowid'=>"IdThirdParty", 's.nom'=>"Name");

-		$this->export_TypeFields_array[$r] = array('cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 's.rowid'=>"Numeric", 's.nom'=>"Text");

-		$this->export_entities_array[$r] = array('p.rowid'=>'project', 'p.ref'=>'project', 's.rowid'=>"company", 's.nom'=>"company"); // We define here only fields that use another picto

-

-		$keyforselect = 'projet';

-		$keyforelement = 'project';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_project as cp ON cp.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'projet as p ON p.rowid = cp.fk_project';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON extra.fk_object = p.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 6';

-

-		// 7 Users

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7];

-		$this->export_label[$r] = 'CatUsersList';

-		$this->export_icon[$r] = $this->picto;

-		$this->export_enabled[$r] = 'isModEnabled("user")';

-		$this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export"));

-		$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid'=>'UserID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname');

-		$this->export_TypeFields_array[$r] = array('cat.rowid'=>"Numeric", 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.login'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text');

-		$this->export_entities_array[$r] = array('p.rowid'=>'user', 'p.login'=>'user', 'p.lastname'=>'user', 'p.firstname'=>'user'); // We define here only fields that use another picto

-

-		$keyforselect = 'user';

-		$keyforelement = 'user';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_user as cu ON cu.fk_categorie = cat.rowid';

-		$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'user as p ON p.rowid = cu.fk_user';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON extra.fk_object = p.rowid';

-		$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';

-		$this->export_sql_end[$r] .= ' AND cat.type = 7';

-

-		// 8 Bank Lines, TODO ?

-

-		// 9 Warehouses, TODO ?

-

-		// 10 Agenda Events, TODO ?

-

-		// 11 Website Pages, TODO ?

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid';

+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')';

+		$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories

@@ -450,3 +403,2 @@
-		// Categories

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_list';

+		$r++;

+		$this->import_code[$r] = $this->rights_class.'_'.$r;

@@ -457,24 +409,28 @@
-		$this->import_fields_array[$r] = array(

-			'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description",

-			'ca.fk_parent' => 'ParentCategory'

-		);

-		$this->import_regex_array[$r] = array('ca.type'=>'^(0|1|2|3|4|5|6|7|8|9|10|11)$');

-		$this->import_convertvalue_array[$r] = array(

-			'ca.fk_parent' => array(

-				'rule'          => 'fetchidfromcodeandlabel',

-				'classfile'     => '/categories/class/categorie.class.php',

-				'class'         => 'Categorie',

-				'method'        => 'fetch',

-				'element'       => 'category',

-				'codefromfield' => 'ca.type'

-			)

-		);

-

-		$this->import_examplevalues_array[$r] = array(

-			'ca.label'=>"My Category Label", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", // $typeexample built above in exports

-			'ca.fk_parent' => 'rowid or label'

-		);

-		$this->import_updatekeys_array[$r] = array('ca.label'=>'Label', 'ca.type' => 'Type');

-

-		// 0 Products

-		if (isModEnabled("product")) {

+        $this->import_fields_array[$r] = array(

+            'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description",

+            'ca.fk_parent' => 'Parent'

+        );

+		$this->import_regex_array[$r] = array('ca.type'=>'^[0|1|2|3]');

+        $this->import_convertvalue_array[$r] = array(

+            'ca.fk_parent' => array(

+                'rule'          => 'fetchidfromcodeandlabel',

+                'classfile'     => '/categories/class/categorie.class.php',

+                'class'         => 'Categorie',

+                'method'        => 'fetch',

+                'element'       => 'category',

+                'codefromfield' => 'ca.type'

+            )

+        );

+		$typeexample = "";

+		if ($conf->product->enabled) { $typeexample .= ($typeexample ? "/" : "")."0=Product"; }

+		if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; }

+		if ($conf->societe->enabled) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; }

+		if ($conf->adherent->enabled) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; }

+        $this->import_examplevalues_array[$r] = array(

+            'ca.label'=>"Supplier Category", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description",

+            'ca.fk_parent' => '0'

+        );

+

+		if (!empty($conf->product->enabled))

+		{

+			//Products

@@ -482 +438 @@
-			$this->import_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0];

+			$this->import_code[$r] = $this->rights_class.'_'.$r;

@@ -492,4 +448,3 @@
-					'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')

-			);

-			$this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_product'=>"rowid or ref");

-			$this->import_updatekeys_array[$r] = array('cp.fk_categorie' => 'Category', 'cp.fk_product' => 'ProductRef');

+					'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product')

+			);

+			$this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"Imported category", 'cp.fk_product'=>"PREF123456");

@@ -498,2 +453,3 @@
-		// 1 Suppliers

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

+		if (!empty($conf->societe->enabled))

+		{

+			// Customers

@@ -501 +457,42 @@
-			$this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1];

+			$this->import_code[$r] = $this->rights_class.'_'.$r;

+			$this->import_label[$r] = "CatCusLinks"; // Translation key

+			$this->import_icon[$r] = $this->picto;

+			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

+			$this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe');

+			$this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"ThirdParty*");

+			$this->import_regex_array[$r] = array(

+				'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2',

+				'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0'

+			);

+

+			$this->import_convertvalue_array[$r] = array(

+					'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),

+					'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')

+			);

+			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany");

+

+			// Contacts/Addresses

+			$r++;

+			$this->import_code[$r] = $this->rights_class.'_'.$r;

+			$this->import_label[$r] = "CatContactsLinks"; // Translation key

+			$this->import_icon[$r] = $this->picto;

+			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

+			$this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_contact');

+			$this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_socpeople'=>"Contact ID*");

+			$this->import_regex_array[$r] = array(

+				'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4'

+				//'cs.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople'

+			);

+

+			$this->import_convertvalue_array[$r] = array(

+				'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category')

+				//'cs.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact')

+			);

+			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_socpeople'=>"123");

+		}

+

+		if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))

+		{

+			// Suppliers

+			$r++;

+			$this->import_code[$r] = $this->rights_class.'_'.$r;

@@ -516 +513 @@
-			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or name");

+			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany");

@@ -518,106 +514,0 @@
-

-		// 2 Customers

-		if (isModEnabled("societe")) {

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2];

-			$this->import_label[$r] = "CatCusLinks"; // Translation key

-			$this->import_icon[$r] = $this->picto;

-			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe');

-			$this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Customer*");

-			$this->import_regex_array[$r] = array(

-				'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2',

-				'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0'

-			);

-

-			$this->import_convertvalue_array[$r] = array(

-					'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),

-					'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')

-			);

-			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or name");

-		}

-

-		// 3 Members

-		if (isModEnabled('adherent')) {

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3];

-			$this->import_label[$r] = "CatMembersLinks"; // Translation key

-			$this->import_icon[$r] = $this->picto;

-			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('cm'=>MAIN_DB_PREFIX.'categorie_contact');

-			$this->import_fields_array[$r] = array('cm.fk_categorie'=>"Category*", 'cm.fk_member'=>"Member*");

-			$this->import_regex_array[$r] = array('cm.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=3');

-

-			$this->import_convertvalue_array[$r] = array(

-				'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),

-				'cs.fk_member'=>array('rule'=>'fetchidfromref', 'classfile'=>'/adherents/class/adherent.class.php', 'class'=>'Adherent', 'method'=>'fetch', 'element'=>'Member')

-			);

-			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_member'=>"rowid or ref");

-		}

-

-		// 4 Contacts/Addresses

-		if (isModEnabled("societe")) {

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4];

-			$this->import_label[$r] = "CatContactsLinks"; // Translation key

-			$this->import_icon[$r] = $this->picto;

-			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('cc'=>MAIN_DB_PREFIX.'categorie_contact');

-			$this->import_fields_array[$r] = array('cc.fk_categorie'=>"Category*", 'cc.fk_socpeople'=>"IdContact*");

-			$this->import_regex_array[$r] = array(

-				'cc.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4'

-				//'cc.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople'

-			);

-

-			$this->import_convertvalue_array[$r] = array(

-				'cc.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),

-				//'cc.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact')

-			);

-			$this->import_examplevalues_array[$r] = array('cc.fk_categorie'=>"rowid or label", 'cc.fk_socpeople'=>"rowid");

-		}

-

-		// 5 Bank accounts, TODO ?

-

-		// 6 Projects

-		if (isModEnabled('project')) {

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6];

-			$this->import_label[$r] = "CatProjectsLinks"; // Translation key

-			$this->import_icon[$r] = $this->picto;

-			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_project');

-			$this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_project'=>"Project*");

-			$this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=6');

-

-			$this->import_convertvalue_array[$r] = array(

-				'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),

-				'cs.fk_project'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project')

-			);

-			$this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_project'=>"rowid or ref");

-		}

-

-		// 7 Users

-		if (isModEnabled('user')) {

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7];

-			$this->import_label[$r] = "CatUsersLinks"; // Translation key

-			$this->import_icon[$r] = $this->picto;

-			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('cu'=>MAIN_DB_PREFIX.'categorie_user');

-			$this->import_fields_array[$r] = array('cu.fk_categorie'=>"Category*", 'cu.fk_user'=>"User*");

-			$this->import_regex_array[$r] = array('cu.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=7');

-

-			$this->import_convertvalue_array[$r] = array(

-				'cu.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),

-				'cu.fk_user'=>array('rule'=>'fetchidfromref', 'classfile'=>'/user/class/user.class.php', 'class'=>'User', 'method'=>'fetch', 'element'=>'User')

-			);

-			$this->import_examplevalues_array[$r] = array('cu.fk_categorie'=>"rowid or label", 'cu.fk_user'=>"rowid or login");

-		}

-

-		// 8 Bank Lines, TODO ?

-

-		// 9 Warehouses, TODO ?

-

-		// 10 Agenda Events, TODO ?

-

-		// 11 Website Pages, TODO ?

@@ -627 +518 @@
-	/**

+    /**

@@ -632 +523 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -634 +525 @@
-	 */

+     */

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modCollab.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCollab.class.php
@@ -23 +23 @@
- *  \brief      Description and activation file for the module Collab

+ *  \brief      Description and activation file for module Collab

@@ -33,8 +32,0 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

@@ -42,2 +34,8 @@
-		$this->db = $db;

-		$this->numero = 30000;

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        global $langs, $conf;

@@ -45,13 +43,2 @@
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "portal";

-		$this->module_position = '51';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc...";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'development';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'collab';

+        $this->db = $db;

+        $this->numero = 30000;

@@ -59,2 +46,13 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array("/collab/temp");

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "portal";

+        $this->module_position = '51';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc...";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'development';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'website';

@@ -62,3 +60,2 @@
-		// Config pages

-		//-------------

-		$this->config_page_url = array(/*'collab.php'*/);

+        // Data directories to create when module is enabled

+        $this->dirs = array("/collab/temp");

@@ -66,7 +63,3 @@
-		// Dependancies

-		//-------------

-		$this->hidden = getDolGlobalString('MODULE_COLLAB_DISABLED'); // A condition to disable module

-		$this->depends = array(); // 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(); // List of modules id this module is in conflict with

-		$this->langfiles = array("collab");

+        // Config pages

+        //-------------

+        $this->config_page_url = array(/*'collab.php'*/);

@@ -74,3 +67,7 @@
-		// Constants

-		//-----------

-		$this->const = array();

+        // Dependancies

+        //-------------

+        $this->hidden = !empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module

+        $this->depends = array(); // 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(); // List of modules id this module is in conflict with

+        $this->langfiles = array("collab");

@@ -78,3 +75,3 @@
-		// New pages on tabs

-		// -----------------

-		$this->tabs = array();

+        // Constants

+        //-----------

+           $this->const = array();

@@ -82,3 +79,3 @@
-		// Boxes

-		//------

-		$this->boxes = array();

+        // New pages on tabs

+        // -----------------

+        $this->tabs = array();

@@ -86,4 +83,3 @@
-		// Permissions

-		$this->rights = array(); // Permission array used by this module

-		$this->rights_class = 'collab';

-		$r = 0;

+        // Boxes

+        //------

+        $this->boxes = array();

@@ -91,5 +87,4 @@
-		/*$this->rights[$r][0] = 30001;

-		$this->rights[$r][1] = 'Read website content';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'read';

-		$r++;

+        // Permissions

+        $this->rights = array(); // Permission array used by this module

+        $this->rights_class = 'collab';

+        $r = 0;

@@ -97,5 +92,5 @@
-		$this->rights[$r][0] = 30002;

-		$this->rights[$r][1] = 'Create/modify website content';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'write';

-		$r++;

+        /*$this->rights[$r][0] = 30001;

+        $this->rights[$r][1] = 'Read website content';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'read';

+        $r++;

@@ -103,5 +98,5 @@
-		$this->rights[$r][0] = 30003;

-		$this->rights[$r][1] = 'Delete website content';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'delete';

-		$r++;*/

+        $this->rights[$r][0] = 30002;

+        $this->rights[$r][1] = 'Create/modify website content';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'write';

+        $r++;

@@ -109,3 +104,9 @@
-		// Main menu entries

-		$r = 0;

-		$this->menu[$r] = array(

+        $this->rights[$r][0] = 30003;

+        $this->rights[$r][1] = 'Delete website content';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'delete';

+        $r++;*/

+

+        // Main menu entries

+        $r = 0;

+        $this->menu[$r] = array(

@@ -113,14 +114,13 @@
-			'type'=>'top', // This is a Left menu entry

-			'titre'=>'Collab',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em092"'),

-			'mainmenu'=>'collab',

-			'url'=>'/collab/index.php',

-			'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>100,

-			'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-			'target'=>'',

-			'user'=>2				                // 0=Menu for internal users, 1=external users, 2=both

-		);

-		$r++;

-	}

+            'type'=>'top', // This is a Left menu entry

+            'titre'=>'Collab',

+            'mainmenu'=>'collab',

+            'url'=>'/collab/index.php',

+            'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+            'position'=>100,

+            'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+            'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+            'target'=>'',

+            'user'=>2				                // 0=Menu for internal users, 1=external users, 2=both

+        );

+        $r++;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modCommande.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCommande.class.php
@@ -9 +8,0 @@
- * Copyright (C) 2020		Ahmad Jamaly Rabub		<rabib@metroworks.co.jp>

@@ -30 +29 @@
- *		\brief      Description and activation file for the module command

+ *		\brief      Fichier de description et activation du module Commande

@@ -37 +36 @@
- *	Class to describe module Sales Orders

+ *	Class to describe module customer orders

@@ -40,0 +40 @@
+

@@ -82 +82 @@
-		$this->const[$r][2] = "eratosthene";

+		$this->const[$r][2] = "einstein";

@@ -142,2 +142,2 @@
-		$this->rights[$r][0] = 85;

-		$this->rights[$r][1] = 'Generate the documents sales orders';

+		$this->rights[$r][0] = 86;

+		$this->rights[$r][1] = 'Send sale orders by email';

@@ -147,9 +147 @@
-		$this->rights[$r][5] = 'generetedoc';

-

-		$r++;

-		$this->rights[$r][0] = 86;

-		$this->rights[$r][1] = 'Send sales orders by email';

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'order_advance';

-		$this->rights[$r][5] = 'send';

+        $this->rights[$r][5] = 'send';

@@ -203 +195 @@
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country',

+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country',

@@ -206,2 +198,2 @@
-			'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.total_ht'=>"TotalHT",

-			'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'sm.code'=>'SendingMethod',

+			'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.remise_percent'=>"GlobalDiscount", 'c.total_ht'=>"TotalHT",

+			'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',

@@ -209 +201 @@
-			'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',

+			'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',

@@ -213,13 +205,7 @@
-		if (isModEnabled("multicurrency")) {

-			$this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency';

-			$this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';

-			$this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add multicompany field

-		if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {

-			$nbofallowedentities = count(explode(',', getEntity('commande')));

-			if (isModEnabled('multicompany') && $nbofallowedentities > 1) {

-				$this->export_fields_array[$r]['c.entity'] = 'Entity';

-			}

+		if (!empty($conf->multicurrency->enabled))

+		{

+		    $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency';

+		    $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';

+		    $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

+		    $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

+		    $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

@@ -228 +214 @@
-		//	's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',

+		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',

@@ -230 +216 @@
-		//	'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.total_ht'=>"Numeric",

+		//	'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",

@@ -236 +222 @@
-			's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text',

+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text',

@@ -238,2 +224,2 @@
-			'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'sm.code'=>"Text", 'c.amount_ht'=>"Numeric", 'c.total_ht'=>"Numeric",

-			'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'pj.ref'=>'Text',

+			'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric",

+			'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text',

@@ -241,2 +227 @@
-			'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text',

-			'c.entity'=>'List:entity:label:rowid',

+			'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text'

@@ -245 +230 @@
-			's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company',

+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company',

@@ -248,2 +233,2 @@
-			'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",

-			'c.date_livraison'=>"order", 'sm.code'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.description'=>"order_line",

+			'c.remise_percent'=>"order", 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",

+			'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.label'=>"order_line", 'cd.description'=>"order_line",

@@ -254,3 +239 @@
-		$keyforselect = 'commande';

-		$keyforelement = 'order';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'commande'; $keyforelement = 'order'; $keyforaliasextra = 'extra';

@@ -258,3 +241 @@
-		$keyforselect = 'commandedet';

-		$keyforelement = 'order_line';

-		$keyforaliasextra = 'extra2';

+		$keyforselect = 'commandedet'; $keyforelement = 'order_line'; $keyforaliasextra = 'extra2';

@@ -262,3 +243 @@
-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra3';

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3';

@@ -266,3 +245 @@
-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extra4';

+		$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra4';

@@ -271,0 +249 @@
+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -273,4 +250,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';

-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

@@ -280 +253,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as sm ON c.fk_shipping_method = sm.rowid';

@@ -291,147 +264 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

-		}

-

-		// Imports

-		//--------

-		$r = 0;

-		//Import Order Header

-

-		$r++;

-		$this->import_code[$r] = 'commande_'.$r;

-		$this->import_label[$r] = 'CustomersOrders';

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array();

-		$this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields');

-		$this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id

-		$import_sample = array();

-		$this->import_fields_array[$r] = array(

-			'c.ref'               => 'Ref*',

-			'c.ref_client'        => 'RefCustomer',

-			'c.fk_soc'            => 'ThirdPartyName*',

-			'c.fk_projet'         => 'ProjectId',

-			'c.date_creation'     => 'DateCreation',

-			'c.date_valid'        => 'DateValidation',

-			'c.date_commande'     => 'OrderDate*',

-			'c.fk_user_modif'     => 'ModifiedById',

-			'c.fk_user_valid'     => 'ValidatedById',

-			'c.total_tva'         => 'TotalTVA',

-			'c.total_ht'          => 'TotalHT',

-			'c.total_ttc'         => 'TotalTTC',

-			'c.note_private'      => 'NotePrivate',

-			'c.note_public'       => 'Note',

-			'c.facture'           => 'Invoice(1/0)',

-			'c.date_livraison'    => 'DeliveryDate',

-			'c.fk_cond_reglement' => 'Payment Condition',

-			'c.fk_mode_reglement' => 'Payment Mode',

-			'c.model_pdf'         => 'Model',

-			'c.fk_statut'         => 'Status*'

-		);

-

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['c.multicurrency_code']      = 'Currency';

-			$this->import_fields_array[$r]['c.multicurrency_tx']        = 'CurrencyRate';

-			$this->import_fields_array[$r]['c.multicurrency_total_ht']  = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		$import_extrafield_sample = array();

-		$keyforselect = 'commande';

-		$keyforelement = 'order';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';

-

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande');

-		$this->import_regex_array[$r] = array(

-			'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'

-		);

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('c.ref' => 'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'c.ref' => array(

-				'rule'=>'getrefifauto',

-				'class'=>(!getDolGlobalString('COMMANDE_ADDON') ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON),

-				'path'=>"/core/modules/commande/".(!getDolGlobalString('COMMANDE_ADDON') ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON).'.php',

-				'classobject'=>'Commande',

-				'pathobject'=>'/commande/class/commande.class.php',

-			),

-			'c.fk_soc' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/societe/class/societe.class.php',

-				'class'   => 'Societe',

-				'method'  => 'fetch',

-				'element' => 'ThirdParty'

-			),

-			'c.fk_user_valid' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/user/class/user.class.php',

-				'class'   => 'User',

-				'method'  => 'fetch',

-				'element' => 'user'

-			),

-			'c.fk_mode_reglement' => array(

-				'rule' => 'fetchidfromcodeorlabel',

-				'file' => '/compta/paiement/class/cpaiement.class.php',

-				'class' => 'Cpaiement',

-				'method' => 'fetch',

-				'element' => 'cpayment'

-			),

-		);

-

-		//Import Order Lines

-		$r++;

-		$this->import_code[$r] = 'commande_lines_'.$r;

-		$this->import_label[$r] = 'SaleOrderLines';

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array();

-		$this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields');

-		$this->import_fields_array[$r] = array(

-			'cd.fk_commande'    => 'CustomerOrder*',

-			'cd.fk_parent_line' => 'ParentLine',

-			'cd.fk_product'     => 'IdProduct',

-			'cd.description'    => 'LineDescription',

-			'cd.tva_tx'         => 'LineVATRate',

-			'cd.qty'            => 'LineQty',

-			'cd.remise_percent' => 'Reduc. Percent',

-			'cd.price'          => 'Price',

-			'cd.subprice'       => 'Sub Price',

-			'cd.total_ht'       => 'LineTotalHT',

-			'cd.total_tva'      => 'LineTotalVAT',

-			'cd.total_ttc'      => 'LineTotalTTC',

-			'cd.product_type'   => 'TypeOfLineServiceOrProduct',

-			'cd.date_start'     => 'Start Date',

-			'cd.date_end'       => 'End Date',

-			'cd.buy_price_ht'   => 'LineBuyPriceHT',

-			'cd.rang'           => 'LinePosition'

-		);

-

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-

-		$import_extrafield_sample = array();

-		$keyforselect = 'commandedet';

-		$keyforelement = 'orderline';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';

-

-		$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commandedet'];

-		$this->import_regex_array[$r] = [

-			'cd.product_type'       => '[0|1]$',

-			'cd.fk_product'         => 'rowid@'.MAIN_DB_PREFIX.'product',

-			'cd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'

-		];

-		$this->import_updatekeys_array[$r] = ['cd.fk_commande' => 'Sales Order Id', 'cd.fk_product' => 'Product Id'];

-		$this->import_convertvalue_array[$r] = [

-			'cd.fk_commande' => [

-				'rule'    => 'fetchidfromref',

-				'file'    => '/commande/class/commande.class.php',

-				'class'   => 'Commande',

-				'method'  => 'fetch',

-				'element' => 'commande'

-			],

-		];

+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

@@ -446 +273 @@
-	 *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

@@ -461 +288,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -465 +293,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -473,2 +302,2 @@
-				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order' AND entity = ".((int) $conf->entity),

-				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'order', ".((int) $conf->entity).")"

+				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order' AND entity = ".$conf->entity,

+				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")"

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modComptabilite.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modComptabilite.class.php
@@ -22,6 +22,5 @@
- *  \defgroup   comptabilite     Module Comptabilite

- *  \brief      Module to include accounting functions (account management and reporting)

- *

- *  \file       htdocs/core/modules/modComptabilite.class.php

- *  \ingroup    comptabilite

- *  \brief      Description and activation file for the module simple accountancy

+ * \defgroup   comptabilite     Module comptabilite

+ * \brief      Module pour inclure des fonctions de comptabilite (gestion de comptes comptables et rapports)

+ * \file       htdocs/core/modules/modComptabilite.class.php

+ * \ingroup    comptabilite

+ * \brief      Fichier de description et activation du module Comptabilite

@@ -38,5 +37,6 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

+

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

@@ -60 +60 @@
-		$this->picto = 'accountancy';

+        $this->picto = 'accounting';

@@ -75,6 +75,6 @@
-		$this->dirs = array(

-			"/comptabilite/temp",

-			"/comptabilite/rapport",

-			"/comptabilite/export",

-			"/comptabilite/bordereau"

-		);

+        $this->dirs = array(

+            "/comptabilite/temp",

+            "/comptabilite/rapport",

+            "/comptabilite/export",

+            "/comptabilite/bordereau"

+        );

@@ -105,2 +105,2 @@
-	/**

-	 *  Function called when module is enabled.

+    /**

+     *  Function called when module is enabled.

@@ -110,5 +110,5 @@
-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+    */

+    public function init($options = '')

+    {

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modContrat.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modContrat.class.php
@@ -25 +25 @@
- *	\brief      Description and activation file for the module contract

+ *	\brief      Fichier de description et activation du module Contrat

@@ -35,0 +36 @@
+

@@ -165 +166 @@
-		's.email'=>'Email', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',

+		's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',

@@ -168 +169 @@
-		'co.fin_validite'=>"ContractEndDate", 'co.date_cloture'=>"DateClosing", 'co.note_private'=>"NotePrivate", 'co.note_public'=>"NotePublic",

+		'co.fin_validite'=>"ContractEndDate", 'co.date_cloture'=>"Closing", 'co.note_private'=>"NotePrivate", 'co.note_public'=>"NotePublic",

@@ -175 +176 @@
-		's.town'=>'company', 'c.code'=>'company', 's.email'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company',

+		's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company',

@@ -184,2 +185,2 @@
-		$this->export_TypeFields_array[$r] = array('s.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text',

-		's.email'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text',

+		$this->export_TypeFields_array[$r] = array('s.rowid'=>"List:societe:nom", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text',

+		's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text',

@@ -195,3 +196 @@
-		$keyforselect = 'contrat';

-		$keyforelement = 'contract';

-		$keyforaliasextra = 'coextra';

+		$keyforselect = 'contrat'; $keyforelement = 'contract'; $keyforaliasextra = 'coextra';

@@ -199,3 +198 @@
-		$keyforselect = 'contratdet';

-		$keyforelement = 'contract_line';

-		$keyforaliasextra = 'codextra';

+		$keyforselect = 'contratdet'; $keyforelement = 'contract_line'; $keyforaliasextra = 'codextra';

@@ -221 +218 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -236,9 +233,11 @@
-		if (file_exists($src) && !file_exists($dest)) {

-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-			dol_mkdir($dirodt);

-			$result = dol_copy($src, $dest, 0, 0);

-			if ($result < 0) {

-				$langs->load("errors");

-				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

-				return 0;

-			}

+		if (file_exists($src) && !file_exists($dest))

+		{

+		    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+		    dol_mkdir($dirodt);

+		    $result = dol_copy($src, $dest, 0, 0);

+		    if ($result < 0)

+		    {

+		        $langs->load("errors");

+		        $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

+		        return 0;

+		    }

@@ -248,2 +247,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."', 'contract', ".((int) $conf->entity).")"

+		    "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity,

+		    "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")"

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modCron.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modCron.class.php
@@ -4 +3,0 @@
- * Copyright (C) 2022		Anthony Berton	<anthony.berton@bb2a.fr>

@@ -25 +24 @@
- *  \brief      Description and activation file for the module Jobs

+ *  \brief      Description and activation file for module Jobs

@@ -35 +34,2 @@
-	/**

+

+    /**

@@ -39,4 +39,4 @@
-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

+     */

+    public function __construct($db)

+    {

+    	global $langs, $conf;

@@ -44,2 +44,2 @@
-		$this->db = $db;

-		$this->numero = 2300;

+        $this->db = $db;

+        $this->numero = 2300;

@@ -49,4 +49,4 @@
-		$this->family = "base";

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable the Dolibarr cron service";

+        $this->family = "base";

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable the Dolibarr cron service";

@@ -54,5 +54,5 @@
-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'cron';

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'technic';

@@ -60,2 +60,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -63,3 +63,3 @@
-		// Config pages

-		//-------------

-		$this->config_page_url = array("cron.php@cron");

+        // Config pages

+        //-------------

+        $this->config_page_url = array("cron.php@cron");

@@ -69 +69 @@
-		$this->hidden = getDolGlobalString('MODULE_CRON_DISABLED'); // A condition to disable module

+		$this->hidden = !empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module

@@ -88,3 +88,3 @@
-		// New pages on tabs

-		// -----------------

-		$this->tabs = array();

+        // New pages on tabs

+        // -----------------

+        $this->tabs = array();

@@ -92,5 +92,3 @@
-		// Boxes

-		//------

-		$this->boxes = array(

-			0 => array('file' => 'box_scheduled_jobs.php', 'enabledbydefaulton' => 'Home')

-		);

+        // Boxes

+        //------

+        $this->boxes = array();

@@ -100,4 +98,2 @@
-			0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'tempfilesold+logfiles', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true),

-			1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10,0,0', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>'in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'),

-			2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendBackup', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'),

-			3=>array('entity'=>0, 'label'=>'CleanUnfinishedCronjobShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'cleanUnfinishedCronjob', 'parameters'=>'', 'comment'=>'CleanUnfinishedCronjob', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>0, 'test'=>'getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 2'),

+			0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true),

+			1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))),

@@ -107 +103 @@
-		// Permissions

+        // Permissions

@@ -136,14 +132,14 @@
-		// Main menu entries

-		$r = 0;

-		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-								'type'=>'left', // This is a Left menu entry

-								'titre'=>'CronList',

-								'url'=>'/cron/list.php?leftmenu=admintools',

-								'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-								'position'=>500,

-								'enabled'=>'$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-								'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-								'target'=>'',

-								'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

-		$r++;

-	}

+        // Main menu entries

+        $r = 0;

+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+						        'type'=>'left', // This is a Left menu entry

+						        'titre'=>'CronList',

+						        'url'=>'/cron/list.php?leftmenu=admintools',

+						        'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+						        'position'=>200,

+						        'enabled'=>'$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+						        'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+						        'target'=>'',

+						        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

+        $r++;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modDataPolicy.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDataPolicy.class.php
@@ -1,0 +2 @@
+

@@ -25 +26 @@
- *  \brief      Description and activation file for the module datapolicy

+ *  \brief      Description and activation file for module DATAPOLICY

@@ -37,222 +38,224 @@
-class modDataPolicy extends DolibarrModules

-{

-	// @codingStandardsIgnoreEnd

-	/**

-	 * Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 * @param DoliDB $db Database handler

-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

-

-		$this->db = $db;

-

-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 4100;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'datapolicy';

-

-		// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'

-		// It is used to group modules by family in module setup page

-		$this->family = "technic";

-		// Module position in the family on 2 digits ('01', '10', '20', ...)

-		$this->module_position = '78';

-		// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)

-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));

-		// Module label (no space allowed), used if translation string 'ModuledatapolicyName' not found (MyModue is name of module).

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuledatapolicyDesc' not found (MyModue is name of module).

-		$this->description = "Module to manage Data policy (for compliance with GDPR in Europe or other Data policy rules)";

-		// Used only if file README.md and README-LL.md not found.

-		$this->descriptionlong = "";

-

-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'

-		$this->version = 'experimental';

-		// Key used in llx_const table to save module status enabled/disabled (where datapolicy is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'generic';

-

-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)

-		// for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable)

-		// for specific path of parts (eg: /datapolicy/core/modules/barcode)

-		// for specific css file (eg: /datapolicy/css/datapolicy.css.php)

-		$this->module_parts = array(

-			'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)

-			'login' => 0, // Set this to 1 if module has its own login method file (core/login)

-			'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)

-			'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)

-			'theme' => 0, // Set this to 1 if module has its own theme directory (theme)

-			'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)

-			'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)

-			'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)

-			'hooks' => array('data' => array('membercard', 'contactcard', 'thirdpartycard'), 'entity' => $conf->entity)  // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'

-		);

-

-		// Data directories to create when module is enabled.

-		// Example: this->dirs = array("/datapolicy/temp","/datapolicy/subdir");

-		$this->dirs = array("/datapolicy/temp");

-

-		// Config pages. Put here list of php page, stored into datapolicy/admin directory, to use to setup module.

-		$this->config_page_url = array("setup.php@datapolicy");

-

-		// Dependencies

-		$this->hidden = false; // A condition to hide module

-		$this->depends = array('always'=>'modCron'); // List of module class names as string that must be enabled if this module is enabled

-		$this->requiredby = array(); // List of module ids to disable if this one is disabled

-		$this->conflictwith = array(); // List of module class names as string this module is in conflict with

-		$this->langfiles = array("datapolicy");

-		$this->phpmin = array(5, 3); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module

-		$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		//$this->automatic_activation = array('FR'=>'datapolicyWasAutomaticallyActivatedBecauseOfYourCountryChoice');

-		//$this->always_enabled = true;								// If true, can't be disabled

-		// Constants

-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

-		// Example: $this->const=array(0=>array('datapolicy_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),

-		//                             1=>array('datapolicy_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)

-		// );

-		$this->const = array(

-			array('DATAPOLICY_TIERS_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_TIERS_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_TIERS_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_TIERS_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_TIERS_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_CONTACT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_CONTACT_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_CONTACT_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_CONTACT_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-			array('DATAPOLICY_ADHERENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

-		);

-

-		$country = explode(":", !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY') ? '' : $conf->global->MAIN_INFO_SOCIETE_COUNTRY);

-

-		// Some keys to add into the overwriting translation tables

-		/* $this->overwrite_translation = array(

-		  'en_US:ParentCompany'=>'Parent company or reseller',

-		  'fr_FR:ParentCompany'=>'Maison mère ou revendeur'

-		  ) */

-

-		if (!isset($conf->datapolicy) || !isset($conf->datapolicy->enabled)) {

-			$conf->datapolicy = new stdClass();

-			$conf->datapolicy->enabled = 0;

-		}

-

-

-		// Array to add new pages in new tabs

-		$this->tabs = array();

-		// Example:

-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@datapolicy:$user->rights->datapolicy->read:/datapolicy/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@datapolicy:$user->rights->othermodule->read:/datapolicy/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

-		//

-		// Where objecttype can be

-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

-		// 'contact'          to add a tab in contact view

-		// 'contract'         to add a tab in contract view

-		// 'group'            to add a tab in group view

-		// 'intervention'     to add a tab in intervention view

-		// 'invoice'          to add a tab in customer invoice view

-		// 'invoice_supplier' to add a tab in supplier invoice view

-		// 'member'           to add a tab in fundation member view

-		// 'opensurveypoll'	  to add a tab in opensurvey poll view

-		// 'order'            to add a tab in sales order view

-		// 'order_supplier'   to add a tab in supplier order view

-		// 'payment'		  to add a tab in payment view

-		// 'payment_supplier' to add a tab in supplier payment view

-		// 'product'          to add a tab in product view

-		// 'propal'           to add a tab in propal view

-		// 'project'          to add a tab in project view

-		// 'stock'            to add a tab in stock view

-		// 'thirdparty'       to add a tab in third party view

-		// 'user'             to add a tab in user view

-

-

-		// Dictionaries

-		$this->dictionaries = array();

-

-

-		// Boxes/Widgets

-		// Add here list of php file(s) stored in datapolicy/core/boxes that contains class to show a widget.

-		$this->boxes = array();

-

-

-		// Cronjobs (List of cron jobs entries to add when module is enabled)

-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

-		$this->cronjobs = array(

-			0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'),

-		);

-		// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),

-		//                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)

-		// );

-		// Permissions

-		$this->rights = array(); // Permission array used by this module

-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

-	}

-

-	/**

-	 * 	Function called when module is enabled.

-	 * 	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 * 	It also creates data directories

-	 *

-	 * 	@param      string	$options    Options when enabling module ('', 'noboxes')

-	 * 	@return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $langs;

-

-		// Create extrafields

-		include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

-		$extrafields = new ExtraFields($this->db);

-

-		/*

-		// Extrafield contact

-		$result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0);

-		$result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'thirdparty', 0, 0, '', '', 0, '', '0', 0);

-

-		// Extrafield Tiers

-		$result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'contact', 0, 0, '', '', 1, '', '3', 0);

-		$result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'contact', 0, 0, '', '', 0, '', '0', 0);

-

-		// Extrafield Adherent

-		$result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy', '$conf->datapolicy->enabled');

-		$result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0);

-		$result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0);

-		*/

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

-

-	/**

-	 * 	Function called when module is disabled.

-	 * 	Remove from database constants, boxes and permissions from Dolibarr database.

-	 * 	Data directories are not deleted

-	 *

-	 * 	@param      string	$options    Options when enabling module ('', 'noboxes')

-	 * 	@return     int             	1 if OK, 0 if KO

-	 */

-	public function remove($options = '')

-	{

-		$sql = array();

-

-		return $this->_remove($sql, $options);

-	}

+class modDataPolicy extends DolibarrModules {

+

+    // @codingStandardsIgnoreEnd

+    /**

+     * Constructor. Define names, constants, directories, boxes, permissions

+     *

+     * @param DoliDB $db Database handler

+     */

+    public function __construct($db)

+    {

+        global $langs, $conf;

+

+        $this->db = $db;

+

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 4100;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'datapolicy';

+

+        // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'

+        // It is used to group modules by family in module setup page

+        $this->family = "technic";

+        // Module position in the family on 2 digits ('01', '10', '20', ...)

+        $this->module_position = '78';

+        // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)

+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));

+        // Module label (no space allowed), used if translation string 'ModuledatapolicyName' not found (MyModue is name of module).

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuledatapolicyDesc' not found (MyModue is name of module).

+        $this->description = "Module to manage Data policy (for compliance with GDPR in Europe or other Data policy rules)";

+        // Used only if file README.md and README-LL.md not found.

+        $this->descriptionlong = "";

+

+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'

+        $this->version = 'experimental';

+        // Key used in llx_const table to save module status enabled/disabled (where datapolicy is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'generic';

+

+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)

+        // for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable)

+        // for specific path of parts (eg: /datapolicy/core/modules/barcode)

+        // for specific css file (eg: /datapolicy/css/datapolicy.css.php)

+        $this->module_parts = array(

+            'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)

+            'login' => 0, // Set this to 1 if module has its own login method file (core/login)

+            'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)

+            'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)

+            'theme' => 0, // Set this to 1 if module has its own theme directory (theme)

+            'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)

+            'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)

+            'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)

+            'hooks' => array('data' => array('membercard', 'contactcard', 'thirdpartycard'), 'entity' => $conf->entity)  // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'

+        );

+

+        // Data directories to create when module is enabled.

+        // Example: this->dirs = array("/datapolicy/temp","/datapolicy/subdir");

+        $this->dirs = array("/datapolicy/temp");

+

+        // Config pages. Put here list of php page, stored into datapolicy/admin directory, to use to setup module.

+        $this->config_page_url = array("setup.php@datapolicy");

+

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

+        $this->depends = array('always'=>'modCron'); // List of module class names as string that must be enabled if this module is enabled

+        $this->requiredby = array(); // List of module ids to disable if this one is disabled

+        $this->conflictwith = array(); // List of module class names as string this module is in conflict with

+        $this->langfiles = array("datapolicy@datapolicy");

+        $this->phpmin = array(5, 3); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module

+        $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        //$this->automatic_activation = array('FR'=>'datapolicyWasAutomaticallyActivatedBecauseOfYourCountryChoice');

+        //$this->always_enabled = true;								// If true, can't be disabled

+        // Constants

+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

+        // Example: $this->const=array(0=>array('datapolicy_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),

+        //                             1=>array('datapolicy_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)

+        // );

+        $this->const = array(

+            array('DATAPOLICY_TIERS_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_TIERS_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_TIERS_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_TIERS_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_TIERS_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_CONTACT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_CONTACT_PROSPECT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_CONTACT_PROSPECT_CLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_CONTACT_FOURNISSEUR', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+            array('DATAPOLICY_ADHERENT', 'chaine', '', $langs->trans('NUMBER_MONTH_BEFORE_DELETION'), 0),

+        );

+

+        $country = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);

+

+        // Some keys to add into the overwriting translation tables

+        /* $this->overwrite_translation = array(

+          'en_US:ParentCompany'=>'Parent company or reseller',

+          'fr_FR:ParentCompany'=>'Maison mère ou revendeur'

+          ) */

+

+        if (!isset($conf->datapolicy) || !isset($conf->datapolicy->enabled)) {

+            $conf->datapolicy = new stdClass();

+            $conf->datapolicy->enabled = 0;

+        }

+

+

+        // Array to add new pages in new tabs

+        $this->tabs = array();

+        // Example:

+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@datapolicy:$user->rights->datapolicy->read:/datapolicy/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

+        // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@datapolicy:$user->rights->othermodule->read:/datapolicy/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //

+        // Where objecttype can be

+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

+        // 'contact'          to add a tab in contact view

+        // 'contract'         to add a tab in contract view

+        // 'group'            to add a tab in group view

+        // 'intervention'     to add a tab in intervention view

+        // 'invoice'          to add a tab in customer invoice view

+        // 'invoice_supplier' to add a tab in supplier invoice view

+        // 'member'           to add a tab in fundation member view

+        // 'opensurveypoll'	  to add a tab in opensurvey poll view

+        // 'order'            to add a tab in customer order view

+        // 'order_supplier'   to add a tab in supplier order view

+        // 'payment'		  to add a tab in payment view

+        // 'payment_supplier' to add a tab in supplier payment view

+        // 'product'          to add a tab in product view

+        // 'propal'           to add a tab in propal view

+        // 'project'          to add a tab in project view

+        // 'stock'            to add a tab in stock view

+        // 'thirdparty'       to add a tab in third party view

+        // 'user'             to add a tab in user view

+

+

+        // Dictionaries

+        $this->dictionaries = array();

+

+

+        // Boxes/Widgets

+        // Add here list of php file(s) stored in datapolicy/core/boxes that contains class to show a widget.

+        $this->boxes = array();

+

+

+        // Cronjobs (List of cron jobs entries to add when module is enabled)

+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

+        $this->cronjobs = array(

+            0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'),

+        );

+        // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),

+        //                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)

+        // );

+        // Permissions

+        $this->rights = array(); // Permission array used by this module

+        // Main menu entries

+        $this->menu = array(); // List of menus to add

+        $r = 0;

+    }

+

+    /**

+     * 	Function called when module is enabled.

+     * 	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     * 	It also creates data directories

+     *

+     * 	@param      string	$options    Options when enabling module ('', 'noboxes')

+     * 	@return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $langs;

+

+        $this->_load_tables('/datapolicy/sql/');

+

+        // Create extrafields

+        include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

+        $extrafields = new ExtraFields($this->db);

+

+        /*

+        // Extrafield contact

+        $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0);

+        $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'thirdparty', 0, 0, '', '', 0, '', '0', 0);

+

+        // Extrafield Tiers

+        $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'contact', 0, 0, '', '', 1, '', '3', 0);

+        $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'contact', 0, 0, '', '', 0, '', '0', 0);

+

+        // Extrafield Adherent

+        $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');

+        $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0);

+        $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0);

+        */

+

+        $sql = array();

+

+        return $this->_init($sql, $options);

+    }

+

+    /**

+     * 	Function called when module is disabled.

+     * 	Remove from database constants, boxes and permissions from Dolibarr database.

+     * 	Data directories are not deleted

+     *

+     * 	@param      string	$options    Options when enabling module ('', 'noboxes')

+     * 	@return     int             	1 if OK, 0 if KO

+     */

+    public function remove($options = '')

+    {

+        $sql = array();

+

+        return $this->_remove($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modDebugBar.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDebugBar.class.php
@@ -24 +24 @@
- *  \brief     Description and activation file for the module debugbar

+ *  \brief      Description and activation file for module debugbar

@@ -34,8 +33,0 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

@@ -43 +35,8 @@
-		$this->numero = 43;

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

@@ -45 +44 @@
-		$this->rights_class = 'debugbar';

+        $this->numero = 43;

@@ -47,2 +46 @@
-		$this->family = "base";

-		$this->module_position = '75';

+        $this->rights_class = 'debugbar';

@@ -50,7 +48,2 @@
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "A tool for developper adding a debug bar in your browser.";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		$this->picto = 'bug';

+        $this->family = "base";

+        $this->module_position = '75';

@@ -58 +51,7 @@
-		$this->module_parts = array('moduleforexternal' => 0);

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "A tool for developper adding a debug bar in your browser.";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        $this->picto = 'bug';

@@ -60,2 +59 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        $this->module_parts = array('moduleforexternal' => 0);

@@ -63,3 +61,2 @@
-		// Dependencies

-		$this->depends = array(); // May be used for product or service or third party module

-		$this->requiredby = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -67,2 +64,3 @@
-		// Config pages

-		$this->config_page_url = array("debugbar.php");

+        // Dependencies

+        $this->depends = array(); // May be used for product or service or third party module

+        $this->requiredby = array();

@@ -70,4 +68,2 @@
-		// Constants

-		// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),

-		//							  1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );

-		$this->const = array();

+        // Config pages

+        $this->config_page_url = array("debugbar.php");

@@ -75,2 +71,4 @@
-		// Boxes

-		$this->boxes = array();

+        // Constants

+        // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),

+        //							  1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );

+        $this->const = array();

@@ -78,2 +76,2 @@
-		// Permissions

-		$this->rights = array();

+        // Boxes

+        $this->boxes = array();

@@ -81,6 +79,9 @@
-		$this->rights[1][0] = 431; // id de la permission

-		$this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission

-		$this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour)

-		$this->rights[1][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[1][4] = 'read';

-	}

+        // Permissions

+        $this->rights = array();

+

+        $this->rights[1][0] = 430; // id de la permission

+        $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission

+        $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour)

+        $this->rights[1][3] = 1; // La permission est-elle une permission par defaut

+        $this->rights[1][4] = 'read';

+    }

@@ -89,12 +90,12 @@
-	/**

-	 *      Function called when module is enabled.

-	 *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *      It also creates data directories.

-	 *

-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *      @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		// Permissions

-		$this->remove($options);

+    /**

+     *      Function called when module is enabled.

+     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *      It also creates data directories.

+     *

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        // Permissions

+        $this->remove($options);

@@ -102,2 +103,2 @@
-		$sql = array(

-		);

+        $sql = array(

+        );

@@ -105,2 +106,2 @@
-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modDeplacement.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDeplacement.class.php
@@ -24 +24 @@
- *	\brief      Description and activation file for the module trips (deprecated)

+ *	\brief      Fichier de description et activation du module Deplacement et notes de frais

@@ -33,0 +34 @@
+

@@ -47 +48 @@
-		$this->module_position = '43';

+		$this->module_position = '41';

@@ -82 +83 @@
-		$this->rights[1][3] = 0;

+		$this->rights[1][3] = 1;

@@ -91 +92 @@
-		$this->rights[3][0] = 173;

+    	$this->rights[3][0] = 173;

@@ -97 +98 @@
-		$this->rights[4][0] = 174;

+    	$this->rights[4][0] = 174;

@@ -122,4 +123,4 @@
-		$this->export_fields_array[$r] = array('u.login'=>'Login', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'd.rowid'=>"TripId", 'd.type'=>"Type", 'd.km'=>"FeesKilometersOrAmout", 'd.dated'=>"Date", 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 's.nom'=>'ThirdParty');

-		$this->export_TypeFields_array[$r] = array('u.rowid'=>'List:user:name', 'u.login'=>'Text', 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'd.type'=>"Text", 'd.km'=>"Numeric", 'd.dated'=>"Date", 'd.note_private'=>'Text', 'd.note_public'=>'Text', 's.rowid'=>"Numeric", 's.nom'=>'Text');

-		$this->export_entities_array[$r] = array('u.login'=>'user', 'u.lastname'=>'user', 'u.firstname'=>'user', 'd.rowid'=>"trip", 'd.type'=>"trip", 'd.km'=>"trip", 'd.dated'=>"trip", 'd.note_private'=>'trip', 'd.note_public'=>'trip', 's.nom'=>'company');

-		$this->export_dependencies_array[$r] = array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

+        $this->export_fields_array[$r] = array('u.login'=>'Login', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'd.rowid'=>"TripId", 'd.type'=>"Type", 'd.km'=>"FeesKilometersOrAmout", 'd.dated'=>"Date", 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 's.nom'=>'ThirdParty');

+        $this->export_TypeFields_array[$r] = array('u.rowid'=>'List:user:name', 'u.login'=>'Text', 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'd.type'=>"Text", 'd.km'=>"Numeric", 'd.dated'=>"Date", 'd.note_private'=>'Text', 'd.note_public'=>'Text', 's.rowid'=>"List:societe:CompanyName", 's.nom'=>'Text');

+        $this->export_entities_array[$r] = array('u.login'=>'user', 'u.lastname'=>'user', 'u.firstname'=>'user', 'd.rowid'=>"trip", 'd.type'=>"trip", 'd.km'=>"trip", 'd.dated'=>"trip", 'd.note_private'=>'trip', 'd.note_public'=>'trip', 's.nom'=>'company');

+        $this->export_dependencies_array[$r] = array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

@@ -131,3 +132 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -136,3 +135 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR d.fk_soc IS NULL)';

-		}

+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR d.fk_soc IS NULL)';

@@ -140,3 +137,4 @@
-		if (!empty($user)) {   // Not defined during migration process

-			$childids = $user->getAllChildIds();

-			$childids[] = $user->id;

+		if (!empty($user))   // Not defined during migration process

+		{

+    		$childids = $user->getAllChildIds();

+    		$childids[] = $user->id;

@@ -144,3 +142 @@
-			if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {

-				$this->export_sql_end[$r] .= ' AND d.fk_user IN ('.$this->db->sanitize(join(',', $childids)).')';

-			}

+    		if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $this->export_sql_end[$r] .= ' AND d.fk_user IN ('.join(',', $childids).')';

@@ -156 +152 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -161,5 +156,0 @@
-		$result = $this->_load_tables('/install/mysql/', 'deplacement');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modDocumentGeneration.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDocumentGeneration.class.php
@@ -25 +25 @@
- *	\brief      	Description and activation file for the module Generation document

+ *	\brief      	Fichier de description et activation du module Generation document

@@ -35,0 +36 @@
+

@@ -102,5 +103,5 @@
-	 *  @param      string  $options    Options when enabling module ('', 'noboxes')

-	 *  @return     int                 1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

+     *  @param      string  $options    Options when enabling module ('', 'noboxes')

+     *  @return     int                 1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modDon.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDon.class.php
@@ -26 +26 @@
- *	\brief      Description and activation file for the module Donation

+ *	\brief      Description and activation file for module Donation

@@ -36,0 +37 @@
+

@@ -123 +124 @@
-		$this->rights[1][3] = 0;

+		$this->rights[1][3] = 1;

@@ -150 +151 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -157,5 +157,0 @@
-		$result = $this->_load_tables('/install/mysql/', 'don');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

@@ -163,2 +159,2 @@
-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'donation' AND entity = ".((int) $conf->entity),

-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','donation',".((int) $conf->entity).")",

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'donation' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','donation',".$conf->entity.")",

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modDynamicPrices.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modDynamicPrices.class.php
@@ -23 +23 @@
- *  \brief      Description and activation file for the module to manage dynamic prices in products

+ *  \brief      File to describe module to manage dynamic prices in products

@@ -33 +33,2 @@
-	/**

+

+    /**

@@ -37,5 +38,5 @@
-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-		$this->numero = 2200;

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+        $this->numero = 2200;

@@ -43,5 +44,5 @@
-		$this->family = "products";

-		$this->module_position = '85';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable the usage of math expressions for prices";

+        $this->family = "products";

+        $this->module_position = '85';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable the usage of math expressions for prices";

@@ -49,5 +50,5 @@
-		$this->version = 'experimental';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'dynamicprice';

+        $this->version = 'experimental';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'dynamicprice';

@@ -55,2 +56,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -58,2 +59,2 @@
-		// Config pages

-		//-------------

+        // Config pages

+        //-------------

@@ -62,5 +63,5 @@
-		// Dependancies

-		//-------------

-		$this->depends = array();

-		$this->requiredby = array();

-		$this->langfiles = array("other");

+        // Dependancies

+        //-------------

+        $this->depends = array();

+        $this->requiredby = array();

+        $this->langfiles = array("other");

@@ -68,3 +69,3 @@
-		// Constants

-		//-----------

-		$this->const = array();

+        // Constants

+        //-----------

+        $this->const = array();

@@ -72,3 +73,3 @@
-		// New pages on tabs

-		// -----------------

-		$this->tabs = array();

+        // New pages on tabs

+        // -----------------

+        $this->tabs = array();

@@ -76,3 +77,3 @@
-		// Boxes

-		//------

-		$this->boxes = array();

+        // Boxes

+        //------

+        $this->boxes = array();

@@ -80,29 +81,6 @@
-		// Permissions

-		//------------

-		$this->rights = array();

-		$this->rights_class = 'dynamicprices';

-		$r = 0;

-	}

-

-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories.

-	 *

-	 *  @param      string  $options    Options

-	 *  @return     int                 1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		$result = $this->_load_tables('/install/mysql/', 'dynamicprices');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Remove permissions and default values

-		$this->remove($options);

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

+        // Permissions

+        //------------

+        $this->rights = array();

+        $this->rights_class = 'dynamicprices';

+        $r = 0;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modECM.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modECM.class.php
@@ -19,7 +19,5 @@
-/**

- *  \defgroup   ecm		Module ECM

- *  \brief      Module ECM (Electronic Content Management) to manage Documents

- *

- *  \file       htdocs/core/modules/modECM.class.php

- *  \ingroup    ecm

- *  \brief      Description and activation file for the module ECM

+/**     \defgroup   ecm		Module ecm

+ *      \brief      Module for ECM (Electronic Content Management)

+ *      \file       htdocs/core/modules/modECM.class.php

+ *      \ingroup    ecm

+ *      \brief      Description and activation file for module ECM

@@ -36,6 +34,7 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

+

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+    */

+    public function __construct($db)

@@ -62 +61 @@
-		$this->picto = 'folder-open';

+		$this->picto = 'folder';

@@ -77,0 +77,6 @@
+		$this->const[$r][0] = "ECM_AUTO_TREE_ENABLED";

+		$this->const[$r][1] = "chaine";

+		$this->const[$r][2] = "1";

+		$this->const[$r][3] = 'Auto tree is enabled by default';

+		$this->const[$r][4] = 0;

+

@@ -84,4 +89,4 @@
-		//$this->boxes[$r][1] = "myboxa.php";

-		//$r++;

-		//$this->boxes[$r][1] = "myboxb.php";

-		//$r++;

+        //$this->boxes[$r][1] = "myboxa.php";

+    	//$r++;

+        //$this->boxes[$r][1] = "myboxb.php";

+    	//$r++;

@@ -115 +120 @@
-		// Menus

+        // Menus

@@ -117 +122 @@
-		$this->menu = array(); // List of menus to add

+		$this->menus = array(); // List of menus to add

@@ -121,14 +126,11 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>0,

-			'type'=>'top',

-			'titre'=>'MenuECM',

-			'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth"'),

-			'mainmenu'=>'ecm',

-			'url'=>'/ecm/index.php',

-			'langs'=>'ecm',

-			'position'=>82,

-			'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup',

-			'enabled'=>'isModEnabled("ecm")',

-			'target'=>'',

-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both

-		);

+		$this->menu[$r] = array('fk_menu'=>0,

+							  'type'=>'top',

+							  'titre'=>'MenuECM',

+							  'mainmenu'=>'ecm',

+							  'url'=>'/ecm/index.php',

+							  'langs'=>'ecm',

+							  'position'=>82,

+							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup',

+							  'enabled'=>'$conf->ecm->enabled',

+							  'target'=>'',

+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

@@ -138,15 +140,12 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=ecm',

-			'type'=>'left',

-			'titre'=>'ECMArea',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

-			'mainmenu'=>'ecm',

-			'leftmenu'=>'ecm',

-			'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm',

-			'langs'=>'ecm',

-			'position'=>101,

-			'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

-			'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

-			'target'=>'',

-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both

-		);

+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm',

+							  'type'=>'left',

+							  'titre'=>'ECMArea',

+							  'mainmenu'=>'ecm',

+							  'leftmenu'=>'ecm',

+							  'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm',

+							  'langs'=>'ecm',

+							  'position'=>101,

+							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

+							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

+							  'target'=>'',

+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

@@ -155,14 +154,12 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',

-			'type'=>'left',

-			'titre'=>'ECMSectionsManual',

-			'mainmenu'=>'ecm',

-			'leftmenu'=>'ecm_manual',

-			'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',

-			'langs'=>'ecm',

-			'position'=>102,

-			'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

-			'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

-			'target'=>'',

-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both

-		);

+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',

+							  'type'=>'left',

+							  'titre'=>'ECMSectionsManual',

+							  'mainmenu'=>'ecm',

+							  'leftmenu'=>'ecm_manual',

+							  'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',

+							  'langs'=>'ecm',

+							  'position'=>102,

+							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

+							  'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

+							  'target'=>'',

+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

@@ -171,28 +168,11 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',

-			'type'=>'left',

-			'titre'=>'ECMSectionsAuto',

-			'mainmenu'=>'ecm',

-			'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',

-			'langs'=>'ecm',

-			'position'=>103,

-			'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

-			'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && !getDolGlobalInt("ECM_AUTO_TREE_HIDEN")',

-			'target'=>'',

-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both

-		);

-		$r++;

-

-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',

-			'type'=>'left',

-			'titre'=>'ECMSectionsMedias',

-			'mainmenu'=>'ecm',

-			'url'=>'/ecm/index_medias.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',

-			'langs'=>'ecm',

-			'position'=>104,

-			'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

-			'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && getDolGlobalInt("MAIN_FEATURES_LEVEL") == 2',

-			'target'=>'',

-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both

-		);

+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',

+							  'type'=>'left',

+							  'titre'=>'ECMSectionsAuto',

+							  'mainmenu'=>'ecm',

+							  'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',

+							  'langs'=>'ecm',

+							  'position'=>103,

+							  'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',

+							  'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)',

+							  'target'=>'',

+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modEmailCollector.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modEmailCollector.class.php
@@ -19,2 +19,2 @@
- * 	\defgroup   emailcollector     Module Emailcollector

- *  \brief      Module to collect emails

+ * 	\defgroup   emailcollector     Module emailcollector

+ *  \brief      emailcollector module descriptor.

@@ -24 +24 @@
- *  \brief      Description and activation file for the module emailcollector

+ *  \brief      Description and activation file for module emailcollector

@@ -41,3 +41,3 @@
-		global $langs, $conf;

-

-		$this->db = $db;

+        global $langs, $conf;

+

+        $this->db = $db;

@@ -55 +55 @@
-		$this->module_position = '23';

+		$this->module_position = '12';

@@ -93,0 +94,2 @@
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+		$this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module

@@ -109 +111,2 @@
-		if (!isset($conf->emailcollector) || !isset($conf->emailcollector->enabled)) {

+		if (!isset($conf->emailcollector) || !isset($conf->emailcollector->enabled))

+		{

@@ -116 +119 @@
-		$this->tabs = array();

+        $this->tabs = array();

@@ -119,4 +122,4 @@
-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

-		//

-		// Where objecttype can be

+        // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //

+        // Where objecttype can be

@@ -132 +135 @@
-		// 'order'            to add a tab in sales order view

+		// 'order'            to add a tab in customer order view

@@ -144 +147 @@
-		// Dictionaries

+        // Dictionaries

@@ -146,3 +149,17 @@
-

-

-		// Boxes/Widgets

+        /* Example:

+        $this->dictionaries=array(

+            'langs'=>'mylangfile@dav',

+            'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),		// List of tables we want to see into dictonnary editor

+            'tablib'=>array("Table1","Table2","Table3"),													// Label of tables

+            'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),	// Request to select fields

+            'tabsqlsort'=>array("label ASC","label ASC","label ASC"),																					// Sort order

+            'tabfield'=>array("code,label","code,label","code,label"),																					// List of fields (result of select to show dictionary)

+            'tabfieldvalue'=>array("code,label","code,label","code,label"),																				// List of fields (list of fields to edit a record)

+            'tabfieldinsert'=>array("code,label","code,label","code,label"),																			// List of fields (list of fields for insert)

+            'tabrowid'=>array("rowid","rowid","rowid"),																									// Name of columns with primary key (try to always name it 'rowid')

+            'tabcond'=>array($conf->dav->enabled,$conf->dav->enabled,$conf->dav->enabled)												// Condition to show each dictionary

+        );

+        */

+

+

+        // Boxes/Widgets

@@ -150,5 +167,5 @@
-		$this->boxes = array(

-			//0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'),

-			//1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'),

-			//2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav')

-		);

+        $this->boxes = array(

+        	//0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'),

+        	//1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'),

+        	//2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav')

+        );

@@ -160 +177 @@
-			0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'isModEnabled("emailcollector")')

+			0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'$conf->emailcollector->enabled')

@@ -166,0 +184,23 @@
+		/*

+		$r=0;

+		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)

+		$this->rights[$r][1] = 'Read myobject of dav';	// Permission label

+		$this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

+		$this->rights[$r][4] = 'read';				// In php code, permission will be checked by test if ($user->rights->dav->level1->level2)

+		$this->rights[$r][5] = '';				    // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)

+

+		$r++;

+		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)

+		$this->rights[$r][1] = 'Create/Update myobject of dav';	// Permission label

+		$this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

+		$this->rights[$r][4] = 'write';				// In php code, permission will be checked by test if ($user->rights->dav->level1->level2)

+		$this->rights[$r][5] = '';				    // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)

+

+		$r++;

+		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)

+		$this->rights[$r][1] = 'Delete myobject of dav';	// Permission label

+		$this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

+		$this->rights[$r][4] = 'delete';				// In php code, permission will be checked by test if ($user->rights->dav->level1->level2)

+		$this->rights[$r][5] = '';				    // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)

+		*/

+

@@ -169 +208,0 @@
-

@@ -171,11 +210,45 @@
-		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'type'=>'left', // This is a Left menu entry

-			'titre'=>'EmailCollectors',

-			'url'=>'/admin/emailcollector_list.php?leftmenu=admintools',

-			'langs'=>'admin', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>400,

-			'enabled'=>'isModEnabled("emailcollector") && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'$user->admin', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-			'target'=>'',

-			'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

-		$r++;

+

+		// Add here entries to declare new menus

+

+		/* BEGIN MODULEBUILDER TOPMENU */

+		/*$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+								'type'=>'top',			                // This is a Top menu entry

+								'titre'=>'dav',

+								'mainmenu'=>'dav',

+								'leftmenu'=>'',

+								'url'=>'/dav/davindex.php',

+								'langs'=>'dav@dav',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+								'position'=>1000+$r,

+								'enabled'=>'$conf->dav->enabled',	// Define condition to show or hide menu entry. Use '$conf->dav->enabled' if entry must be visible if module is enabled.

+								'perms'=>'1',			                // Use 'perms'=>'$user->rights->dav->level1->level2' if you want your menu with a permission rules

+								'target'=>'',

+								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both

+		*/

+		/* END MODULEBUILDER TOPMENU */

+

+		/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT

+		$this->menu[$r++]=array(	'fk_menu'=>'fk_mainmenu=dav',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+								'type'=>'left',			                // This is a Left menu entry

+								'titre'=>'List MyObject',

+								'mainmenu'=>'dav',

+								'leftmenu'=>'dav_myobject_list',

+								'url'=>'/dav/myobject_list.php',

+								'langs'=>'dav@dav',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+								'position'=>1000+$r,

+								'enabled'=>'$conf->dav->enabled',  // Define condition to show or hide menu entry. Use '$conf->dav->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+								'perms'=>'1',			                // Use 'perms'=>'$user->rights->dav->level1->level2' if you want your menu with a permission rules

+								'target'=>'',

+								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both

+		$this->menu[$r++]=array(	'fk_menu'=>'fk_mainmenu=dav,fk_leftmenu=dav',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+								'type'=>'left',			                // This is a Left menu entry

+								'titre'=>'New MyObject',

+								'mainmenu'=>'dav',

+								'leftmenu'=>'dav_myobject_new',

+								'url'=>'/dav/myobject_page.php?action=create',

+								'langs'=>'dav@dav',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+								'position'=>1000+$r,

+								'enabled'=>'$conf->dav->enabled',  // Define condition to show or hide menu entry. Use '$conf->dav->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+								'perms'=>'1',			                // Use 'perms'=>'$user->rights->dav->level1->level2' if you want your menu with a permission rules

+								'target'=>'',

+								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both

+		END MODULEBUILDER LEFTMENU MYOBJECT */

@@ -189 +262 @@
-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')

+     *	@param      string	$options    Options when enabling module ('', 'noboxes')

@@ -194,2 +267,11 @@
-		global $conf, $user, $langs;

-		$langs->load("admin");

+		global $conf, $user;

+		//$this->_load_tables('/dav/sql/');

+

+		// Create extrafields

+		//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

+		//$extrafields = new ExtraFields($this->db);

+		//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');

+		//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');

+		//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');

+		//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1 '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');

+		//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');

@@ -199 +281 @@
-		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity;

+		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity;

@@ -203,2 +285,2 @@
-				$descriptionA1 = $langs->trans('EmailCollectorExampleToCollectTicketRequestsDesc');

-				$label = $langs->trans('EmailCollectorExampleToCollectTicketRequests');

+				$descriptionA1 = 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated.';

+				$descriptionA1 .= ' If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.';

@@ -206,12 +288,7 @@
-				$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requests', '".$this->db->escape($label)."', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";

-

-				$sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				//$sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				//$sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				$sqlforexampleFilterA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sqlforexampleActionA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleActionA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

+				$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";

+				$sqlforexampleA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

+				$sqlforexampleA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sqlforexampleA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";

+				$sqlforexampleA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sqlforexampleA4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";

+				$sqlforexampleA4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

@@ -219,6 +296,3 @@
-

-				$sql[] = $sqlforexampleFilterA1;

-				//$sql[] = $sqlforexampleFilterA2;

-				$sql[] = $sqlforexampleFilterA3;

-

-				$sql[] = $sqlforexampleActionA1;

+				$sql[] = $sqlforexampleA2;

+				$sql[] = $sqlforexampleA3;

+				$sql[] = $sqlforexampleA4;

@@ -226,5 +300,3 @@
-		} else {

-			dol_print_error($this->db);

-		}

-

-		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity;

+		} else dol_print_error($this->db);

+

+		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity;

@@ -234,19 +306,10 @@
-				$descriptionA1 = $langs->trans('EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware');

-				$label = $langs->trans('EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware');

-				$sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";

-				$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Responses_Out', '".$this->db->escape($label)."', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";

-

-				$sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'isanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				$sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'withouttrackingidinmsgid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sqlforexampleActionA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleActionA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'recordevent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sql[] = $sqlforexampleA1;

-

-				$sql[] = $sqlforexampleFilterA1;

-				$sql[] = $sqlforexampleFilterA2;

-

-				$sql[] = $sqlforexampleActionA1;

+				$descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event with the email response will be recorded at the good place (Module Agenda must be enabled). For example, if your send a commercial proposal, order or invoice by email and your customer answers your email, the system will automatically find the answer and add it into your ERP.';

+				$sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";

+				$sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses', 'Example to collect any email responses', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";

+				$sqlforexampleB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

+				$sqlforexampleB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'withtrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sqlforexampleB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";

+				$sqlforexampleB3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'recordevent', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sql[] = $sqlforexampleB1;

+				$sql[] = $sqlforexampleB2;

+				$sql[] = $sqlforexampleB3;

@@ -254,3 +317,3 @@
-		}

-

-		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity);

+		} else dol_print_error($this->db);

+

+		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity;

@@ -260,16 +323,15 @@
-				$descriptionB1 = $langs->trans('EmailCollectorExampleToCollectDolibarrAnswersDesc');

-				$label = $langs->trans('EmailCollectorExampleToCollectDolibarrAnswers');

-				$sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";

-				$sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses_In', '".$this->db->escape($label)."', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";

-

-				$sqlforexampleFilterB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity)."), 'isanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sqlforexampleActionB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleActionB3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity)."), 'recordevent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sql[] = $sqlforexampleB1;

-

-				$sql[] = $sqlforexampleFilterB2;

-

-				$sql[] = $sqlforexampleActionB3;

+				$descriptionC1 = "This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated.";

+				$descriptionC1 .= " If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.<br>";

+				$descriptionC1 .= "Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1.";

+				$sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";

+				$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";

+				$sqlforexampleC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

+				$sqlforexampleC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sqlforexampleC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";

+				$sqlforexampleC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sqlforexampleC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)";

+				$sqlforexampleC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'project', 'tmp_from=EXTRACT:HEADER:^From:(.*);socid=SETIFEMPTY:1;usage_opportunity=SET:1;description=EXTRACT:BODY:(.*);title=SET:Lead or message from __tmp_from__ received by email', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";

+				$sql[] = $sqlforexampleC1;

+				$sql[] = $sqlforexampleC2;

+				$sql[] = $sqlforexampleC3;

+				$sql[] = $sqlforexampleC4;

@@ -277,67 +339 @@
-		} else {

-			dol_print_error($this->db);

-		}

-

-		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity);

-		$tmpresql = $this->db->query($tmpsql);

-		if ($tmpresql) {

-			if ($this->db->num_rows($tmpresql) == 0) {

-				$descriptionC1 = $langs->trans("EmailCollectorExampleToCollectLeadsDesc");

-				$label = $langs->trans('EmailCollectorExampleToCollectLeads');

-				$sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";

-				$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', '".$this->db->escape($label)."', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";

-

-				$sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				//$sqlforexampleFilterC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				//$sqlforexampleFilterC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				$sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$paramstring = 'tmp_from=EXTRACT:HEADER:^From:(.*)'."\n".'socid=SETIFEMPTY:1'."\n".'usage_opportunity=SET:1'."\n".'description=EXTRACT:BODY:(.*)'."\n".'title=SET:Lead or message from __tmp_from__ received by email';

-				$sqlforexampleActionC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)";

-				$sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'project', '".$this->db->escape($paramstring)."', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sql[] = $sqlforexampleC1;

-

-				$sql[] = $sqlforexampleFilterC1;

-				//$sql[] = $sqlforexampleFilterC2;

-				$sql[] = $sqlforexampleFilterC3;

-

-				$sql[] = $sqlforexampleActionC4;

-			}

-		} else {

-			dol_print_error($this->db);

-		}

-

-		$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity);

-		$tmpresql = $this->db->query($tmpsql);

-		if ($tmpresql) {

-			if ($this->db->num_rows($tmpresql) == 0) {

-				$descriptionC1 = $langs->trans("EmailCollectorExampleToCollectJobCandidaturesDesc");

-				$label = $langs->trans('EmailCollectorExampleToCollectJobCandidatures');

-				$sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";

-				$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Candidatures', '".$this->db->escape($label)."', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";

-

-				$sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				//$sqlforexampleFilterC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

-				//$sqlforexampleFilterC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-				$sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";

-				$sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'to', 'jobs@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$paramstring = 'tmp_from=EXTRACT:HEADER:^From:(.*)(<.*>)?'."\n".'fk_recruitmentjobposition=EXTRACT:HEADER:^To:[^\n]*\+([^\n]*)'."\n".'description=EXTRACT:BODY:(.*)'."\n".'lastname=SET:__tmp_from__';

-				$sqlforexampleActionC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)";

-				$sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'candidature', '".$this->db->escape($paramstring)."', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";

-

-				$sql[] = $sqlforexampleC1;

-

-				$sql[] = $sqlforexampleFilterC1;

-				//$sql[] = $sqlforexampleFilterC2;

-				$sql[] = $sqlforexampleFilterC3;

-

-				$sql[] = $sqlforexampleActionC4;

-			}

-		} else {

-			dol_print_error($this->db);

-		}

+		} else dol_print_error($this->db);

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modExpedition.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExpedition.class.php
@@ -23,6 +23,5 @@
- *  \defgroup   expedition     Module Shipping

- *  \brief      Module to manage product shipments

- *

- *  \file       htdocs/core/modules/modExpedition.class.php

- *  \ingroup    expedition

- *  \brief      Description and activation file for the module Expedition

+ *	\defgroup   expedition     Module shipping

+ *	\brief      Module pour gerer les expeditions de produits

+ *	\file       htdocs/core/modules/modExpedition.class.php

+ *	\ingroup    expedition

+ *	\brief      Fichier de description et activation du module Expedition

@@ -66,3 +65,3 @@
-							"/expedition/sending/temp",

-							"/expedition/receipt",

-							"/expedition/receipt/temp",

+		                    "/expedition/sending/temp",

+		                    "/expedition/receipt",

+		                    "/expedition/receipt/temp",

@@ -71 +70 @@
-							);

+		                    );

@@ -74 +73 @@
-		$this->config_page_url = array("expedition.php");

+		$this->config_page_url = array("confexped.php");

@@ -88 +87 @@
-		$this->const[$r][2] = "espadon";

+		$this->const[$r][2] = "rouget";

@@ -107,3 +106,3 @@
-		$this->const[$r][0] = "DELIVERY_ADDON_PDF";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "storm";

+		$this->const[$r][0] = "LIVRAISON_ADDON_PDF";

+		$this->const[$r][1] = "chaine";

+		$this->const[$r][2] = "typhon";

@@ -114,3 +113,3 @@
-		$this->const[$r][0] = "DELIVERY_ADDON_NUMBER";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "mod_delivery_jade";

+		$this->const[$r][0] = "LIVRAISON_ADDON_NUMBER";

+		$this->const[$r][1] = "chaine";

+		$this->const[$r][2] = "mod_livraison_jade";

@@ -121 +120 @@
-		$this->const[$r][0] = "DELIVERY_ADDON_PDF_ODT_PATH";

+		$this->const[$r][0] = "LIVRAISON_ADDON_PDF_ODT_PATH";

@@ -173 +172 @@
-		$this->rights[$r][5] = 'send';

+        $this->rights[$r][5] = 'send';

@@ -195 +194 @@
-		$this->rights[$r][4] = 'delivery';

+		$this->rights[$r][4] = 'livraison';

@@ -203 +202 @@
-		$this->rights[$r][4] = 'delivery';

+		$this->rights[$r][4] = 'livraison';

@@ -211 +210 @@
-		$this->rights[$r][4] = 'delivery_advance';

+		$this->rights[$r][4] = 'livraison_advance';

@@ -219 +218 @@
-		$this->rights[$r][4] = 'delivery';

+		$this->rights[$r][4] = 'livraison';

@@ -249 +248 @@
-			's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation",  'c.date_valid'=>"DateValidation",

+			's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation",

@@ -255,3 +254 @@
-		if ($idcontacts && getDolGlobalString('SHIPMENT_ADD_CONTACTS_IN_EXPORT')) {

-			$this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');

-		}

+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');

@@ -259 +256 @@
-		//	's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',

+		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',

@@ -266 +263 @@
-			's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date", 'c.date_valid'=>"Date",

+			's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date",

@@ -274 +271 @@
-			'c.date_creation'=>"shipment", 'c.date_valid'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment",

+			'c.date_creation'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment",

@@ -279,2 +276,6 @@
-		if ($idcontacts && getDolGlobalString('SHIPMENT_ADD_CONTACTS_IN_EXPORT')) {

-			$this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');

+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');

+		$this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))

+		{

+		    $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3';

+		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

@@ -282,10 +283 @@
-		$this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

-		if ($idcontacts && getDolGlobalString('SHIPMENT_ADD_CONTACTS_IN_EXPORT')) {

-			$keyforselect = 'socpeople';

-			$keyforelement = 'contact';

-			$keyforaliasextra = 'extra3';

-			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		}

-		$keyforselect = 'expedition';

-		$keyforelement = 'shipment';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra';

@@ -293,3 +285 @@
-		$keyforselect = 'expeditiondet';

-		$keyforelement = 'shipment_line';

-		$keyforaliasextra = 'extra2';

+		$keyforselect = 'expeditiondet'; $keyforelement = 'shipment_line'; $keyforaliasextra = 'extra2';

@@ -297,3 +287 @@
-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extraprod';

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extraprod';

@@ -306,3 +294 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -316,4 +302,4 @@
-		if ($idcontacts && getDolGlobalString('SHIPMENT_ADD_CONTACTS_IN_EXPORT')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$this->db->sanitize($idcontacts).')';

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';

+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';

@@ -323,3 +309 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

-		}

+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

@@ -334 +318 @@
-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -349 +333,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -353 +338,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -363,6 +349,4 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'shipping' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'shipping', ".((int) $conf->entity).")",

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'delivery' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."', 'delivery', ".((int) $conf->entity).")",

-			//"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name IN ('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') AND entity = ".((int) $conf->entity),

-			//"INSERT INTO ".MAIN_DB_PREFIX."const (name, value, entity) VALUES ('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', 1, ".((int) $conf->entity).")"

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'shipping' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','shipping',".$conf->entity.")",

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'delivery' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','delivery',".$conf->entity.")",

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modExpenseReport.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExpenseReport.class.php
@@ -2,3 +2,2 @@
-/* Copyright (C) 2011  Dimitri Mouillard    <dmouillard@teclib.com>

- * Copyright (C) 2015  Laurent Destailleur  <eldy@users.sourceforge.net>

- * Copyright (C) 2023  Alexandre Spangaro   <aspangaro@easya.solutions>

+/* Copyright (C) 2011 Dimitri Mouillard   <dmouillard@teclib.com>

+ * Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>

@@ -25 +24 @@
- *      \brief      Description and activation file for the module ExpenseReport

+ *      \brief      Description and activation file for module ExpenseReport

@@ -69 +68 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -184 +183 @@
-		$this->export_fields_array[$r] = array(

+        $this->export_fields_array[$r] = array(

@@ -187,4 +186,3 @@
-			'd.fk_statut'=>'Status', 'd.paid'=>'Paid',

-			'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 'd.detail_cancel'=>'MOTIF_CANCEL', 'd.detail_refuse'=>'MOTIF_REFUS',

-			'ed.rowid'=>'LineId', 'tf.code'=>'Type', 'ed.date'=>'Date', 'ed.tva_tx'=>'VATRate',

-			'ed.qty'=>"Quantity", 'ed.value_unit'=>"UnitPriceHT",

+        	'd.fk_statut'=>'Status', 'd.paid'=>'Paid',

+        	'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 'd.detail_cancel'=>'MOTIF_CANCEL', 'd.detail_refuse'=>'MOTIF_REFUS',

+			'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login", 'ed.rowid'=>'LineId', 'tf.code'=>'Type', 'ed.date'=>'Date', 'ed.tva_tx'=>'VATRate',

@@ -192,3 +190,2 @@
-			'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login",

-			'user_rib.iban_prefix' => 'IBAN', 'user_rib.bic' => 'BIC', 'user_rib.code_banque' => 'BankCode', 'user_rib.bank' => 'BankName', 'user_rib.proprio' => 'BankAccountOwner',

-			'user_rib.owner_address' => 'BankAccountOwnerAddress'

+            'user_rib.iban_prefix' => 'IBAN', 'user_rib.bic' => 'BIC', 'user_rib.code_banque' => 'BankCode', 'user_rib.bank' => 'BankName', 'user_rib.proprio' => 'BankAccountOwner',

+            'user_rib.owner_address' => 'BankAccountOwnerAddress'

@@ -196,15 +193,12 @@
-		$this->export_TypeFields_array[$r] = array(

-			'd.rowid'=>'Numeric', 'd.ref'=>'Text', 'd.date_debut'=>'Date', 'd.date_fin'=>'Date', 'd.date_create'=>'Date', 'd.date_approve'=>'Date',

-			'd.total_ht'=>"Numeric", 'd.total_tva'=>'Numeric', 'd.total_ttc'=>'Numeric',

-			'd.fk_statut'=>"Numeric", 'd.paid'=>'Numeric',

-			'd.note_private'=>'Text', 'd.note_public'=>'Text', 'd.detail_cancel'=>'Text', 'd.detail_refuse'=>'Text',

-			'ed.rowid'=>'Numeric', 'tf.code'=>'Code', 'ed.date'=>'Date', 'ed.tva_tx'=>'Numeric',

-			'ed.qty'=>'Numeric', 'ed.value_unit'=>'Numeric',

-			'ed.total_ht'=>'Numeric', 'ed.total_tva'=>'Numeric', 'ed.total_ttc'=>'Numeric', 'ed.comments'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text',

-			'u.lastname'=>'Text', 'u.firstname'=>'Text', 'u.login'=>"Text",

-			'user_rib.iban_prefix' => 'Text', 'user_rib.bic' => 'Text', 'user_rib.code_banque' => 'Text', 'user_rib.bank' => 'Text', 'user_rib.proprio' => 'Text',

-			'user_rib.owner_address' => 'Text'

-		);

-		$this->export_entities_array[$r] = array(

-			'ed.rowid'=>'expensereport_line', 'ed.date'=>'expensereport_line',

-			'ed.qty'=>'expensereport_line', 'ed.value_unit'=>'expensereport_line',

+        $this->export_TypeFields_array[$r] = array(

+        	'd.rowid'=>"Numeric", 'd.ref'=>'Text', 'd.date_debut'=>'Date', 'd.date_fin'=>'Date', 'd.date_create'=>'Date', 'd.date_approve'=>'Date',

+        	'd.total_ht'=>"Numeric", 'd.total_tva'=>'Numeric', 'd.total_ttc'=>'Numeric',

+        	'd.fk_statut'=>"Numeric", 'd.paid'=>'Numeric',

+        	'd.note_private'=>'Text', 'd.note_public'=>'Text', 'd.detail_cancel'=>'Text', 'd.detail_refuse'=>'Text',

+        	'u.lastname'=>'Text', 'u.firstname'=>'Text', 'u.login'=>"Text", 'ed.rowid'=>'Numeric', 'tf.code'=>'Code', 'ed.date'=>'Date', 'ed.tva_tx'=>'Numeric',

+        	'ed.total_ht'=>'Numeric', 'ed.total_tva'=>'Numeric', 'ed.total_ttc'=>'Numeric', 'ed.comments'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text',

+            'user_rib.iban_prefix' => 'Text', 'user_rib.bic' => 'Text', 'user_rib.code_banque' => 'Text', 'user_rib.bank' => 'Text', 'user_rib.proprio' => 'Text',

+            'user_rib.owner_address' => 'Text'

+        );

+        $this->export_entities_array[$r] = array(

+			'u.lastname'=>'user', 'u.firstname'=>'user', 'u.login'=>'user', 'ed.rowid'=>'expensereport_line', 'ed.date'=>'expensereport_line',

@@ -213,3 +207,2 @@
-			'u.lastname'=>'user', 'u.firstname'=>'user', 'u.login'=>'user',

-			'user_rib.iban_prefix' => 'user', 'user_rib.bic' => 'user', 'user_rib.code_banque' => 'user', 'user_rib.bank' => 'user', 'user_rib.proprio' => 'user',

-			'user_rib.owner_address' => 'user'

+            'user_rib.iban_prefix' => 'user', 'user_rib.bic' => 'user', 'user_rib.code_banque' => 'user', 'user_rib.bank' => 'user', 'user_rib.proprio' => 'user',

+            'user_rib.owner_address' => 'user'

@@ -218 +211 @@
-		//$this->export_alias_array[$r] = array('d.rowid'=>"idtrip", 'd.type'=>"type", 'd.note_private'=>'note_private', 'd.note_public'=>'note_public', 'u.lastname'=>'name', 'u.firstname'=>'firstname', 'u.login'=>'login');

+        $this->export_alias_array[$r] = array('d.rowid'=>"idtrip", 'd.type'=>"type", 'd.note_private'=>'note_private', 'd.note_public'=>'note_public', 'u.lastname'=>'name', 'u.firstname'=>'firstname', 'u.login'=>'login');

@@ -221,7 +214 @@
-		$keyforselect = 'expensereport';

-		$keyforelement = 'expensereport';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$keyforselect = 'user';

-		$keyforelement = 'user';

-		$keyforaliasextra = 'extrau';

+		$keyforselect = 'expensereport'; $keyforelement = 'expensereport'; $keyforaliasextra = 'extra';

@@ -234,2 +221 @@
-		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'user as u';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extrau ON u.rowid = extrau.fk_object,';

+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'user as u,';

@@ -254,5 +239,0 @@
-		$result = $this->_load_tables('/install/mysql/', 'expensereport');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

@@ -263,2 +244,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard' AND type='expensereport' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','expensereport',".((int) $conf->entity).")"

+				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard' AND type='expensereport' AND entity = ".$conf->entity,

+				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','expensereport',".$conf->entity.")"

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modExternalRss.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExternalRss.class.php
@@ -24 +24 @@
- *	\brief      Description and activation file for the module externalrss

+ *	\brief      Fichier de description et activation du module externalrss

@@ -34,0 +35 @@
+

@@ -65 +66 @@
-		$this->phpmin = array(7, 0);

+		$this->phpmin = array(4, 2, 0);

@@ -85 +86 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -100,4 +101,6 @@
-		if ($result) {

-			while ($obj = $this->db->fetch_object($result)) {

-				$reg = array();

-				if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg)) {

+		if ($result)

+		{

+			while ($obj = $this->db->fetch_object($result))

+			{

+				if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg))

+				{

@@ -118 +121 @@
-	/**

+    /**

@@ -123 +126 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -125,3 +128,3 @@
-	 */

-	public function remove($options = '')

-	{

+     */

+    public function remove($options = '')

+    {

@@ -134 +137 @@
-	}

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modExternalSite.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modExternalSite.class.php
@@ -25 +25 @@
- * \brief      Description and activation file for the module ExternalSite

+ * \brief      Description and activation file for module ExternalSite

@@ -36 +36,2 @@
-	/**

+

+    /**

@@ -40 +41 @@
-	 */

+     */

@@ -61 +62 @@
-		$this->picto = 'website';

+		$this->picto = 'bookmark';

@@ -69 +70 @@
-		$this->config_page_url = array("index.php@externalsite");

+		$this->config_page_url = array("externalsite.php@externalsite");

@@ -88,4 +89,4 @@
-		//$this->boxes[$r][1] = "myboxa.php";

-		//$r++;

-		//$this->boxes[$r][1] = "myboxb.php";

-		//$r++;

+        //$this->boxes[$r][1] = "myboxa.php";

+    	//$r++;

+        //$this->boxes[$r][1] = "myboxb.php";

+    	//$r++;

@@ -97 +98 @@
-		// Menus

+        // Menus

@@ -105 +105,0 @@
-			'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth em092"'),

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modFTP.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFTP.class.php
@@ -24 +24 @@
- *      \brief      Description and activation file for the module FTP

+ *      \brief      Description and activation file for module FTP

@@ -35,5 +35,6 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

+

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+    */

@@ -56 +57 @@
-		$this->version = 'dolibarr_deprecated';

+		$this->version = 'dolibarr';

@@ -60 +61 @@
-		$this->picto = 'folder';

+		$this->picto = 'dir';

@@ -77,2 +78,2 @@
-			1=>array('FTP_CONNECT_WITH_SSL', 'chaine', '0', 'Use FTPS for FTP module', 1, 'current', 1),

-			2=>array('FTP_CONNECT_WITH_SFTP', 'chaine', '0', 'Use SFTP for FTP module', 1, 'current', 1)

+		    1=>array('FTP_CONNECT_WITH_SSL', 'chaine', '0', 'Use FTPS for FTP module', 1, 'current', 1),

+		    2=>array('FTP_CONNECT_WITH_SFTP', 'chaine', '0', 'Use SFTP for FTP module', 1, 'current', 1)

@@ -87,4 +88,4 @@
-		//$this->boxes[$r][1] = "myboxa.php";

-		//$r++;

-		//$this->boxes[$r][1] = "myboxb.php";

-		//$r++;

+        //$this->boxes[$r][1] = "myboxa.php";

+    	//$r++;

+        //$this->boxes[$r][1] = "myboxb.php";

+    	//$r++;

@@ -116 +116,0 @@
-							  'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth em092"'),

@@ -121,2 +121,2 @@
-							  'enabled'=>'$conf->ftp->enabled',

-							  'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup',

+                              'enabled'=>'$conf->ftp->enabled',

+		                      'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup',

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modFacture.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFacture.class.php
@@ -7,3 +6,0 @@
- * Copyright (C) 2021		Alexandre Spangaro		<aspangaro@open-dsi.fr>

- * Copyright (C) 2022       Frédéric France         <frederic.france@netlogic.fr>

- * Copyright (C) 2024		William Mead			<william.mead@manchenumerique.fr>

@@ -26,2 +23,2 @@
- * 		\defgroup   facture     Module customer invoices

- *      \brief      Module to manage customer invoices

+ * 		\defgroup   facture     Module invoices

+ *      \brief      Module pour gerer les factures clients et/ou fournisseurs

@@ -30 +27 @@
- *		\brief      Description and activation file for the module customer invoices

+ *		\brief      Fichier de la classe de description et activation du module Facture

@@ -39,0 +37 @@
+

@@ -47 +45 @@
-		global $conf, $user, $mysoc;

+		global $conf, $user;

@@ -91 +89 @@
-		$this->const[$r][2] = "sponge";

+		$this->const[$r][2] = "crabe";

@@ -102,0 +101,8 @@
+		/*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK";

+		$this->const[$r][1] = "chaine";

+		$this->const[$r][2] = "__(Draft)__";

+		$this->const[$r][3] = 'Watermark to show on draft invoices';

+		$this->const[$r][4] = 0;

+		$r++;*/

+

+

@@ -108,2 +114 @@
-				2=>array('file'=>'box_graph_invoices_permonth.php', 'enabledbydefaulton'=>'Home'),

-				3=>array('file'=>'box_customers_outstanding_bill_reached.php', 'enabledbydefaulton'=>'Home')

+				2=>array('file'=>'box_graph_invoices_permonth.php', 'enabledbydefaulton'=>'Home')

@@ -116,30 +121 @@
-			0 => array(

-				'label'=>'RecurringInvoicesJob',

-				'jobtype'=>'method',

-				'class'=>'compta/facture/class/facture-rec.class.php',

-				'objectname'=>'FactureRec',

-				'method'=>'createRecurringInvoices',

-				'parameters'=>'',

-				'comment'=>'Generate recurring invoices',

-				'frequency'=>1,

-				'unitfrequency'=>3600 * 24,

-				'priority'=>51,

-				'status'=>1,

-				'test'=>'$conf->facture->enabled',

-				'datestart'=>$datestart

-			),

-			1 => array(

-				'label'=>'SendEmailsRemindersOnInvoiceDueDate',

-				'jobtype'=>'method',

-				'class'=>'compta/facture/class/facture.class.php',

-				'objectname'=>'Facture',

-				'method'=>'sendEmailsRemindersOnInvoiceDueDate',

-				'parameters'=>"10,all,EmailTemplateCode,duedate",

-				'comment'=>'Send an email when we reach the invoice due date (or invoice date) - n days. First param is n, the number of days before due date (or invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the invoice to use.',

-				'frequency'=>1,

-				'unitfrequency'=>3600 * 24,

-				'priority'=>50,

-				'status'=>0,

-				'test'=>'$conf->facture->enabled',

-				'datestart'=>$datestart

-			),

+			0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart),

@@ -173 +149 @@
-		$this->rights[$r][4] = 'invoice_advance';

+        $this->rights[$r][4] = 'invoice_advance';

@@ -190 +166 @@
-		$this->rights[$r][5] = 'send';

+        $this->rights[$r][5] = 'send';

@@ -228 +204 @@
-		// Imports

+		// Exports

@@ -232,266 +207,0 @@
-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = "Invoices"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('f' => MAIN_DB_PREFIX.'facture', 'extra' => MAIN_DB_PREFIX.'facture_extrafields');

-		$this->import_tables_creator_array[$r] = array('f' => 'fk_user_author'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'f.ref' => 'InvoiceRef*',

-			'f.ref_ext' => 'ExternalRef',

-			'f.ref_client' => 'RefCustomer',

-			'f.type' => 'Type*',

-			'f.fk_soc' => 'Customer*',

-			'f.datec' => 'InvoiceDateCreation',

-			'f.datef' => 'DateInvoice',

-			'f.date_valid' => 'Validation Date',

-			'f.paye' => 'InvoicePaid',

-			'f.total_tva' => 'TotalVAT',

-			'f.total_ht' => 'TotalHT',

-			'f.total_ttc' => 'TotalTTC',

-			'f.fk_statut' => 'InvoiceStatus',

-			'f.fk_user_modif' => 'Modifier Id',

-			'f.fk_user_valid' => 'Validator Id',

-			'f.fk_user_closing' => 'Closer Id',

-			'f.fk_facture_source' => 'Invoice Source Id',

-			'f.fk_projet' => 'Project Id',

-			'f.fk_account' => 'Bank Account',

-			'f.fk_currency' => 'Currency*',

-			'f.fk_cond_reglement' => 'PaymentTerm',

-			'f.fk_mode_reglement' => 'PaymentMode',

-			'f.date_lim_reglement' => 'DateMaxPayment',

-			'f.note_public' => 'InvoiceNote',

-			'f.note_private' => 'NotePrivate',

-			'f.model_pdf' => 'Model'

-		);

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['f.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture');

-		$this->import_regex_array[$r] = array('f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency');

-		$import_sample = array(

-			'f.ref' => '(PROV0001)',

-			'f.ref_ext' => '',

-			'f.ref_client' => '',

-			'f.type' => '0',

-			'f.fk_soc' => '80LIMIT',

-			'f.datec' => '2021-11-24',

-			'f.datef' => '2021-11-24',

-			'f.date_valid' => '2021-11-24',

-			'f.paye' => '1',

-			'f.total_tva' => '21',

-			'f.total_ht' => '100',

-			'f.total_ttc' => '121',

-			'f.fk_statut' => '1',

-			'f.fk_user_modif' => '',

-			'f.fk_user_valid' => '',

-			'f.fk_user_closing' => '',

-			'f.fk_facture_source' => '',

-			'f.fk_projet' => '',

-			'f.fk_account' => '',

-			'f.fk_currency' => 'EUR',

-			'f.fk_cond_reglement' => '30D',

-			'f.fk_mode_reglement' => 'VIR',

-			'f.date_lim_reglement' => '2021-12-24',

-			'f.note_public' => '',

-			'f.note_private' => '',

-			'f.model_pdf' => 'sponge',

-			'f.multicurrency_code' => 'EUR',

-			'f.multicurrency_tx' => '1',

-			'f.multicurrency_total_ht' => '100',

-			'f.multicurrency_total_tva' => '21',

-			'f.multicurrency_total_ttc' => '121'

-		);

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('f.ref' => 'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'f.fk_soc' => array(

-				'rule' => 'fetchidfromref',

-				'file' => '/societe/class/societe.class.php',

-				'class' => 'Societe',

-				'method' => 'fetch',

-				'element' => 'ThirdParty'

-			),

-			'f.fk_projet' => array(

-				'rule' => 'fetchidfromref',

-				'file' => '/projet/class/project.class.php',

-				'class' => 'Project',

-				'method' => 'fetch',

-				'element' => 'facture'

-			),

-			'f.fk_cond_reglement' => array(

-				'rule' => 'fetchidfromcodeorlabel',

-				'file' => '/compta/facture/class/paymentterm.class.php',

-				'class' => 'PaymentTerm',

-				'method' => 'fetch',

-				'element' => 'c_payment_term'

-			)

-		);

-

-		// Import Invoice Lines

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = "InvoiceLine"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('fd' => MAIN_DB_PREFIX.'facturedet', 'extra' => MAIN_DB_PREFIX.'facturedet_extrafields');

-		$this->import_fields_array[$r] = array(

-			'fd.fk_facture' => 'InvoiceRef*',

-			'fd.fk_parent_line' => 'FacParentLine',

-			'fd.fk_product' => 'IdProduct',

-			'fd.label' => 'Label',

-			'fd.description' => 'LineDescription*',

-			'fd.vat_src_code' => 'Vat Source Code',

-			'fd.tva_tx' => 'LineVATRate*',

-			// localtax1_tx

-			// localtax1_type

-			// localtax2_tx

-			// localtax2_type

-			'fd.qty' => 'LineQty',

-			'fd.remise_percent' => 'Reduc. (%)',

-			// remise

-			// fk_remise_except

-			'fd.subprice' => 'UnitPriceHT',

-			// price

-			'fd.total_ht' => 'LineTotalHT',

-			'fd.total_tva' => 'LineTotalVAT',

-			// total_localtax1

-			// total_localtax2

-			'fd.total_ttc' => 'LineTotalTTC',

-			'fd.product_type' => 'TypeOfLineServiceOrProduct',

-			'fd.date_start' => 'Start Date',

-			'fd.date_end' => 'End Date',

-			// info_bits

-			// buy_price_ht

-			// fk_product_fournisseur_price

-			// specia_code

-			// rang

-			// fk_contract_line

-			'fd.fk_unit' => 'Unit',

-			// fk_code_ventilation

-			// situation_percent

-			// fk_prev_id

-			// fk_user_author

-			// fk_user_modif

-			// ref_ext

-		);

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['fd.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['fd.multicurrency_subprice'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['fd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['fd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['fd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_det' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facturedet');

-		$this->import_regex_array[$r] = array(

-			'fd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product',

-			'fd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'

-		);

-		$import_sample = array(

-			'fd.fk_facture' => '(PROV00001)',

-			'fd.fk_parent_line' => '',

-			'fd.fk_product' => '',

-			'fd.label' => '',

-			'fd.description' => 'Test product',

-			'fd.vat_src_code' => '',

-			'fd.tva_tx' => '21',

-			// localtax1_tx

-			// localtax1_type

-			// localtax2_tx

-			// localtax2_type

-			'fd.qty' => '1',

-			'fd.remise_percent' => '0',

-			// remise

-			// fk_remise_except

-			'fd.subprice' => '100',

-			// price

-			'fd.total_ht' => '100',

-			'fd.total_tva' => '21',

-			// total_localtax1

-			// total_localtax2

-			'fd.total_ttc' => '121',

-			'fd.product_type' => '0',

-			'fd.date_start' => '',

-			'fd.date_end' => '',

-			// info_bits

-			// buy_price_ht

-			// fk_product_fournisseur_price

-			// specia_code

-			// rang

-			// fk_contract_line

-			'fd.fk_unit' => '',

-			// fk_code_ventilation

-			// situation_percent

-			// fk_prev_id

-			// fk_user_author

-			// fk_user_modif

-			// ref_ext

-			'fd.multicurrency_code' => 'EUR',

-			'fd.multicurrency_tx' => '21',

-			'fd.multicurrency_total_ht' => '100',

-			'fd.multicurrency_total_tva' => '21',

-			'fd.multicurrency_total_ttc' => '121'

-		);

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array(

-			'fd.rowid' => 'Row Id',

-			'fd.fk_facture' => 'Invoice Id'

-		);

-		$this->import_convertvalue_array[$r] = array(

-			'fd.fk_facture' => array(

-				'rule' => 'fetchidfromref',

-				'file' => '/compta/facture/class/facture.class.php',

-				'class' => 'Facture',

-				'method' => 'fetch',

-				'element' => 'facture'

-			),

-			'fd.fk_projet' => array(

-				'rule' => 'fetchidfromref',

-				'file' => '/projet/class/project.class.php',

-				'class' => 'Project',

-				'method' => 'fetch',

-				'element' => 'facture'

-			),

-		);

-

-

-		// Exports

-		//--------

-		$uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0;

-		$uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0;

-

-		$r = 1;

-

-		$alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe";

-

-		// Invoices and lines

@@ -502 +211,0 @@
-

@@ -504,2 +213,2 @@
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom' => 'ParentCompany', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State',

-			's.phone'=>'Phone',

+		    's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State',

+		    's.phone'=>'Phone',

@@ -510,7 +219,3 @@
-			't.libelle'=>"ThirdPartyType", // 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus",

-			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', 'f.fk_facture_source'=>'SourceInvoiceId',

-			'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue",

-			'f.fk_cond_reglement'=>'IdPaymentTerm', 'f.fk_mode_reglement'=>'IdPaymentMode',

-			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT",

-			'f.localtax1'=>"TotalLT1", 'f.localtax2'=>"TotalLT2",

-			'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',

+			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',

+			'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",

+			'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',

@@ -518,19 +223,17 @@
-			'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic"

-		);

-		if (!$uselocaltax1) {

-			unset($this->export_fields_array[$r]['f.localtax1']);

-		}

-		if (!$uselocaltax2) {

-			unset($this->export_fields_array[$r]['f.localtax2']);

-		}

-

-		// Add multicurrency fields

-		if (isModEnabled("multicurrency")) {

-			$this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';

-			$this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';

-			$this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add POS fields

-		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || getDolGlobalString('INVOICE_SHOW_POS')) {

+			'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',

+			'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",

+			'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",

+			'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',

+			'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',

+			'p.accountancy_code_sell'=>'ProductAccountancySellCode'

+		);

+		if (!empty($conf->multicurrency->enabled))

+		{

+		    $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';

+		    $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';

+		    $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

+		    $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

+		    $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

+		}

+		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))

+		{

@@ -540,35 +242,0 @@
-		$this->export_fields_array[$r] = $this->export_fields_array[$r] + array(

-			'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',

-			'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',

-			'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel'

-		);

-		// Add multicompany field

-		if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {

-			$nbofallowedentities = count(explode(',', getEntity('invoice')));

-			if (isModEnabled('multicompany') && $nbofallowedentities > 1) {

-				$this->export_fields_array[$r]['f.entity'] = 'Entity';

-			}

-		}

-		$this->export_fields_array[$r] = $this->export_fields_array[$r] + array(

-			'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",

-			'fd.subprice'=>"LineUnitPrice", 'fd.qty'=>"LineQty",

-			'fd.tva_tx'=>"LineVATRate",

-			'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT", 'fd.total_ttc'=>"LineTotalTTC",

-			'fd.localtax1_tx'=>"LineLT1Rate", 'fd.localtax1_type'=>"LineLT1Type", 'fd.total_localtax1'=>"LineTotalLT1",

-			'fd.localtax2_tx'=>"LineLT2Rate", 'fd.localtax2_type'=>"LineLT2Type", 'fd.total_localtax2'=>"LineTotalLT2",

-			'fd.buy_price_ht'=>'BuyingPrice', 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',

-			'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',

-			$alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode',

-			'aa.account_number' => 'AccountingAffectation'

-		);

-		if (!$uselocaltax1) {

-			unset($this->export_fields_array[$r]['fd.localtax1_tx']);

-			unset($this->export_fields_array[$r]['fd.localtax1_type']);

-			unset($this->export_fields_array[$r]['fd.total_localtax1']);

-		}

-		if (!$uselocaltax2) {

-			unset($this->export_fields_array[$r]['fd.localtax2_tx']);

-			unset($this->export_fields_array[$r]['fd.localtax2_type']);

-			unset($this->export_fields_array[$r]['fd.total_localtax2']);

-		}

-

@@ -576 +244 @@
-			's.rowid'=>'Numeric', 's.nom'=>'Text', 'ps.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',

+			's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',

@@ -578,4 +246,2 @@
-			't.libelle'=>"Text", // 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text",

-			'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.fk_facture_source'=>'Numeric', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",

-			'f.fk_cond_reglement'=>'Numeric', 'f.fk_mode_reglement'=>'Numeric',

-			'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',

+			'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",

+			'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',

@@ -583,9 +249,3 @@
-			'f.note_private'=>"Text", 'f.note_public'=>"Text",

-			'f.module_source' => 'Text',

-			'f.pos_source' => 'Text',

-			'f.entity'=>'List:entity:label:rowid',

-			'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',

-			'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",

-			'fd.qty'=>"Numeric", 'fd.buy_price_ht'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",

-			'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_localtax1'=>"Numeric", 'fd.total_localtax2'=>"Numeric",

-			'fd.localtax1_tx'=>'Numeric', 'fd.localtax2_tx'=>'Numeric', 'fd.localtax1_type'=>'Numeric', 'fd.localtax2_type'=>'Numeric',

+			'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',

+			'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",

+			'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",

@@ -593,5 +253,7 @@
-			$alias_product_perentity . '.accountancy_code_sell'=>'Text',

-			'aa.account_number' => 'Text',

-			'f.multicurrency_code' => 'Text',

-			'f.multicurrency_tx' => 'Number', 'f.multicurrency_total_ht' => 'Number', 'f.multicurrency_total_tva' => 'Number', 'f.multicurrency_total_ttc' => 'Number'

-		);

+			'p.accountancy_code_sell'=>'Text'

+		);

+		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))

+		{

+			$this->export_TypeFields_array[$r]['f.module_source'] = 'Text';

+			$this->export_TypeFields_array[$r]['f.pos_source'] = 'Text';

+		}

@@ -599,7 +261,4 @@
-			's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',

-			's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',

-			't.libelle'=>'company', // 'ce.code'=>'company', 'cfj.libelle'=>'company'

-			'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line",

-			'fd.subprice'=>"invoice_line", 'fd.buy_price_ht'=>'invoice_line',

-			'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.total_localtax1'=>"invoice_line", 'fd.total_localtax2'=>"invoice_line",

-			'fd.tva_tx'=>"invoice_line", 'fd.localtax1_tx'=>"invoice_line", 'fd.localtax2_tx'=>"invoice_line", 'fd.localtax1_type'=>"invoice_line", 'fd.localtax2_type'=>"invoice_line",

+			's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',

+			's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',

+			's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",

+			'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",

@@ -607,5 +266,3 @@
-			'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product',

-			'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user',

-			'aa.account_number' => "invoice_line",

-		);

-		$this->export_help_array[$r] = array('fd.buy_price_ht'=>'CostPriceUsage');

+			'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_sell'=>'product',

+			'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user'

+		);

@@ -614,3 +271 @@
-		$keyforselect = 'facture';

-		$keyforelement = 'invoice';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';

@@ -618,3 +273 @@
-		$keyforselect = 'facturedet';

-		$keyforelement = 'invoice_line';

-		$keyforaliasextra = 'extra2';

+		$keyforselect = 'facturedet'; $keyforelement = 'invoice_line'; $keyforaliasextra = 'extra2';

@@ -622,7 +275 @@
-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra3';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extra4';

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3';

@@ -632,6 +279 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';

-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -648,3 +289,0 @@
-		if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {

-			$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);

-		}

@@ -652 +290,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_account as aa on fd.fk_code_ventilation = aa.rowid';

@@ -655,6 +293,4 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

-		}

-		$r++;

-

-		// Invoices and payments

+		if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

+		$r++;

+

+

@@ -666,2 +302,2 @@
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State',

-			's.phone'=>'Phone',

+		    's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State',

+		    's.phone'=>'Phone',

@@ -670,4 +306,3 @@
-			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', 'f.fk_facture_source'=>'SourceInvoiceId',

-			'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue",

-			'f.fk_cond_reglement'=>'IdPaymentTerm', 'f.fk_mode_reglement'=>'IdPaymentMode',

-			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',

+			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',

+			'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",

+			'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',

@@ -680,7 +314,0 @@
-		if (!$uselocaltax1) {

-			unset($this->export_fields_array[$r]['f.localtax1']);

-		}

-		if (!$uselocaltax2) {

-			unset($this->export_fields_array[$r]['f.localtax2']);

-		}

-

@@ -688,9 +316,11 @@
-		if (isModEnabled("multicurrency")) {

-			$this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';

-			$this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';

-			$this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-			$this->export_examplevalues_array[$r]['f.multicurrency_code'] = 'EUR';

-		}

-		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || getDolGlobalString('INVOICE_SHOW_POS')) {

+		if (!empty($conf->multicurrency->enabled))

+		{

+		    $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';

+		    $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';

+		    $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

+		    $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

+		    $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

+		    $this->export_examplevalues_array[$r]['f.multicurrency_code'] = 'EUR';

+		}

+		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))

+		{

@@ -701 +331 @@
-			's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',

+		    's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',

@@ -703,3 +333,2 @@
-			'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.fk_facture_source'=>'Numeric', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",

-			'f.fk_cond_reglement'=>'Numeric', 'f.fk_mode_reglement'=>'Numeric',

-			'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text',

+			'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",

+			'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text',

@@ -711 +340,2 @@
-		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || getDolGlobalString('INVOICE_SHOW_POS')) {

+		if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))

+		{

@@ -724,3 +354 @@
-		$keyforselect = 'facture';

-		$keyforelement = 'invoice';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';

@@ -730,3 +358 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -747,3 +373 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

-		}

+		if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

@@ -759 +383 @@
-	 *  @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

+     *  @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

@@ -774 +398,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -778 +403,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -786,2 +412,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'invoice' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','invoice',".((int) $conf->entity).")"

+				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'invoice' AND entity = ".$conf->entity,

+				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','invoice',".$conf->entity.")"

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modFckeditor.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFckeditor.class.php
@@ -25 +25 @@
- *  \brief      Description and activation file for the module Fckeditor

+ *  \brief      Fichier de description et activation du module Fckeditor

@@ -66 +66 @@
-		$this->disabled = (defined('JS_CKEDITOR') && in_array(constant('JS_CKEDITOR'), array('disabled', 'disabled/')));

+		$this->disabled = (in_array(constant('JS_CKEDITOR'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)

@@ -69 +68,0 @@
-		$this->enabled_bydefault = true; // Will be enabled during install

@@ -73,5 +72,7 @@
-		$this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for the fields descriptions of elements (except products/services)");

-		$this->const[2] = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities");

-		$this->const[3] = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature");

-		$this->const[4] = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings");

-		$this->const[5] = array("FCKEDITOR_ENABLE_MAIL", "yesno", "1", "WYSIWIG for products details lines for all entities");

+        $this->const[0]  = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for description and note (except products/services)");

+        $this->const[1]  = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for products/services description and note");

+        $this->const[2]  = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings");

+        $this->const[3]  = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities");

+        $this->const[4]  = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature");

+        $this->const[5]  = array("FCKEDITOR_ENABLE_MAIL", "yesno", "1", "WYSIWIG for products details lines for all entities");

+		$this->const[6] = array("FCKEDITOR_SKIN", "string", "moono-lisa", "Skin by default for fckeditor");

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modFicheinter.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFicheinter.class.php
@@ -28 +28 @@
- *	\brief      Description and activation file for the module Ficheinter

+ *	\brief      Fichier de description et activation du module Ficheinter

@@ -39 +39,2 @@
-	/**

+

+    /**

@@ -43,125 +44,120 @@
-	 */

-	public function __construct($db)

-	{

-		global $conf;

-

-		$this->db = $db;

-		$this->numero = 70;

-

-		$this->family = "crm";

-		$this->module_position = '41';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Gestion des fiches d'intervention";

-

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		$this->picto = "intervention";

-

-		// Data directories to create when module is enabled

-		$this->dirs = array("/ficheinter/temp");

-

-		// Dependencies

-		$this->depends = array("modSociete");

-		$this->requiredby = array();

-		$this->conflictwith = array();

-		$this->langfiles = array("bills", "companies", "interventions");

-

-		// Config pages

-		$this->config_page_url = array("fichinter.php");

-

-		// Constants

-		$this->const = array();

-		$r = 0;

-

-		if (!isset($conf->ficheinter) || !isset($conf->ficheinter->enabled)) {

-			$conf->ficheinter = new stdClass();

-			$conf->ficheinter->enabled = 0;

-		}

-

-		$this->const[$r][0] = "FICHEINTER_ADDON_PDF";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "soleil";

-		$r++;

-

-		$this->const[$r][0] = "FICHEINTER_ADDON";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "pacific";

-		$r++;

-

-		// Boxes

-		$this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home'));

-

-		// Permissions

-		$this->rights = array();

-		$this->rights_class = 'ficheinter';

-		$r = 0;

-

-		$r++;

-		$this->rights[$r][0] = 61;

-		$this->rights[$r][1] = 'Lire les fiches d\'intervention';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'lire';

-

-		$r++;

-		$this->rights[$r][0] = 62;

-		$this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'creer';

-

-		$r++;

-		$this->rights[$r][0] = 64;

-		$this->rights[$r][1] = 'Supprimer les fiches d\'intervention';

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'supprimer';

-

-		$r++;

-		$this->rights[$r][0] = 67;

-		$this->rights[$r][1] = 'Exporter les fiches interventions';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'export';

-

-		$r++;

-		$this->rights[$r][0] = 68;

-		$this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

-		$this->rights[$r][5] = 'send';

-

-		$r++;

-		$this->rights[$r][0] = 69;

-		$this->rights[$r][1] = 'Valider les fiches d\'intervention ';

-		$this->rights[$r][2] = 'a';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

-		$this->rights[$r][5] = 'validate';

-

-		$r++;

-		$this->rights[$r][0] = 70;

-		$this->rights[$r][1] = 'Dévalider les fiches d\'intervention';

-		$this->rights[$r][2] = 'a';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

-		$this->rights[$r][5] = 'unvalidate';

-

-

-		// Menus

-		//-------

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

-

-

-		//Exports

-		//--------

-		$r = 1;

-

-		$this->export_code[$r] = $this->rights_class.'_'.$r;

-		$this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->export_permission[$r] = array(array("ficheinter", "export"));

-		$this->export_fields_array[$r] = array(

+     */

+    public function __construct($db)

+    {

+        global $conf;

+

+        $this->db = $db;

+        $this->numero = 70;

+

+        $this->family = "crm";

+        $this->module_position = '41';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Gestion des fiches d'intervention";

+

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        $this->picto = "intervention";

+

+        // Data directories to create when module is enabled

+        $this->dirs = array("/ficheinter/temp");

+

+        // Dependencies

+        $this->depends = array("modSociete");

+        $this->requiredby = array();

+        $this->conflictwith = array();

+        $this->langfiles = array("bills", "companies", "interventions");

+

+        // Config pages

+        $this->config_page_url = array("fichinter.php");

+

+        // Constants

+        $this->const = array();

+        $r = 0;

+

+        $this->const[$r][0] = "FICHEINTER_ADDON_PDF";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "soleil";

+        $r++;

+

+        $this->const[$r][0] = "FICHEINTER_ADDON";

+        $this->const[$r][1] = "chaine";

+        $this->const[$r][2] = "pacific";

+        $r++;

+

+        // Boxes

+        $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home'));

+

+        // Permissions

+        $this->rights = array();

+        $this->rights_class = 'ficheinter';

+        $r = 0;

+

+        $r++;

+        $this->rights[$r][0] = 61;

+        $this->rights[$r][1] = 'Lire les fiches d\'intervention';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'lire';

+

+        $r++;

+        $this->rights[$r][0] = 62;

+        $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention';

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'creer';

+

+        $r++;

+        $this->rights[$r][0] = 64;

+        $this->rights[$r][1] = 'Supprimer les fiches d\'intervention';

+        $this->rights[$r][2] = 'd';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'supprimer';

+

+        $r++;

+        $this->rights[$r][0] = 67;

+        $this->rights[$r][1] = 'Exporter les fiches interventions';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'export';

+

+        $r++;

+        $this->rights[$r][0] = 68;

+        $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

+        $this->rights[$r][5] = 'send';

+

+        $r++;

+        $this->rights[$r][0] = 69;

+        $this->rights[$r][1] = 'Valider les fiches d\'intervention ';

+        $this->rights[$r][2] = 'a';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

+        $this->rights[$r][5] = 'validate';

+

+        $r++;

+        $this->rights[$r][0] = 70;

+        $this->rights[$r][1] = 'Dévalider les fiches d\'intervention';

+        $this->rights[$r][2] = 'a';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

+        $this->rights[$r][5] = 'unvalidate';

+

+

+        // Menus

+        //-------

+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.

+

+

+        //Exports

+        //--------

+        $r = 1;

+

+        $this->export_code[$r] = $this->rights_class.'_'.$r;

+        $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)

+        $this->export_permission[$r] = array(array("ficheinter", "export"));

+        $this->export_fields_array[$r] = array(

@@ -172,7 +168,5 @@
-		$keyforselect = 'fichinter';

-		$keyforelement = 'intervention';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$this->export_fields_array[$r] += array(

-			'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel',

-			'fd.rowid'=>'InterLineId',

+        $keyforselect = 'fichinter'; $keyforelement = 'intervention'; $keyforaliasextra = 'extra';

+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+        $this->export_fields_array[$r] += array(

+        	'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel',

+        	'fd.rowid'=>'InterLineId',

@@ -181,2 +175,9 @@
-		$this->export_TypeFields_array[$r] = array(

-			's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text',

+        //$this->export_TypeFields_array[$r]=array(

+		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',

+		//	's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',

+		//	's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",

+		//	'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",

+		//	'fd.total_ht'=>"Numeric"

+		//);

+        $this->export_TypeFields_array[$r] = array(

+        	's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text',

@@ -184,4 +185,4 @@
-			'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date",

-			'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Text",

-			'pj.ref'=>'Text', 'pj.title'=>'Text',

-			'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric"

+        	'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date",

+			'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Boolean",

+        	'pj.ref'=>'Text', 'pj.title'=>'Text',

+        	'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric"

@@ -189 +190 @@
-		$this->export_entities_array[$r] = array(

+        $this->export_entities_array[$r] = array(

@@ -193 +194 @@
-			'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line",

+        	'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line",

@@ -196,20 +197,18 @@
-		$this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

-		$keyforselect = 'fichinterdet';

-		$keyforelement = 'inter_line';

-		$keyforaliasextra = 'extradet';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'fichinter as f';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,';

-		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';

-		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';

-		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')';

-		$r++;

-	}

-

-

-	/**

+        $this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

+        $keyforselect = 'fichinterdet'; $keyforelement = 'inter_line'; $keyforaliasextra = 'extradet';

+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+

+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';

+        $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'fichinter as f';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,';

+        $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';

+        $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';

+        $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')';

+        $r++;

+    }

+

+

+    /**

@@ -220,17 +219,17 @@
-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf;

-

-		// Permissions

-		$this->remove($options);

-

-		$sql = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".((int) $conf->entity).")",

-		);

-

-		return $this->_init($sql, $options);

-	}

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf;

+

+        // Permissions

+        $this->remove($options);

+

+        $sql = array(

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".$conf->entity.")",

+        );

+

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modFournisseur.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modFournisseur.class.php
@@ -7 +6,0 @@
- * Copyright (C) 2020      Ahmad Jamaly Rabib   <rabib@metroworks.co.jp>

@@ -24,6 +23,4 @@
- *  \defgroup   fournisseur     Module suppliers

- *  \brief      Module to manage suppliers relations and activities

- *

- *  \file       htdocs/core/modules/modFournisseur.class.php

- *  \ingroup    fournisseur

- *  \brief      Description and activation file for the module Supplier

+ * 		\defgroup   fournisseur     Module suppliers

+ *		\file       htdocs/core/modules/modFournisseur.class.php

+ *		\ingroup    fournisseur

+ *		\brief      Description and activation file for module Supplier

@@ -38,0 +36 @@
+

@@ -46 +44 @@
-		global $conf, $langs, $user, $mysoc;

+		global $conf, $user;

@@ -67,6 +65,6 @@
-			"/fournisseur/temp",

-			"/fournisseur/commande",

-			"/fournisseur/commande/temp",

-			"/fournisseur/facture",

-			"/fournisseur/facture/temp"

-		);

+            "/fournisseur/temp",

+            "/fournisseur/commande",

+            "/fournisseur/commande/temp",

+            "/fournisseur/facture",

+            "/fournisseur/facture/temp"

+        );

@@ -88 +86 @@
-		$this->const[$r][2] = "cornas";

+		$this->const[$r][2] = "muscadet";

@@ -116 +113,0 @@
-		// Add ability ODT for Supplier orders

@@ -124,8 +120,0 @@
-		// Add ability ODT for Supplier Invoices

-		$this->const[$r][0] = "SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

@@ -134,27 +123,8 @@
-			0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),

-			1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),

-			2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'),

-			3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'),

-			4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'),

-			5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'),

-			6=>array('file'=>'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton'=>'Home'),

-		);

-

-		$arraydate = dol_getdate(dol_now());

-		$datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);

-		$this->cronjobs = array(

-			0 => array(

-				'label'=>'RecurringSupplierInvoicesJob',

-				'jobtype'=>'method',

-				'class'=>'fourn/class/fournisseur.facture-rec.class.php',

-				'objectname'=>'FactureFournisseurRec',

-				'method'=>'createRecurringInvoices',

-				'parameters'=>'',

-				'comment'=>'Generate recurring supplier invoices',

-				'frequency'=>1,

-				'unitfrequency'=>3600 * 24,

-				'priority'=>51,

-				'status'=>1,

-				'datestart'=>$datestart

-			));

-

+		0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),

+		1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),

+		2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'),

+		3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'),

+		4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'),

+		5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'),

+		6=>array('file'=>'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton'=>'Home'),

+		);

@@ -223,6 +193,6 @@
-		$this->rights[$r][0] = 1189;

-		$this->rights[$r][1] = 'Check/Uncheck a supplier order reception';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'commande_advance';

-		$this->rights[$r][5] = 'check';

+        $this->rights[$r][0] = 1189;

+        $this->rights[$r][1] = 'Check/Uncheck a supplier order reception';

+        $this->rights[$r][2] = 'w';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'commande_advance';

+        $this->rights[$r][5] = 'check';

@@ -238 +208,2 @@
-		if (getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED')) {

+		if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))

+		{

@@ -305,3 +276,3 @@
-		// Menus

-		//-------

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

+	    // Menus

+	    //-------

+	    $this->menu = 1; // This module add menu entries. They are coded into menu manager.

@@ -312,3 +282,0 @@
-		$uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0;

-		$uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0;

-

@@ -316,4 +283,0 @@
-

-		$langs->loadLangs(array("suppliers", "multicurrency"));

-

-		$alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe";

@@ -324 +288 @@
-		$this->export_icon[$r] = 'invoice';

+		$this->export_icon[$r] = 'bill';

@@ -327 +291 @@
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',

+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',

@@ -331,11 +295,4 @@
-			'f.fk_cond_reglement'=>'IdPaymentTerm', 'f.fk_mode_reglement'=>'IdPaymentMode',

-			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT",

-			'f.localtax1'=>"TotalLT1", 'f.localtax2'=>"TotalLT2",

-			'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote",

-			'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount",

-			'fd.tva_tx'=>"LineVATRate", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC", 'fd.tva'=>"LineTotalVAT",

-			'fd.localtax1_tx'=>"LineLT1Rate", 'fd.localtax1_type'=>"LineLT1Type", 'fd.total_localtax1'=>"LineTotalLT1",

-			'fd.localtax2_tx'=>"LineLT2Rate", 'fd.localtax2_type'=>"LineLT2Type", 'fd.total_localtax2'=>"LineTotalLT2",

-			'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',

-			'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.fk_product'=>'ProductId',

-			'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', $alias_product_perentity.'.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',

+			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote",

+			'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT",

+			'fd.total_ttc'=>"LineTotalTTC", 'fd.tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.fk_product'=>'ProductId',

+			'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',

@@ -344,12 +301,2 @@
-		if (!$uselocaltax1) {

-			unset($this->export_fields_array[$r]['fd.localtax1_tx']);

-			unset($this->export_fields_array[$r]['fd.localtax1_type']);

-			unset($this->export_fields_array[$r]['fd.total_localtax1']);

-		}

-		if (!$uselocaltax2) {

-			unset($this->export_fields_array[$r]['fd.localtax2_tx']);

-			unset($this->export_fields_array[$r]['fd.localtax2_type']);

-			unset($this->export_fields_array[$r]['fd.total_localtax2']);

-		}

-

-		if (isModEnabled("multicurrency")) {

+		if (! empty($conf->multicurrency->enabled))

+		{

@@ -362,7 +308,0 @@
-		if (!$uselocaltax1) {

-			unset($this->export_fields_array[$r]['f.localtax1']);

-		}

-		if (!$uselocaltax2) {

-			unset($this->export_fields_array[$r]['f.localtax2']);

-		}

-

@@ -370 +310 @@
-		//    's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',

+		//    's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',

@@ -376,15 +316,5 @@
-			's.rowid' => 'Numeric', 's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',

-			's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',

-			'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date',

-			'f.fk_cond_reglement'=>'Numeric', 'f.fk_mode_reglement'=>'Numeric',

-			'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>"Numeric", 'f.localtax2'=>"Numeric",

-			'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text",

-			'fd.rowid'=>'Numeric', 'fd.description'=>"Text", 'fd.tva_tx'=>"Text",

-			'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric",

-			'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.tva'=>"Numeric", 'fd.total_localtax1'=>"Numeric", 'fd.total_localtax2'=>"Numeric",

-			'fd.localtax1_tx'=>'Numeric', 'fd.localtax2_tx'=>'Numeric', 'fd.localtax1_type'=>'Numeric', 'fd.localtax2_type'=>'Numeric',

-			'fd.date_start'=>"Date", 'fd.date_end'=>"Date", 'fd.special_code'=>"Numeric",

-			'fd.product_type'=>'Numeric', 'fd.fk_product'=>'List:product:label', $alias_product_perentity . '.accountancy_code_buy'=>'Text',

-			'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text',

-			'f.multicurrency_code' => 'Text',

-			'f.multicurrency_tx' => 'Number', 'f.multicurrency_total_ht' => 'Number', 'f.multicurrency_total_tva' => 'Number', 'f.multicurrency_total_ttc' => 'Number'

+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',

+			's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date',

+			'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'fd.description'=>"Text", 'fd.tva_tx'=>"Text",

+			'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.tva'=>"Numeric", 'fd.product_type'=>'Numeric', 'fd.fk_product'=>'List:product:label',

+			'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'

@@ -393 +323 @@
-			's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company',

+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company',

@@ -395,10 +325,4 @@
-			'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice',

-			'f.fk_cond_reglement'=>'invoice', 'f.fk_mode_reglement'=>'invoice',

-			'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice",

-			'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.qty'=>"invoice_line",

-			'fd.total_ht'=>"invoice_line", 'fd.tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.total_localtax1'=>"invoice_line", 'fd.total_localtax2'=>"invoice_line",

-			'fd.tva_tx'=>"invoice_line", 'fd.localtax1_tx'=>"invoice_line", 'fd.localtax2_tx'=>"invoice_line", 'fd.localtax1_type'=>"invoice_line", 'fd.localtax2_type'=>"invoice_line",

-			'fd.remise_percent'=>"invoice_line",

-			'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>"invoice_line",

-			'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product',

-			'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity.'.accountancy_code_buy'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'

+			'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice', 'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice",

+			'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line",

+			'fd.remise_percent'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva'=>"invoice_line", 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product',

+			'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_buy'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'

@@ -408,8 +332,75 @@
-		$keyforselect = 'facture_fourn';

-		$keyforelement = 'invoice';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$keyforselect = 'facture_fourn_det';

-		$keyforelement = 'invoice_line';

-		$keyforaliasextra = 'extraline';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";

+		$resql = $this->db->query($sql);

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+			while ($obj = $this->db->fetch_object($resql))

+			{

+				$fieldname = 'extra.'.$obj->name;

+				$fieldlabel = ucfirst($obj->label);

+				$typeFilter = "Text";

+				switch ($obj->type)

+				{

+					case 'int':

+					case 'double':

+					case 'price':

+						$typeFilter = "Numeric";

+						break;

+					case 'date':

+					case 'datetime':

+						$typeFilter = "Date";

+						break;

+					case 'boolean':

+						$typeFilter = "Boolean";

+						break;

+					case 'sellist':

+						$tmp = '';

+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null

+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {

+							$var = array_keys($tmpparam['options']);

+							$tmp = array_shift($var);

+						}

+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;

+						break;

+				}

+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;

+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+				$this->export_entities_array[$r][$fieldname] = 'invoice';

+			}

+		}

+		// End add extra fields

+		// Add extra fields line

+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";

+		$resql = $this->db->query($sql);

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+			while ($obj = $this->db->fetch_object($resql))

+			{

+				$fieldname = 'extraline.'.$obj->name;

+				$fieldlabel = ucfirst($obj->label);

+				$typeFilter = "Text";

+				switch ($obj->type)

+				{

+					case 'int':

+					case 'double':

+					case 'price':

+						$typeFilter = "Numeric";

+						break;

+					case 'date':

+					case 'datetime':

+						$typeFilter = "Date";

+						break;

+					case 'boolean':

+						$typeFilter = "Boolean";

+						break;

+					case 'sellist':

+						$tmp = '';

+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null

+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));

+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;

+						break;

+				}

+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;

+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+				$this->export_entities_array[$r][$fieldname] = 'invoice_line';

+			}

+		}

@@ -419,4 +410 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';

-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -432,5 +420,2 @@
-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.((int) $user->id);

-		}

-

-		// Invoices and payments

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

+

@@ -440 +425 @@
-		$this->export_icon[$r] = 'invoice';

+		$this->export_icon[$r] = 'bill';

@@ -446,5 +431,2 @@
-			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateMaxPayment",

-			'f.fk_cond_reglement'=>'IdPaymentTerm', 'f.fk_mode_reglement'=>'IdPaymentMode',

-			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT",

-			'f.localtax1'=>"TotalLT1", 'f.localtax2'=>"TotalLT2",

-			'f.paye'=>"InvoicePaid",

+			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation",

+			'f.datef'=>"DateInvoice", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid",

@@ -454,7 +436,2 @@
-		if (!$uselocaltax1) {

-			unset($this->export_fields_array[$r]['f.localtax1']);

-		}

-		if (!$uselocaltax2) {

-			unset($this->export_fields_array[$r]['f.localtax2']);

-		}

-		if (isModEnabled("multicurrency")) {

+		if (! empty($conf->multicurrency->enabled))

+		{

@@ -468 +445 @@
-		//	's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',

+		//	's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',

@@ -474,10 +451,4 @@
-			's.rowid'=>'Numeric', 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text',

-			's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',

-			'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text",

-			'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date',

-			'f.fk_cond_reglement'=>'Numeric', 'f.fk_mode_reglement'=>'Numeric',

-			'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>"Numeric", 'f.localtax2'=>"Numeric",

-			'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'pf.amount'=>'Numeric',

-			'p.rowid'=>'Numeric', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', 'p.fk_bank'=>'Numeric', 'project.rowid'=>'Numeric', 'project.ref'=>'Text', 'project.title'=>'Text',

-			'f.multicurrency_code' => 'Text',

-			'f.multicurrency_tx' => 'Number', 'f.multicurrency_total_ht' => 'Number', 'f.multicurrency_total_tva' => 'Number', 'f.multicurrency_total_ttc' => 'Number'

+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text',

+			's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.total_ht'=>"Numeric",

+			'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'pf.amount'=>'Numeric',

+			'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', 'p.fk_bank'=>'Numeric', 'project.ref'=>'Text', 'project.title'=>'Text'

@@ -489,4 +460,3 @@
-			'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice',

-			'f.fk_cond_reglement'=>'invoice', 'f.fk_mode_reglement'=>'invoice',

-			'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment',

-			'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'p.fk_bank'=>'account', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project');

+			'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.total_ht'=>"invoice",

+			'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment',

+		    'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'p.fk_bank'=>'account', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project');

@@ -495,4 +465,35 @@
-		$keyforselect = 'facture_fourn';

-		$keyforelement = 'invoice';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";

+		$resql = $this->db->query($sql);

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+			while ($obj = $this->db->fetch_object($resql))

+			{

+				$fieldname = 'extra.'.$obj->name;

+				$fieldlabel = ucfirst($obj->label);

+				$typeFilter = "Text";

+				switch ($obj->type)

+				{

+					case 'int':

+					case 'double':

+					case 'price':

+						$typeFilter = "Numeric";

+						break;

+					case 'date':

+					case 'datetime':

+						$typeFilter = "Date";

+						break;

+					case 'boolean':

+						$typeFilter = "Boolean";

+						break;

+					case 'sellist':

+						$tmp = '';

+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null

+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));

+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;

+						break;

+				}

+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;

+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+				$this->export_entities_array[$r][$fieldname] = 'invoice';

+			}

+		}

@@ -502,3 +503 @@
-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -512,4 +511,2 @@
-		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';

-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.((int) $user->id);

-		}

+        $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

@@ -524 +521 @@
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',

+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',

@@ -527,2 +524,2 @@
-			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_valid'=>'DateValidation', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',

-			'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'uv.login'=>'UserValidation', 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",

+			'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',

+			'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",

@@ -530,2 +527 @@
-			'fd.total_tva'=>"LineTotalVAT", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',

-			'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'SupplierRef', 'fd.fk_product'=>'ProductId',

+			'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',

@@ -534 +530,2 @@
-		if (isModEnabled("multicurrency")) {

+		if (! empty($conf->multicurrency->enabled))

+		{

@@ -541 +538,2 @@
-		if (!getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED')) {

+		if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))

+		{

@@ -546 +544 @@
-			's.rowid'=>"company", 's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',

+			's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',

@@ -548,2 +546,2 @@
-			'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric",

-			'f.fk_statut'=>'Status', 'f.date_valid'=>'Date', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",

+			'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric",

+			'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",

@@ -551 +548,0 @@
-			'fd.date_start'=>"Date", 'fd.date_end'=>"Date", 'fd.special_code'=>"Numeric",

@@ -555,2 +552,2 @@
-			's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company',

-			's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'uv.login'=>'user', 'ua1.login'=>'user',

+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company',

+			's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'ua1.login'=>'user',

@@ -558,2 +555 @@
-			'fd.total_ht'=>"order_line", 'fd.total_ttc'=>"order_line", 'fd.total_tva'=>"order_line", 'fd.date_start'=>"order_line", 'fd.date_end'=>"order_line", 'fd.special_code'=>"order_line",

-			'fd.product_type'=>'order_line', 'fd.ref'=>'order_line', 'fd.fk_product'=>'product',

+			'fd.total_ht'=>"order_line", 'fd.total_ttc'=>"order_line", 'fd.total_tva'=>"order_line", 'fd.product_type'=>'order_line', 'fd.ref'=>'order_line', 'fd.fk_product'=>'product',

@@ -564,4 +560,36 @@
-		$keyforselect = 'commande_fournisseur';

-		$keyforelement = 'order';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")";

+		$resql = $this->db->query($sql);

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+			while ($obj = $this->db->fetch_object($resql))

+			{

+				$fieldname = 'extra.'.$obj->name;

+				$fieldlabel = ucfirst($obj->label);

+				$typeFilter = "Text";

+				switch ($obj->type)

+				{

+					case 'int':

+					case 'double':

+					case 'price':

+						$typeFilter = "Numeric";

+						break;

+					case 'date':

+					case 'datetime':

+						$typeFilter = "Date";

+						break;

+					case 'boolean':

+						$typeFilter = "Boolean";

+						break;

+					case 'sellist':

+						$tmp = '';

+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null

+						$tmpkey = array_keys($tmpparam['options']);

+						if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift($tmpkey);

+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;

+						break;

+				}

+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;

+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+				$this->export_entities_array[$r][$fieldname] = 'order';

+			}

+		}

@@ -570,4 +598,39 @@
-		$keyforselect = 'commande_fournisseurdet';

-		$keyforelement = 'order_line';

-		$keyforaliasextra = 'extraline';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+		$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")";

+		$resql = $this->db->query($sql);

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+			while ($obj = $this->db->fetch_object($resql))

+			{

+				$fieldname = 'extraline.'.$obj->name;

+				$fieldlabel = ucfirst($obj->label);

+				$typeFilter = "Text";

+				switch ($obj->type)

+				{

+					case 'int':

+					case 'double':

+					case 'price':

+						$typeFilter = "Numeric";

+						break;

+					case 'date':

+					case 'datetime':

+						$typeFilter = "Date";

+						break;

+					case 'boolean':

+						$typeFilter = "Boolean";

+						break;

+					case 'sellist':

+						$tmp = '';

+						$tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null

+

+						if ($tmpparam['options'] && is_array($tmpparam['options'])) {

+							$tmpparam_param_key = array_keys($tmpparam['options']);

+							$tmp = array_shift($tmpparam_param_key);

+						}

+						if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;

+						break;

+				}

+				$this->export_fields_array[$r][$fieldname] = $fieldlabel;

+				$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;

+				$this->export_entities_array[$r][$fieldname] = 'order_line';

+			}

+		}

@@ -577,4 +640 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';

-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -584 +643,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON uv.rowid = f.fk_user_valid';

@@ -593,342 +652 @@
-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.((int) $user->id);

-		}

-

-		//Import Supplier Invoice

-		//--------

-		$r = 0;

-

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = "SupplierInvoices"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('f' => MAIN_DB_PREFIX.'facture_fourn', 'extra' => MAIN_DB_PREFIX.'facture_fourn_extrafields');

-		$this->import_tables_creator_array[$r] = array('f' => 'fk_user_author'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'f.ref' => 'InvoiceRef*',

-			'f.ref_supplier' => 'RefSupplier',

-			'f.type' => 'Type*',

-			'f.fk_soc' => 'Supplier/Vendor*',

-			'f.datec' => 'InvoiceDateCreation',

-			'f.datef' => 'DateInvoice',

-			'f.date_lim_reglement' => 'DateMaxPayment',

-			'f.total_ht' => 'TotalHT',

-			'f.total_ttc' => 'TotalTTC',

-			'f.total_tva' => 'TotalVAT',

-			'f.paye' => 'InvoicePaid',

-			'f.fk_statut' => 'InvoiceStatus',

-			'f.fk_user_modif' => 'Modifier Id',

-			'f.fk_user_valid' => 'Validator Id',

-			'f.fk_facture_source' => 'Invoice Source Id',

-			'f.fk_projet' => 'Project Id',

-			'f.fk_account' => 'Bank Account*',

-			'f.note_public' => 'InvoiceNote',

-			'f.note_private' => 'NotePrivate',

-			'f.fk_cond_reglement' => 'PaymentTerm',

-			'f.fk_mode_reglement' => 'PaymentMode',

-			'f.model_pdf' => 'Model',

-			'f.date_valid' => 'DateValidation'

-		);

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['f.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn');

-		if (empty($conf->multicurrency->enabled)) {

-			$this->import_fieldshidden_array[$r]['f.multicurrency_code'] = 'const-'.$conf->currency;

-		}

-		$this->import_regex_array[$r] = array('f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency');

-		$import_sample = array(

-			'f.ref' => '(PROV001)',

-			'f.ref_supplier' => 'Supplier1',

-			'f.type' => '0',

-			'f.fk_soc' => 'Vendor1',

-			'f.datec' => '2021-01-01',

-			'f.datef' => '',

-			'f.date_lim_reglement' => '2021-01-30',

-			'f.total_ht' => '1000',

-			'f.total_ttc' => '1000',

-			'f.total_tva' => '0',

-			'f.paye' => '0',

-			'f.fk_statut' => '0',

-			'f.fk_user_modif' => '',

-			'f.fk_user_valid' => '',

-			'f.fk_facture_source' => '',

-			'f.fk_projet' => '',

-			'f.fk_account' => 'BANK1',

-			'f.note_public' => 'Note: ',

-			'f.note_private' => '',

-			'f.fk_cond_reglement' => '1',

-			'f.fk_mode_reglement' => '2',

-			'f.model_pdf' => 'crab',

-			'f.date_valid' => '',

-			'f.multicurrency_code' => 'USD',

-			'f.multicurrency_tx' => '1',

-			'f.multicurrency_total_ht' => '1000',

-			'f.multicurrency_total_tva' => '0',

-			'f.multicurrency_total_ttc' => '1000'

-		);

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('f.ref' => 'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'f.ref' => array(

-				'rule'=>'getrefifauto',

-				'class'=>(!getDolGlobalString('INVOICE_SUPPLIER_ADDON_NUMBER') ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),

-				'path'=>"/core/modules/supplier_invoice/".(!getDolGlobalString('INVOICE_SUPPLIER_ADDON_NUMBER') ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).'.php',

-				'classobject'=>'FactureFournisseur',

-				'pathobject'=>'/fourn/class/fournisseur.facture.class.php',

-			),

-			'f.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),

-			'f.fk_account' => array('rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'),

-		);

-

-		//Import Supplier Invoice Lines

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = "SupplierInvoiceLines"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields');

-		$this->import_fields_array[$r] = array(

-			'fd.fk_facture_fourn' => 'InvoiceRef*',

-			'fd.fk_parent_line' => 'ParentLine',

-			'fd.fk_product' => 'IdProduct',

-			'fd.description' => 'LineDescription',

-			'fd.pu_ht' => 'PriceUHT',

-			'fd.pu_ttc' => 'PriceUTTC',

-			'fd.qty' => 'LineQty',

-			'fd.remise_percent' => 'Reduc.',

-			'fd.vat_src_code' => 'Vat Source Code',

-			'fd.product_type' => 'TypeOfLineServiceOrProduct',

-			'fd.tva_tx' => 'LineVATRate',

-			'fd.total_ht' => 'LineTotalHT',

-			'fd.tva' => 'LineTotalVAT',

-			'fd.total_ttc' => 'LineTotalTTC',

-			'fd.date_start' => 'Start Date',

-			'fd.date_end' => 'End Date',

-			'fd.fk_unit' => 'Unit'

-		);

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['fd.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['fd.multicurrency_subprice'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['fd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['fd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['fd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn_det');

-		$this->import_regex_array[$r] = array('fd.product_type' => '[0|1]$', 'fd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', 'fd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency');

-		$import_sample = array(

-			'fd.fk_facture_fourn' => '(PROV001)',

-			'fd.fk_parent_line' => '',

-			'fd.fk_product' => '',

-			'fd.description' => 'Test Product',

-			'fd.pu_ht' => '50000',

-			'fd.pu_ttc' => '50000',

-			'fd.qty' => '1',

-			'fd.remise_percent' => '0',

-			'fd.vat_src_code' => '',

-			'fd.product_type' => '0',

-			'fd.tva_tx' => '0',

-			'fd.total_ht' => '50000',

-			'fd.tva' => '0',

-			'fd.total_ttc' => '50000',

-			'fd.date_start' => '',

-			'fd.date_end' => '',

-			'fd.fk_unit' => '',

-			'fd.multicurrency_code' => 'USD',

-			'fd.multicurrency_tx' => '0',

-			'fd.multicurrency_total_ht' => '50000',

-			'fd.multicurrency_total_tva' => '0',

-			'fd.multicurrency_total_ttc' => '50000'

-		);

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('fd.rowid' => 'Row Id', 'fd.fk_facture_fourn' => 'Invoice Id', 'fd.fk_product' => 'Product Id');

-		$this->import_convertvalue_array[$r] = array(

-			'fd.fk_facture_fourn' => array('rule' => 'fetchidfromref', 'file' => '/fourn/class/fournisseur.facture.class.php', 'class' => 'FactureFournisseur', 'method' => 'fetch'),

-		);

-

-		//Import Purchase Orders

-		$r++;

-		$this->import_code[$r] = 'commande_fournisseur_'.$r;

-		$this->import_label[$r] = 'SuppliersOrders';

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array();

-		$this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'commande_fournisseur', 'extra' => MAIN_DB_PREFIX.'commande_fournisseur_extrafields');

-		$this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'c.ref'               => 'Ref*',

-			'c.ref_supplier'      => 'RefSupplier',

-			'c.fk_soc'            => 'ThirdPartyName*',

-			'c.fk_projet'         => 'ProjectId',

-			'c.date_creation'     => 'DateCreation',

-			'c.date_valid'        => 'DateValid',

-			'c.date_approve'      => 'DateApprove',

-			'c.date_commande'     => 'DateOrder',

-			'c.fk_user_modif'     => 'ModifiedById',

-			'c.fk_user_valid'     => 'ValidatedById',

-			'c.fk_user_approve'   => 'ApprovedById',

-			'c.source'            => 'Source',

-			'c.fk_statut'         => 'Status*',

-			'c.billed'            => 'Billed(0/1)',

-			'c.total_tva'         => 'TotalTVA',

-			'c.total_ht'          => 'TotalHT',

-			'c.total_ttc'         => 'TotalTTC',

-			'c.note_private'      => 'NotePrivate',

-			'c.note_public'       => 'Note',

-			'c.date_livraison'    => 'DeliveryDate',

-			'c.fk_cond_reglement' => 'Payment Condition',

-			'c.fk_mode_reglement' => 'Payment Mode',

-			'c.model_pdf'         => 'Model'

-		);

-

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['c.multicurrency_code']      = 'Currency';

-			$this->import_fields_array[$r]['c.multicurrency_tx']        = 'CurrencyRate';

-			$this->import_fields_array[$r]['c.multicurrency_total_ht']  = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseur');

-		$this->import_regex_array[$r] = array(

-			'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'

-		);

-

-		$this->import_updatekeys_array[$r] = array('c.ref' => 'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'c.ref' => array(

-				'rule'=>'getrefifauto',

-				'class'=>(!getDolGlobalString('COMMANDE_SUPPLIER_ADDON_NUMBER') ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),

-				'path'=>"/core/modules/supplier_order/".(!getDolGlobalString('COMMANDE_SUPPLIER_ADDON_NUMBER') ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).'.php',

-				'classobject'=>'CommandeFournisseur',

-				'pathobject'=>'/fourn/class/fournisseur.commande.class.php',

-			),

-			'c.fk_soc' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/societe/class/societe.class.php',

-				'class'   => 'Societe',

-				'method'  => 'fetch',

-				'element' => 'ThirdParty'

-			),

-			'c.fk_mode_reglement' => array(

-				'rule' => 'fetchidfromcodeorlabel',

-				'file' => '/compta/paiement/class/cpaiement.class.php',

-				'class' => 'Cpaiement',

-				'method' => 'fetch',

-				'element' => 'cpayment'

-			),

-			'c.source' => array('rule' => 'zeroifnull'),

-		);

-

-		// Import PO Lines

-		$r++;

-		$this->import_code[$r] = 'commande_fournisseurdet_'.$r;

-		$this->import_label[$r] = 'PurchaseOrderLines';

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array();

-		$this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields');

-		$this->import_fields_array[$r] = array(

-			'cd.fk_commande'    => 'PurchaseOrder*',

-			'cd.fk_parent_line' => 'ParentLine',

-			'cd.fk_product'     => 'IdProduct',

-			'cd.ref'     		=> 'SupplierRef',

-			'cd.description'    => 'LineDescription',

-			'cd.tva_tx'         => 'LineVATRate',

-			'cd.qty'            => 'LineQty',

-			'cd.remise_percent' => 'Reduc. Percent',

-			'cd.subprice'       => 'Sub Price',

-			'cd.total_ht'       => 'LineTotalHT',

-			'cd.total_tva'      => 'LineTotalVAT',

-			'cd.total_ttc'      => 'LineTotalTTC',

-			'cd.product_type'   => 'TypeOfLineServiceOrProduct',

-			'cd.date_start'     => 'Start Date',

-			'cd.date_end'       => 'End Date',

-			'cd.info_bits'      => 'InfoBits',

-			'cd.special_code'   => 'Special Code',

-			'cd.rang'           => 'LinePosition',

-			'cd.fk_unit'        => 'Unit'

-		);

-

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-

-		// Add extra fields

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-			}

-		}

-		// End add extra fields

-

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseurdet');

-		$this->import_regex_array[$r] = array(

-			'cd.product_type'       => '[0|1]$',

-			'cd.fk_product'         => 'rowid@'.MAIN_DB_PREFIX.'product',

-			'cd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'

-		);

-		$this->import_updatekeys_array[$r] = array('cd.fk_commande' => 'Purchase Order Id');

-		$this->import_convertvalue_array[$r] = array(

-			'cd.fk_commande' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/fourn/class/fournisseur.commande.class.php',

-				'class'   => 'CommandeFournisseur',

-				'method'  => 'fetch',

-				'element' => 'order_supplier'

-			),

-			'cd.info_bits' => array('rule' => 'zeroifnull'),

-			'cd.special_code' => array('rule' => 'zeroifnull'),

-		);

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

@@ -943 +661 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -952 +670 @@
-		//ODT template for Supplier Orders

+		//ODT template

@@ -957 +675,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -961 +680,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -968,31 +688,4 @@
-		$sql_order = array(

-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".((int) $conf->entity),

-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'order_supplier', ".((int) $conf->entity).")",

-		);

-

-		//ODT template for Supplier Invoice

-		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt';

-		$dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_invoices';

-		$dest = $dirodt.'/template_supplier_invoices.odt';

-

-		if (file_exists($src) && !file_exists($dest)) {

-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-			dol_mkdir($dirodt);

-			$result = dol_copy($src, $dest, 0, 0);

-			if ($result < 0) {

-				$langs->load("errors");

-				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

-				return 0;

-			}

-		}

-

-		/*

-		$sql_invoice = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'invoice_supplier' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."', 'invoice_supplier', ".((int) $conf->entity).")",

-		);

-

-		$sql = array_merge($sql_order, $sql_invoice);

-		*/

-

-		$sql = $sql_order;

+		$sql = array(

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order_supplier',".$conf->entity.")",

+		);

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modHRM.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modHRM.class.php
@@ -2 +2 @@
-/* Copyright (C) 2015-2021  Alexandre Spangaro  <aspangaro@open-dsi.fr>

+/* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>

@@ -16 +15,0 @@
- * or see https://www.gnu.org/

@@ -20,6 +19,3 @@
- *  \defgroup   HRM 	Module hrm

- *  \brief      Module for Human Resource Management (HRM)

- *

- *  \file       htdocs/core/modules/modHRM.class.php

- *  \ingroup    HRM

- *  \brief      Description and activation file for the module HRM

+ * \file    htdocs/core/modules/modHRM.class.php

+ * \ingroup HRM

+ * \brief   Description and activation file for module HRM

@@ -29 +24,0 @@
-

@@ -31 +26 @@
- *		Description and activation class for module HRM

+ * Class to describe and activate the HRM module

@@ -36 +31,2 @@
-	 *  Constructor. Define names, constants, directories, boxes, permissions

+	 * Constructor.

+	 * Define names, constants, directories, boxes, permissions

@@ -38 +34 @@
-	 *  @param	DoliDB	$db		Database handler

+	 * @param 	DoliDB 	$db		Database handler

@@ -46,2 +41,0 @@
-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

@@ -49 +42,0 @@
-		// Key text used to identify module (for permissions, menus, etc...)

@@ -52,2 +44,0 @@
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

@@ -55 +45,0 @@
-		$this->module_position = '50';

@@ -58,2 +48,2 @@
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "HRM";

+		$this->description = "Management of employees carrier and feelings (department, employment contract)";

+

@@ -61,2 +51,2 @@
-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+		$this->version = 'development';

+

@@ -69,24 +59,2 @@
-		// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)

-		$this->module_parts = array(

-			// Set this to 1 if module has its own trigger directory (core/triggers)

-			'triggers' => 0,

-			// Set this to 1 if module has its own login method file (core/login)

-			'login' => 0,

-			// Set this to 1 if module has its own substitution function file (core/substitutions)

-			'substitutions' => 0,

-			// Set this to 1 if module has its own menus handler directory (core/menus)

-			'menus' => 0,

-			// Set this to 1 if module overwrite template dir (core/tpl)

-			'tpl' => 0,

-			// Set this to 1 if module has its own barcode directory (core/modules/barcode)

-			'barcode' => 0,

-			// Set this to 1 if module has its own models directory (core/modules/xxx)

-			'models' => 1,

-			// Set this to 1 if module has its own printing directory (core/modules/printing)

-			'printing' => 0,

-			// Set this to 1 if module has its own theme directory (theme)

-			'theme' => 0,

-			// Set this to relative path of css file if module has its own css file

-			'css' => array(),

-			// Set this to relative path of js file if module must load a js on all pages

-			'js' => array(),

+		// define triggers

+		$this->module_parts = array();

@@ -94,3 +62,2 @@
-			// Set this to 1 if features of module are opened to external users

-			'moduleforexternal' => 0,

-		);

+		// Data directories to create when module is enabled

+		$this->dirs = array();

@@ -98,6 +65,2 @@
-		// Data directories to create when module is enabled.

-		// Example: this->dirs = array("/hrm/temp","/hrm/subdir");

-		$this->dirs = array("/hrm/temp");

-

-		// Config pages. Put here list of php page, stored into hrm/admin directory, to use to setup module.

-		$this->config_page_url = array("hrm.php");

+		// Config pages

+		$this->config_page_url = array('admin_hrm.php@hrm');

@@ -108 +71 @@
-		$this->requiredby = array(); // List of module ids to disable if this one is disabled

+		$this->requiredby = array(/*"modSalaries, modExpenseReport, modHoliday"*/); // List of module ids to disable if this one is disabled

@@ -110,2 +73,2 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(11, 0); // Minimum version of Dolibarr required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+		$this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module

@@ -113,43 +75,0 @@
-

-		// Constants

-		// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),

-		//                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );

-		$this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')

-		$r = 0;

-

-

-		if (!isset($conf->hrm) || !isset($conf->hrm->enabled)) {

-			$conf->hrm = new stdClass();

-			$conf->hrm->enabled = 0;

-		}

-

-		// Array to add new pages in new tabs

-		$this->tabs = array();

-		$this->tabs[] = array('data'=>'user:+skill_tab:Skills:hrm:1:/hrm/skill_tab.php?id=__ID__&objecttype=user');  					// To add a new tab identified by code tabname1

-		//$this->tabs[] = array('data'=>'job:+tabname1:Poste:mylangfile@hrm:1:/hrm/poste_list.php?fk_job=__ID__');  					// To add a new tab identified by code tabname1

-		// Example:

-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@hrm:$user->rights->hrm->read:/hrm/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@hrm:$user->rights->othermodule->read:/hrm/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

-		//

-		// Where objecttype can be

-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

-		// 'contact'          to add a tab in contact view

-		// 'contract'         to add a tab in contract view

-		// 'group'            to add a tab in group view

-		// 'intervention'     to add a tab in intervention view

-		// 'invoice'          to add a tab in customer invoice view

-		// 'invoice_supplier' to add a tab in supplier invoice view

-		// 'member'           to add a tab in fundation member view

-		// 'opensurveypoll'	  to add a tab in opensurvey poll view

-		// 'order'            to add a tab in sales order view

-		// 'order_supplier'   to add a tab in supplier order view

-		// 'payment'		  to add a tab in payment view

-		// 'payment_supplier' to add a tab in supplier payment view

-		// 'product'          to add a tab in product view

-		// 'propal'           to add a tab in propal view

-		// 'project'          to add a tab in project view

-		// 'stock'            to add a tab in stock view

-		// 'thirdparty'       to add a tab in third party view

-		// 'user'             to add a tab in user view

-

@@ -160,10 +80,3 @@
-		// Boxes/Widgets

-		// Add here list of php file(s) stored in hrm/core/boxes that contains a class to show a widget.

-		$this->boxes = array(

-			//  0 => array(

-			//      'file' => 'hrmwidget1.php@hrm',

-			//      'note' => 'Widget provided by HrmTest',

-			//      'enabledbydefaulton' => 'Home',

-			//  ),

-			//  ...

-		);

+		// Constantes

+		$this->const = array();

+		$r = 0;

@@ -171,19 +84,2 @@
-		// Cronjobs (List of cron jobs entries to add when module is enabled)

-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

-		$this->cronjobs = array(

-			//  0 => array(

-			//      'label' => 'MyJob label',

-			//      'jobtype' => 'method',

-			//      'class' => '/hrm/class/poste.class.php',

-			//      'objectname' => 'Poste',

-			//      'method' => 'doScheduledJob',

-			//      'parameters' => '',

-			//      'comment' => 'Comment',

-			//      'frequency' => 2,

-			//      'unitfrequency' => 3600,

-			//      'status' => 0,

-			//      'test' => '$conf->hrm->enabled',

-			//      'priority' => 50,

-			//  ),

-		);

-

+		// Boxes

+		$this->boxes = array();

@@ -195,6 +91,5 @@
-		// Skill / Job / Position

-		$this->rights[$r][0] = 4001; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read skill/job/position'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'all';

-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->all->read)

+		$this->rights[$r][0] = 4001;

+		$this->rights[$r][1] = 'See employees';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'employee';

+		$this->rights[$r][5] = 'read';

@@ -203,5 +98,5 @@
-		$this->rights[$r][0] = 4002; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Create/modify skill/job/position'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'all';

-		$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->all->write)

+		$this->rights[$r][0] = 4002;

+		$this->rights[$r][1] = 'Create employees';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'employee';

+		$this->rights[$r][5] = 'write';

@@ -210,5 +105,5 @@
-		$this->rights[$r][0] = 4003; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Delete skill/job/position'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'all';

-		$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->all->delete)

+		$this->rights[$r][0] = 4003;

+		$this->rights[$r][1] = 'Delete employees';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'employee';

+		$this->rights[$r][5] = 'delete';

@@ -217,6 +112,5 @@
-		// Evaluation

-		$this->rights[$r][0] = 4021; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read evaluations'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'evaluation';

-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read)

+		$this->rights[$r][0] = 4004;

+		$this->rights[$r][1] = 'Export employees';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'employee';

+		$this->rights[$r][5] = 'export';

@@ -225,6 +118,0 @@
-		$this->rights[$r][0] = 4022; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Create/modify your evaluation'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'evaluation';

-		$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->write)

-		$r++;

@@ -232,45 +120,3 @@
-		$this->rights[$r][0] = 4023; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Validate evaluation'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'evaluation_advance';

-		$this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->validate)

-		$r++;

-

-		$this->rights[$r][0] = 4025; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Delete evaluations'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'evaluation';

-		$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->delete)

-		$r++;

-

-		// Comparison

-		$this->rights[$r][0] = 4028; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'See comparison menu'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'compare_advance';

-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read)

-		$r++;

-

-		// Evaluation

-		$this->rights[$r][0] = 4029; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read all evaluations'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'evaluation';

-		$this->rights[$r][5] = 'readall'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read)

-		$r++;

-

-		// Read employee

-		$this->rights[$r][0] = 4031; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read personal/HR information'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'read_personal_information';

-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_personal_information->read)

-		$r++;

-

-		// Write employee

-		$this->rights[$r][0] = 4032; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Write personal/HR information'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'write_personal_information';

-		$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_personal_information->write)

-		$r++;

+		// Menus

+		//-------

+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

@@ -280,3 +126,4 @@
-	 *		Function called when module is enabled.

-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *		It also creates data directories

+	 * Function called when module is enabled.

+	 * The init function add constants, boxes, permissions and menus

+	 * (defined in constructor) into Dolibarr database.

+	 * It also creates data directories

@@ -284,2 +131,2 @@
-	 *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

-	 *      @return     int             	1 if OK, 0 if KO

+	 * @param string $options Enabling module ('', 'noboxes')

+	 * @return int if OK, 0 if KO

@@ -289 +135,0 @@
-		global $conf;

@@ -293,9 +139 @@
-		$result = $this->_load_tables('/install/mysql/', 'hrm');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		$sql = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard' AND type='evaluation' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','evaluation',".((int) $conf->entity).")"

-		);

+		$sql = array();

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modHoliday.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modHoliday.class.php
@@ -26,2 +26 @@
- *    \brief      Module for leave/vacation management

- *

+ *    \brief      Module de gestion des congés

@@ -30 +29 @@
- *    \brief      Description and activation file for the module holiday

+ *    \brief      Description and activation file for module holiday

@@ -81,0 +81,4 @@
+

+		// Config pages. Put here list of php page names stored in admmin directory used to setup module.

+		// $this->config_page_url = array("holiday.php?leftmenu=setup@holiday");

+

@@ -87 +90 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -93,0 +97 @@
+		//                             2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)

@@ -134,22 +137,0 @@
-		// Cronjobs

-		$arraydate = dol_getdate(dol_now());

-		$datestart = dol_mktime(4, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);

-		$this->cronjobs = array(

-			0 => array(

-				'label' => 'HolidayBalanceMonthlyUpdate:holiday',

-				'jobtype' => 'method',

-				'class' => 'holiday/class/holiday.class.php',

-				'objectname' => 'Holiday',

-				'method' => 'updateBalance',

-				'parameters' => '',

-				'comment' => 'Update holiday balance every month',

-				'frequency' => 1,

-				'unitfrequency' => 3600 * 24,

-				'priority' => 50,

-				'status' => 1,

-				'test' => '$conf->holiday->enabled',

-				'datestart' => $datestart

-			)

-		);

-

-

@@ -161 +143 @@
-		$this->rights[$r][1] = 'Read leave requests (yours and your subordinates)'; // Permission label

+		$this->rights[$r][1] = 'Read your own leave requests'; // Permission label

@@ -168 +150 @@
-		$this->rights[$r][1] = 'Create/modify leave requests'; // Permission label

+		$this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label

@@ -191 +173 @@
-		$this->rights[$r][4] = 'readall'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+		$this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

@@ -198 +180 @@
-		$this->rights[$r][4] = 'writeall'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+		$this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

@@ -222 +204 @@
-		$this->export_permission[$r] = array(array("holiday", "readall"));

+		$this->export_permission[$r] = array(array("holiday", "read_all"));

@@ -225,4 +207,2 @@
-			'd.date_debut'=>'DateStart', 'd.date_fin'=>'DateEnd', 'd.halfday'=>'HalfDay', 'none.num_open_days'=>'NbUseDaysCP',

-			'd.date_valid'=>'DateApprove', 'd.fk_validator'=>"UserForApprovalID",

-			'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login",

-			'ua.lastname'=>"UserForApprovalLastname", 'ua.firstname'=>"UserForApprovalFirstname",

+			'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>"Login", 'd.date_debut'=>'DateStart', 'd.date_fin'=>'DateEnd', 'd.halfday'=>'HalfDay', 'none.num_open_days'=>'NbUseDaysCP',

+			'd.date_valid'=>'DateApprove', 'd.fk_validator'=>"UserForApprovalID", 'ua.lastname'=>"UserForApprovalLastname", 'ua.firstname'=>"UserForApprovalFirstname",

@@ -233,4 +213,2 @@
-			'd.date_debut'=>'Date', 'd.date_fin'=>'Date', 'none.num_open_days'=>'NumericCompute',

-			'd.date_valid'=>'Date', 'd.fk_validator'=>"Numeric",

-			'u.lastname'=>'Text', 'u.firstname'=>'Text', 'u.login'=>"Text",

-			'ua.lastname'=>"Text", 'ua.firstname'=>"Text",

+			'u.lastname'=>'Text', 'u.firstname'=>'Text', 'u.login'=>"Text", 'd.date_debut'=>'Date', 'd.date_fin'=>'Date', 'none.num_open_days'=>'NumericCompute',

+			'd.date_valid'=>'Date', 'd.fk_validator'=>"Numeric", 'ua.lastname'=>"Text", 'ua.firstname'=>"Text",

@@ -242 +220 @@
-		//$this->export_alias_array[$r] = array('d.rowid'=>"idholiday");

+		$this->export_alias_array[$r] = array('d.rowid'=>"idholiday");

@@ -246,7 +224 @@
-		$keyforselect = 'holiday';

-		$keyforelement = 'holiday';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$keyforselect = 'user';

-		$keyforelement = 'user';

-		$keyforaliasextra = 'extrau';

+		$keyforselect = 'holiday'; $keyforelement = 'holiday'; $keyforaliasextra = 'extra';

@@ -261 +232,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extrau ON u.rowid = extrau.fk_object';

@@ -273 +244 @@
-		//	'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

+		//	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

@@ -281 +252 @@
-		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",

+		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",

@@ -284,0 +256,9 @@
+		//);

+		// $this->export_alias_array[$r]=array(

+		//	's.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.zip'=>'soc_zip','s.town'=>'soc_town','s.fk_pays'=>'soc_pays','s.phone'=>'soc_tel',

+		//	's.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy',

+		//	's.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.ref'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",

+		//	'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid',

+		//	'fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc",

+		//	'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid',

+		//	'p.ref'=>'productref'

@@ -325 +305 @@
-		*/

+        */

@@ -328,2 +308,2 @@
-			//	"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".((int) $conf->entity),

-			//	"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".((int) $conf->entity).")"

+		//	"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".$conf->entity,

+		//	"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".$conf->entity.")"

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modIncoterm.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modIncoterm.class.php
@@ -25 +25 @@
- *  \brief      Description and activation file for the module MyModule

+ *  \brief      Description and activation file for module MyModule

@@ -40,3 +40,3 @@
-	public function __construct($db)

-	{

-		global $langs, $conf;

+    public function __construct($db)

+    {

+        global $langs, $conf;

@@ -44 +44 @@
-		$this->db = $db;

+        $this->db = $db;

@@ -59 +59 @@
-		$this->picto = 'incoterm';

+		$this->picto = 'generic';

@@ -71 +71 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -79 +79 @@
-		$this->tabs = array();

+        $this->tabs = array();

@@ -81,5 +81,6 @@
-		// Dictionaries

-		if (!isset($conf->incoterm->enabled)) {

-			$conf->incoterm = new stdClass();

-			$conf->incoterm->enabled = 0;

-		}

+        // Dictionaries

+		if (!isset($conf->incoterm->enabled))

+        {

+        	$conf->incoterm = new stdClass();

+        	$conf->incoterm->enabled = 0;

+        }

@@ -88,10 +89,9 @@
-			'tabname'=>array("c_incoterms"), // List of tables we want to see into dictonnary editor

-			'tablib'=>array("Incoterms"), // Label of tables

-			'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields

-			'tabsqlsort'=>array("rowid ASC"), // Sort order

-			'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary)

-			'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)

-			'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)

-			'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')

-			'tabcond'=>array($conf->incoterm->enabled),

-			'tabhelp' => array(array())

+            'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor

+            'tablib'=>array("Incoterms"), // Label of tables

+            'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields

+            'tabsqlsort'=>array("rowid ASC"), // Sort order

+            'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary)

+            'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)

+            'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)

+            'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')

+            'tabcond'=>array($conf->incoterm->enabled)

@@ -100 +100 @@
-		$this->boxes = array(); // List of boxes

+        $this->boxes = array(); // List of boxes

@@ -108 +108 @@
-		$this->menu = array(); // List of menus to add

+		$this->menus = array(); // List of menus to add

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modLabel.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modLabel.class.php
@@ -24 +24 @@
- *	\brief      Description and activation file for the module Labels

+ *	\brief      Fichier de description et activation du module Label

@@ -34,0 +35 @@
+

@@ -63 +64 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -80 +81 @@
-		$this->rights[1][3] = 0; // La permission est-elle une permission par defaut

+		$this->rights[1][3] = 1; // La permission est-elle une permission par defaut

@@ -99 +100 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -102,2 +103,2 @@
-	public function init($options = '')

-	{

+    public function init($options = '')

+    {

@@ -110 +111 @@
-	}

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modLoan.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modLoan.class.php
@@ -24 +24 @@
- *      \brief      Description and activation file for the module loan

+ *      \brief      File to activate module loan

@@ -33,0 +34 @@
+

@@ -69 +70 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -84 +85 @@
-		$this->const[2] = array(

+		$this->const[1] = array(

@@ -99 +100 @@
-		$this->rights[$r][0] = 521;

+		$this->rights[$r][0] = 520;

@@ -155 +156 @@
-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -160,4 +161 @@
-		$result = $this->_load_tables('/install/mysql/', 'loan');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

+		global $conf;

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modMailing.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modMailing.class.php
@@ -25 +25 @@
- *	\brief      Description and activation file for the module Mailing

+ *	\brief      Fichier de description et activation du module Mailing

@@ -35,0 +36 @@
+

@@ -50 +51 @@
-		$this->module_position = '23';

+		$this->module_position = '11';

@@ -68 +69 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -76,8 +76,0 @@
-		$r = 0;

-

-		$this->const[$r][0] = "MAILING_CONTACT_DEFAULT_BULK_STATUS";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "0";

-		$this->const[$r][3] = 'Default value for field "Refuse bulk email" when creating a contact';

-		$this->const[$r][4] = 0;

-		$r++;

@@ -156 +149 @@
-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -161,5 +153,0 @@
-		$result = $this->_load_tables('/install/mysql/', 'mailing');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modModuleBuilder.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modModuleBuilder.class.php
@@ -24 +24 @@
- *  \brief      Description and activation file for the module ModuleBuilder

+ *  \brief      Description and activation file for module ModuleBuilder

@@ -33 +33 @@
-	/**

+    /**

@@ -37,4 +37,4 @@
-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

+     */

+    public function __construct($db)

+    {

+    	global $langs, $conf;

@@ -42,2 +42,2 @@
-		$this->db = $db;

-		$this->numero = 3300;

+        $this->db = $db;

+        $this->numero = 3300;

@@ -47,5 +47,5 @@
-		$this->family = "technic";

-		$this->module_position = '90';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "A RAD (Rapid Application Development - low-code and no-code) tool to help developers or advanced users to build their own module/application.";

+        $this->family = "technic";

+        $this->module_position = '90';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module.";

@@ -53,5 +53,5 @@
-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'bug';

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'bug';

@@ -59,2 +59,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -62,3 +62,3 @@
-		// Config pages

-		//-------------

-		$this->config_page_url = array('setup.php@modulebuilder');

+        // Config pages

+        //-------------

+        $this->config_page_url = array('setup.php@modulebuilder');

@@ -66,7 +66,7 @@
-		// Dependencies

-		//-------------

-		$this->hidden = false; // A condition to disable module

-		$this->depends = array(); // 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(); // List of modules id this module is in conflict with

-		$this->langfiles = array();

+        // Dependencies

+        //-------------

+	    $this->hidden = false; // A condition to disable module

+	    $this->depends = array(); // 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(); // List of modules id this module is in conflict with

+        $this->langfiles = array();

@@ -74,2 +74,2 @@
-		// Constants

-		//-----------

+        // Constants

+        //-----------

@@ -78,3 +78,3 @@
-		// New pages on tabs

-		// -----------------

-		$this->tabs = array();

+        // New pages on tabs

+        // -----------------

+        $this->tabs = array();

@@ -82,3 +82,3 @@
-		// Boxes

-		//------

-		$this->boxes = array();

+        // Boxes

+        //------

+        $this->boxes = array();

@@ -86,4 +86,4 @@
-		// Permissions

-		//------------

-		$this->rights = array(); // Permission array used by this module

-		$this->rights_class = 'modulebuilder';

+        // Permissions

+        //------------

+        $this->rights = array(); // Permission array used by this module

+        $this->rights_class = 'modulebuilder';

@@ -91 +91 @@
-		$r = 0;

+        $r = 0;

@@ -93,6 +93,6 @@
-		$r++;

-		$this->rights[$r][0] = 3301;

-		$this->rights[$r][1] = 'Generate new modules';

-		$this->rights[$r][2] = 'a';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'run';

+        $r++;

+        $this->rights[$r][0] = 3301;

+        $this->rights[$r][1] = 'Generate new modules';

+        $this->rights[$r][2] = 'a';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'run';

@@ -101,3 +101,3 @@
-		// Main menu entries

-		//------------------

-		$this->menu = array();

+        // Main menu entries

+        //------------------

+        $this->menu = array();

@@ -105,15 +105,13 @@
-		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools',

-			'type'=>'left',

-			'titre'=>'ModuleBuilder',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

-			'mainmenu'=>'tools',

-			'leftmenu'=>'devtools_modulebuilder',

-			'url'=>'/modulebuilder/index.php?mainmenu=tools&amp;leftmenu=devtools',

-			'langs'=>'modulebuilder',

-			'position'=>100,

-			'perms'=>'$user->hasRight("modulebuilder", "run")',

-			//'enabled'=>'isModEnabled("modulebuilder") && preg_match(\'/^(devtools|all)/\',$leftmenu)',

-			'enabled'=>'isModEnabled("modulebuilder")',

-			'target'=>'_modulebuilder',

-			'user'=>0);

-	}

+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',

+            'type'=>'left',

+            'titre'=>'ModuleBuilder',

+            'mainmenu'=>'home',

+            'leftmenu'=>'admintools_modulebuilder',

+            'url'=>'/modulebuilder/index.php?mainmenu=home&amp;leftmenu=admintools',

+            'langs'=>'modulebuilder',

+            'position'=>100,

+            'perms'=>'1',

+            'enabled'=>'$conf->modulebuilder->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu) && ($user->admin || $conf->global->MODULEBUILDER_FOREVERYONE)',

+            'target'=>'_modulebuilder',

+            'user'=>0);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modMrp.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modMrp.class.php
@@ -5 +5 @@
- * Copyright (C) 2019       Destailleur Laurent     <eldy@users.sourceforge.net>

+ * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson <testldr9@dolicloud.com>

@@ -18 +18 @@
- * along with this program. If not, see <https://www.gnu.org/licenses/>.

+ * along with this program. If not, see <http://www.gnu.org/licenses/>.

@@ -23 +23 @@
- *  \brief      Module to manage Manufacturing Orders (MO)

+ *  \brief      Mrp module descriptor.

@@ -27 +27 @@
- *  \brief      Description and activation file for the module Mrp

+ *  \brief      Description and activation file for module Mrp

@@ -36,205 +36,228 @@
-	/**

-	 * Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 * @param DoliDB $db Database handler

-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

-		$this->db = $db;

-

-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 660;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'mrp';

-		// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'

-		// It is used to group modules by family in module setup page

-		$this->family = "products";

-		// Module position in the family on 2 digits ('01', '10', '20', ...)

-		$this->module_position = '66';

-		// Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)

-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));

-		// Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module).

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module).

-		$this->description = "Module to Manage Manufacturing Orders (MO)";

-		// Used only if file README.md and README-LL.md not found.

-		$this->descriptionlong = "Module to Manage Manufacturing Orders (MO)";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'

-		$this->version = 'dolibarr';

-		// Url to the file with your last numberversion of this module

-		//$this->url_last_version = 'http://www.example.com/versionmodule.txt';

-

-		// Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'mrp';

-		// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)

-		$this->module_parts = array(

-			// Set this to 1 if module has its own trigger directory (core/triggers)

-			'triggers' => 0,

-			// Set this to 1 if module has its own login method file (core/login)

-			'login' => 0,

-			// Set this to 1 if module has its own substitution function file (core/substitutions)

-			'substitutions' => 0,

-			// Set this to 1 if module has its own menus handler directory (core/menus)

-			'menus' => 0,

-			// Set this to 1 if module overwrite template dir (core/tpl)

-			'tpl' => 0,

-			// Set this to 1 if module has its own barcode directory (core/modules/barcode)

-			'barcode' => 0,

-			// Set this to 1 if module has its own models directory (core/modules/xxx)

-			'models' => 0,

-			// Set this to 1 if module has its own theme directory (theme)

-			'theme' => 0,

-			// Set this to relative path of css file if module has its own css file

-			'css' => array(

-				//    '/mrp/css/mrp.css.php',

-			),

-			// Set this to relative path of js file if module must load a js on all pages

-			'js' => array(

-				//   '/mrp/js/mrp.js.php',

-			),

-			// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'

-			'hooks' => array(

-				//   'data' => array(

-				//       'hookcontext1',

-				//       'hookcontext2',

-				//   ),

-				//   'entity' => '0',

-			),

-			// Set this to 1 if features of module are opened to external users

-			'moduleforexternal' => 0,

-		);

-		// Data directories to create when module is enabled.

-		// Example: this->dirs = array("/mrp/temp","/mrp/subdir");

-		$this->dirs = array("/mrp/temp");

-		// Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module.

-		$this->config_page_url = array("mrp.php");

-		// Dependencies

-		// A condition to hide module

-		$this->hidden = false;

-		// List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))

-		$this->depends = array('modBom');

-		$this->requiredby = array('modWorkstation'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)

-		$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

-		$this->langfiles = array("mrp");

-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module

-		$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		//$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice');

-		//$this->always_enabled = true;								// If true, can't be disabled

-

-		// Constants

-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

-		// Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),

-		//                             2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)

-		// );

-		$this->const = array(

-			//1=>array('MRP_MO_ADDON_PDF', 'chaine', 'vinci', 'Name of default PDF model of MO', 0),

-			2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0),

-			3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0)

-		);

-

-		// Some keys to add into the overwriting translation tables

-		/*$this->overwrite_translation = array(

-			'en_US:ParentCompany'=>'Parent company or reseller',

-			'fr_FR:ParentCompany'=>'Maison mère ou revendeur'

-		)*/

-

-		if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {

-			$conf->mrp = new stdClass();

-			$conf->mrp->enabled = 0;

-		}

-

-		// Array to add new pages in new tabs

-		$this->tabs = array();

-		// Example:

-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

-		//

-		// Where objecttype can be

-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

-		// 'contact'          to add a tab in contact view

-		// 'contract'         to add a tab in contract view

-		// 'group'            to add a tab in group view

-		// 'intervention'     to add a tab in intervention view

-		// 'invoice'          to add a tab in customer invoice view

-		// 'invoice_supplier' to add a tab in supplier invoice view

-		// 'member'           to add a tab in fundation member view

-		// 'opensurveypoll'	  to add a tab in opensurvey poll view

-		// 'order'            to add a tab in sales order view

-		// 'order_supplier'   to add a tab in supplier order view

-		// 'payment'		  to add a tab in payment view

-		// 'payment_supplier' to add a tab in supplier payment view

-		// 'product'          to add a tab in product view

-		// 'propal'           to add a tab in propal view

-		// 'project'          to add a tab in project view

-		// 'stock'            to add a tab in stock view

-		// 'thirdparty'       to add a tab in third party view

-		// 'user'             to add a tab in user view

-

-		// Dictionaries

-		$this->dictionaries = array();

-

-		// Boxes/Widgets

-		// Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget.

-		$this->boxes = array(

-			0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home')

-		);

-

-		// Cronjobs (List of cron jobs entries to add when module is enabled)

-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

-		$this->cronjobs = array(

-			//  0 => array(

-			//      'label' => 'MyJob label',

-			//      'jobtype' => 'method',

-			//      'class' => '/mrp/class/mo.class.php',

-			//      'objectname' => 'Mo',

-			//      'method' => 'doScheduledJob',

-			//      'parameters' => '',

-			//      'comment' => 'Comment',

-			//      'frequency' => 2,

-			//      'unitfrequency' => 3600,

-			//      'status' => 0,

-			//      'test' => '$conf->mrp->enabled',

-			//      'priority' => 50,

-			//  ),

-		);

-		// Example: $this->cronjobs=array(

-		//    0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50),

-		//    1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50)

-		// );

-

-		// Permissions provided by this module

-		$this->rights = array();

-		$r = 1;

-		// Add here entries to declare new permissions

-		/* BEGIN MODULEBUILDER PERMISSIONS */

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label

-		$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

-		$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

-		$r++;

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label

-		$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

-		$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

-		$r++;

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label

-		$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

-		$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

-		$r++;

-		/* END MODULEBUILDER PERMISSIONS */

-

-		// Main menu entries to add

-		$this->menu = array();

-		$r = 0;

-		// Add here entries to declare new menus

-		/* BEGIN MODULEBUILDER TOPMENU */

+    /**

+     * Constructor. Define names, constants, directories, boxes, permissions

+     *

+     * @param DoliDB $db Database handler

+     */

+    public function __construct($db)

+    {

+        global $langs, $conf;

+        $this->db = $db;

+

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 660;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'mrp';

+        // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'

+        // It is used to group modules by family in module setup page

+        $this->family = "products";

+        // Module position in the family on 2 digits ('01', '10', '20', ...)

+        $this->module_position = '62';

+        // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)

+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));

+        // Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module).

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module).

+        $this->description = "Module to Manage Manufacturing Orders (MO)";

+        // Used only if file README.md and README-LL.md not found.

+        $this->descriptionlong = "Module to Manage Manufacturing Orders (MO)";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'

+        $this->version = 'dolibarr';

+        // Url to the file with your last numberversion of this module

+        //$this->url_last_version = 'http://www.example.com/versionmodule.txt';

+

+        // Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'mrp';

+        // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)

+        $this->module_parts = array(

+            // Set this to 1 if module has its own trigger directory (core/triggers)

+            'triggers' => 0,

+            // Set this to 1 if module has its own login method file (core/login)

+            'login' => 0,

+            // Set this to 1 if module has its own substitution function file (core/substitutions)

+            'substitutions' => 0,

+            // Set this to 1 if module has its own menus handler directory (core/menus)

+            'menus' => 0,

+            // Set this to 1 if module overwrite template dir (core/tpl)

+            'tpl' => 0,

+            // Set this to 1 if module has its own barcode directory (core/modules/barcode)

+            'barcode' => 0,

+            // Set this to 1 if module has its own models directory (core/modules/xxx)

+            'models' => 0,

+            // Set this to 1 if module has its own theme directory (theme)

+            'theme' => 0,

+            // Set this to relative path of css file if module has its own css file

+            'css' => array(

+                //    '/mrp/css/mrp.css.php',

+            ),

+            // Set this to relative path of js file if module must load a js on all pages

+            'js' => array(

+                //   '/mrp/js/mrp.js.php',

+            ),

+            // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'

+            'hooks' => array(

+                //   'data' => array(

+                //       'hookcontext1',

+                //       'hookcontext2',

+                //   ),

+                //   'entity' => '0',

+            ),

+            // Set this to 1 if features of module are opened to external users

+            'moduleforexternal' => 0,

+        );

+        // Data directories to create when module is enabled.

+        // Example: this->dirs = array("/mrp/temp","/mrp/subdir");

+        $this->dirs = array("/mrp/temp");

+        // Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module.

+        $this->config_page_url = array("mrp.php");

+        // Dependencies

+        // A condition to hide module

+        $this->hidden = false;

+        // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)

+        $this->depends = array('modBom');

+        $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)

+        $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

+        $this->langfiles = array("mrp");

+        $this->phpmin = array(5, 5); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module

+        $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice');

+        //$this->always_enabled = true;								// If true, can't be disabled

+

+        // Constants

+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

+        // Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),

+        //                             2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)

+        // );

+        $this->const = array(

+        	1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of MO', 0),

+        	2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0),

+        	3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0)

+        );

+

+        // Some keys to add into the overwriting translation tables

+        /*$this->overwrite_translation = array(

+            'en_US:ParentCompany'=>'Parent company or reseller',

+            'fr_FR:ParentCompany'=>'Maison mère ou revendeur'

+        )*/

+

+        if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {

+            $conf->mrp = new stdClass();

+            $conf->mrp->enabled = 0;

+        }

+

+        // Array to add new pages in new tabs

+        $this->tabs = array();

+        // Example:

+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

+        // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //

+        // Where objecttype can be

+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

+        // 'contact'          to add a tab in contact view

+        // 'contract'         to add a tab in contract view

+        // 'group'            to add a tab in group view

+        // 'intervention'     to add a tab in intervention view

+        // 'invoice'          to add a tab in customer invoice view

+        // 'invoice_supplier' to add a tab in supplier invoice view

+        // 'member'           to add a tab in fundation member view

+        // 'opensurveypoll'	  to add a tab in opensurvey poll view

+        // 'order'            to add a tab in customer order view

+        // 'order_supplier'   to add a tab in supplier order view

+        // 'payment'		  to add a tab in payment view

+        // 'payment_supplier' to add a tab in supplier payment view

+        // 'product'          to add a tab in product view

+        // 'propal'           to add a tab in propal view

+        // 'project'          to add a tab in project view

+        // 'stock'            to add a tab in stock view

+        // 'thirdparty'       to add a tab in third party view

+        // 'user'             to add a tab in user view

+

+        // Dictionaries

+        $this->dictionaries = array();

+        /* Example:

+        $this->dictionaries=array(

+            'langs'=>'mylangfile@mrp',

+            // List of tables we want to see into dictonnary editor

+            'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),

+            // Label of tables

+            'tablib'=>array("Table1","Table2","Table3"),

+            // Request to select fields

+            'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),

+            // Sort order

+            'tabsqlsort'=>array("label ASC","label ASC","label ASC"),

+            // List of fields (result of select to show dictionary)

+            'tabfield'=>array("code,label","code,label","code,label"),

+            // List of fields (list of fields to edit a record)

+            'tabfieldvalue'=>array("code,label","code,label","code,label"),

+            // List of fields (list of fields for insert)

+            'tabfieldinsert'=>array("code,label","code,label","code,label"),

+            // Name of columns with primary key (try to always name it 'rowid')

+            'tabrowid'=>array("rowid","rowid","rowid"),

+            // Condition to show each dictionary

+            'tabcond'=>array($conf->mrp->enabled,$conf->mrp->enabled,$conf->mrp->enabled)

+        );

+        */

+

+        // Boxes/Widgets

+        // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget.

+        $this->boxes = array(

+            0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home')

+        );

+

+        // Cronjobs (List of cron jobs entries to add when module is enabled)

+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

+        $this->cronjobs = array(

+            //  0 => array(

+            //      'label' => 'MyJob label',

+            //      'jobtype' => 'method',

+            //      'class' => '/mrp/class/mo.class.php',

+            //      'objectname' => 'Mo',

+            //      'method' => 'doScheduledJob',

+            //      'parameters' => '',

+            //      'comment' => 'Comment',

+            //      'frequency' => 2,

+            //      'unitfrequency' => 3600,

+            //      'status' => 0,

+            //      'test' => '$conf->mrp->enabled',

+            //      'priority' => 50,

+            //  ),

+        );

+        // Example: $this->cronjobs=array(

+        //    0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50),

+        //    1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50)

+        // );

+

+        // Permissions provided by this module

+        $this->rights = array();

+        $r = 0;

+        // Add here entries to declare new permissions

+        /* BEGIN MODULEBUILDER PERMISSIONS */

+        $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

+        $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label

+        $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

+        $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

+        $r++;

+        $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

+        $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label

+        $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

+        $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

+        $r++;

+        $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

+        $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label

+        $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

+        $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)

+        $r++;

+        /* END MODULEBUILDER PERMISSIONS */

+

+        // Main menu entries to add

+        $this->menu = array();

+        $r = 0;

+        // Add here entries to declare new menus

+        /* BEGIN MODULEBUILDER TOPMENU */

@@ -243,234 +266,109 @@
-		$langs->loadLangs(array("mrp", "stocks"));

-

-		// Exports profiles provided by this module

-		$r = 1;

-

-		$this->export_code[$r]=$this->rights_class.'_'.$r;

-		$this->export_label[$r]='MOs';	// Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->export_icon[$r]='mrp';

-		$this->export_fields_array[$r] = array(

-			'm.rowid'=>"Id",

-			'm.ref'=>"Ref",

-			'm.label'=>"Label",

-			'm.fk_project'=>'Project',

-			'm.fk_bom'=>"Bom",

-			'm.date_start_planned'=>"DateStartPlanned",

-			'm.date_end_planned'=>"DateEndPlanned",

-			'm.fk_product'=>"Product",

-			'm.status'=>'Status',

-			'm.model_pdf'=>'Model',

-			'm.fk_user_valid'=>'ValidatedById',

-			'm.fk_user_modif'=>'ModifiedById',

-			'm.fk_user_creat'=>'CreatedById',

-			'm.date_valid'=>'DateValidation',

-			'm.note_private'=>'NotePrivate',

-			'm.note_public'=>'Note',

-			'm.fk_soc'=>'Tiers',

-			'e.rowid'=>'WarehouseId',

-			'e.ref'=>'WarehouseRef',

-			'm.qty'=>'Qty',

-			'm.date_creation'=>'DateCreation',

-			'm.tms'=>'DateModification'

-		);

-		$keyforselect = 'mrp_mo';

-		$keyforelement = 'mrp_mo';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$this->export_TypeFields_array[$r] = array(

-			'm.ref'=>"Text",

-			'm.label'=>"Text",

-			'm.fk_project'=>'Numeric',

-			'm.fk_bom'=>"Numeric",

-			'm.date_end_planned'=>"Date",

-			'm.date_start_planned'=>"Date",

-			'm.fk_product'=>"Numeric",

-			'm.status'=>'Numeric',

-			'm.model_pdf'=>'Text',

-			'm.fk_user_valid'=>'Numeric',

-			'm.fk_user_modif'=>'Numeric',

-			'm.fk_user_creat'=>'Numeric',

-			'm.date_valid'=>'Date',

-			'm.note_private'=>'Text',

-			'm.note_public'=>'Text',

-			'm.fk_soc'=>'Numeric',

-			'e.fk_warehouse'=>'Numeric',

-			'e.ref'=>'Text',

-			'm.qty'=>'Numeric',

-			'm.date_creation'=>'Date',

-			'm.tms'=>'Date'

-

-		);

-		$this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'mrp_mo as m';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = m.fk_warehouse';

-		$this->export_sql_end[$r] .= ' WHERE m.entity IN ('.getEntity('mrp_mo').')'; // For product and service profile

-

-		// Imports profiles provided by this module

-		$r = 0;

-		$langs->load("mrp");

-		/* BEGIN MODULEBUILDER IMPORT MO */

-		/*

-		 $this->export_code[$r]=$this->rights_class.'_'.$r;

-		 $this->export_label[$r]='MoLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

-		 $this->export_icon[$r]='mo@mrp';

-		 $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo';

-		 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';

-		 $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo';

-		 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		 //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)

-		 $this->export_sql_start[$r]='SELECT DISTINCT ';

-		 $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'mo as t';

-		 $this->export_sql_end[$r] .=' WHERE 1 = 1';

-		 $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';

-		 $r++; */

-		/* END MODULEBUILDER IMPORT MO */

-		$r++;

-		$this->import_code[$r]=$this->rights_class.'_'.$r;

-		$this->import_label[$r]='MOs';	// Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->import_icon[$r]='mrp';

-		$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon

-		$this->import_tables_array[$r] = array('m'=>MAIN_DB_PREFIX.'mrp_mo', 'extra'=>MAIN_DB_PREFIX.'mrp_mo_extrafields');

-		$this->import_tables_creator_array[$r] = array('m'=>'fk_user_creat'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'm.ref' => "Ref*",

-			'm.label' => "Label*",

-			'm.fk_project'=>'Project',

-			'm.fk_bom'=>"Bom",

-			'm.date_start_planned'=>"DateStartPlanned",

-			'm.date_end_planned'=>"DateEndPlanned",

-			'm.fk_product'=>"Product*",

-			'm.status'=>'Status',

-			'm.model_pdf'=>'Model',

-			'm.fk_user_valid'=>'ValidatedById',

-			'm.fk_user_modif'=>'ModifiedById',

-			'm.fk_user_creat'=>'CreatedById',

-			'm.date_valid'=>'DateValid',

-			'm.note_private'=>'NotePrivate',

-			'm.note_public'=>'Note',

-			'm.fk_soc'=>'Tiers',

-			'm.fk_warehouse'=>'Warehouse',

-			'm.qty'=>'Qty*',

-			'm.date_creation'=>'DateCreation',

-			'm.tms'=>'DateModification',

-		);

-		$import_sample = array();

-

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'mrp_mo');

-		/*$this->import_regex_array[$r] = array(

-			'm.ref' => ''

-		);*/

-

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('m.ref' => 'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'm.fk_product' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/product/class/product.class.php',

-				'class'   => 'Product',

-				'method'  => 'fetch',

-				'element' => 'Product'

-			),

-			'm.fk_warehouse' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/product/stock/class/entrepot.class.php',

-				'class'   => 'Entrepot',

-				'method'  => 'fetch',

-				'element' => 'Warehouse'

-			),

-			'm.fk_user_valid' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/user/class/user.class.php',

-				'class'   => 'User',

-				'method'  => 'fetch',

-				'element' => 'user'

-			),

-			'm.fk_user_modif' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/user/class/user.class.php',

-				'class'   => 'User',

-				'method'  => 'fetch',

-				'element' => 'user'

-			),

-		);

-	}

-

-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories

-	 *

-	 *  @param      string  $options    Options when enabling module ('', 'noboxes')

-	 *  @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf, $langs;

-

-		// Create extrafields during init

-		//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

-		//$extrafields = new ExtraFields($this->db);

-		//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

-		//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

-		//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

-		//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

-		//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

-

-		// Permissions

-		$this->remove($options);

-

-		$sql = array();

-

-		// ODT template

-		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';

-		$dirodt = DOL_DATA_ROOT.'/doctemplates/mrps';

-		$dest = $dirodt.'/template_mo.odt';

-

-		if (file_exists($src) && !file_exists($dest)) {

-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-			dol_mkdir($dirodt);

-			$result = dol_copy($src, $dest, 0, 0);

-			if ($result < 0) {

-				$langs->load("errors");

-				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

-				return 0;

-			}

-		}

-

-		$sql = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('vinci')."' AND type = 'mrp' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('vinci')."','mrp',".((int) $conf->entity).")"

-		);

-

-		return $this->_init($sql, $options);

-	}

-

-	/**

-	 *  Function called when module is disabled.

-	 *  Remove from database constants, boxes and permissions from Dolibarr database.

-	 *  Data directories are not deleted

-	 *

-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int                 1 if OK, 0 if KO

-	 */

-	public function remove($options = '')

-	{

-		$sql = array();

-		return $this->_remove($sql, $options);

-	}

+        // Exports profiles provided by this module

+        $r = 1;

+        /* BEGIN MODULEBUILDER EXPORT MO */

+        /*

+        $langs->load("mrp");

+        $this->export_code[$r]=$this->rights_class.'_'.$r;

+        $this->export_label[$r]='MoLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

+        $this->export_icon[$r]='mo@mrp';

+        $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo';

+        include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';

+        $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo';

+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+        //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)

+        $this->export_sql_start[$r]='SELECT DISTINCT ';

+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'mo as t';

+        $this->export_sql_end[$r] .=' WHERE 1 = 1';

+        $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';

+        $r++; */

+        /* END MODULEBUILDER EXPORT MO */

+

+        // Imports profiles provided by this module

+        $r = 1;

+        /* BEGIN MODULEBUILDER IMPORT MO */

+        /*

+         $langs->load("mrp");

+         $this->export_code[$r]=$this->rights_class.'_'.$r;

+         $this->export_label[$r]='MoLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

+         $this->export_icon[$r]='mo@mrp';

+         $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo';

+         include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';

+         $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo';

+         include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+         //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)

+         $this->export_sql_start[$r]='SELECT DISTINCT ';

+         $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'mo as t';

+         $this->export_sql_end[$r] .=' WHERE 1 = 1';

+         $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';

+         $r++; */

+        /* END MODULEBUILDER IMPORT MO */

+    }

+

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string  $options    Options when enabling module ('', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+    	global $conf, $langs;

+

+        $result = $this->_load_tables('/mrp/sql/');

+        if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

+

+        // Create extrafields during init

+        //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

+        //$extrafields = new ExtraFields($this->db);

+        //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

+        //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

+        //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

+        //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

+        //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');

+

+        // Permissions

+        $this->remove($options);

+

+        $sql = array();

+

+        // ODT template

+        $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';

+        $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps';

+        $dest = $dirodt.'/template_mo.odt';

+

+        if (file_exists($src) && !file_exists($dest))

+        {

+        	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+        	dol_mkdir($dirodt);

+        	$result = dol_copy($src, $dest, 0, 0);

+        	if ($result < 0)

+        	{

+        		$langs->load("errors");

+        		$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

+        		return 0;

+        	}

+        }

+

+        $sql = array(

+        	//"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity,

+        	//"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")"

+        );

+

+        return $this->_init($sql, $options);

+    }

+

+    /**

+     *  Function called when module is disabled.

+     *  Remove from database constants, boxes and permissions from Dolibarr database.

+     *  Data directories are not deleted

+     *

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int                 1 if OK, 0 if KO

+     */

+    public function remove($options = '')

+    {

+        $sql = array();

+        return $this->_remove($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modMultiCurrency.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modMultiCurrency.class.php
@@ -26 +26 @@
- *  \brief      Description and activation file for the module MultiCurrency

+ *  \brief      Description and activation file for module MultiCurrency

@@ -41,5 +41,5 @@
-	public function __construct($db)

-	{

-		global $langs, $conf;

-

-		$this->db = $db;

+    public function __construct($db)

+    {

+        global $langs, $conf;

+

+        $this->db = $db;

@@ -91 +91 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -104,2 +104,2 @@
-		//                              'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		//                              'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //                              'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        //                              'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

@@ -116 +116 @@
-		// 'order'            to add a tab in sales order view

+		// 'order'            to add a tab in customer order view

@@ -126,7 +126,8 @@
-		$this->tabs = array();

-

-		// Dictionaries

-		if (!isset($conf->multicurrency->enabled)) {

-			$conf->multicurrency = new stdClass();

-			$conf->multicurrency->enabled = 0;

-		}

+        $this->tabs = array();

+

+        // Dictionaries

+	    if (!isset($conf->multicurrency->enabled))

+        {

+        	$conf->multicurrency = new stdClass();

+        	$conf->multicurrency->enabled = 0;

+        }

@@ -134,3 +135,18 @@
-

-

-		// Boxes

+        /* Example:

+        if (! isset($conf->multicurrency->enabled)) $conf->multicurrency->enabled=0;	// This is to avoid warnings

+        $this->dictionaries=array(

+            'langs'=>'mylangfile@multicurrency',

+            'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),		// List of tables we want to see into dictonnary editor

+            'tablib'=>array("Table1","Table2","Table3"),													// Label of tables

+			'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),	// Request to select fields

+			// Sort order

+            'tabsqlsort'=>array("label ASC","label ASC","label ASC"),

+            'tabfield'=>array("code,label","code,label","code,label"),																					// List of fields (result of select to show dictionary)

+            'tabfieldvalue'=>array("code,label","code,label","code,label"),																				// List of fields (list of fields to edit a record)

+            'tabfieldinsert'=>array("code,label","code,label","code,label"),																			// List of fields (list of fields for insert)

+            'tabrowid'=>array("rowid","rowid","rowid"),																									// Name of columns with primary key (try to always name it 'rowid')

+            'tabcond'=>array($conf->multicurrency->enabled,$conf->multicurrency->enabled,$conf->multicurrency->enabled)												// Condition to show each dictionary

+        );

+        */

+

+        // Boxes

@@ -138 +154 @@
-		$this->boxes = array(); // List of boxes

+        $this->boxes = array(); // List of boxes

@@ -145,24 +160,0 @@
-

-		// Cronjobs (List of cron jobs entries to add when module is enabled)

-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

-		$statusatinstall=1;

-		$arraydate=dol_getdate(dol_now());

-		$datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);

-

-		$this->cronjobs = array(

-			0 => array(

-				'priority'=>61,

-				'label'=>'MutltiCurrencyAutoUpdateCurrencies',

-				'jobtype'=>'method',

-				'class'=>'multicurrency/class/multicurrency.class.php',

-				'objectname'=>'MultiCurrency',

-				'method'=>'syncRates',

-				'parameters'=>'0,0,cron',

-				'comment'=>'Update all the currencies using the currencylayer API. An API key needs to be given in the multi-currency module config page',

-				'frequency'=>1,

-				'unitfrequency'=>2678400,

-				'status'=>$statusatinstall,

-				'test'=>'isModEnabled("cron")',

-				'datestart'=>$datestart

-			),

-		);

@@ -182,24 +173,0 @@
-

-		$this->rights[$r][0] = 40001;

-		$this->rights[$r][1] = 'Read currencies and their rates';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 1;

-		$this->rights[$r][4] = 'currency';

-		$this->rights[$r][5] = 'read';

-		$r++;

-

-		$this->rights[$r][0] = 40002;

-		$this->rights[$r][1] = 'Create/Update currencies and their rates';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'currency';

-		$this->rights[$r][5] = 'write';

-		$r++;

-

-		$this->rights[$r][0] = 40003;

-		$this->rights[$r][1] = 'Delete currencies and their rates';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'currency';

-		$this->rights[$r][5] = 'delete';

-		$r++;

@@ -250,2 +218,2 @@
-		// $this->export_enabled[$r]='1';                               // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.

-		// $this->export_icon[$r]='generic:MyModule';

+        // $this->export_enabled[$r]='1';                               // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.

+        // $this->export_icon[$r]='generic:MyModule';

@@ -257 +225 @@
-		//	'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

+		//	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

@@ -266 +234 @@
-		//	'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",

+		//	'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",

@@ -275,2 +243,2 @@
-		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",

-		//	'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",

+		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",

+		//	'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",

@@ -294 +262 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -300,0 +269 @@
+		//$this->_load_tables('/multicurrency/sql/');

@@ -303 +272,2 @@
-		if ($res) {

+		if ($res)

+		{

@@ -335,3 +305,2 @@
-		$multicurrency = new MultiCurrency($this->db);

-

-		if (! $multicurrency->checkCodeAlreadyExists($conf->currency)) {

+		if (!MultiCurrency::checkCodeAlreadyExists($conf->currency))

+		{

@@ -339,0 +309 @@
+			$multicurrency = new MultiCurrency($this->db);

@@ -344,5 +314 @@
-			if ($r > 0) {

-				$multicurrency->addRate(1);

-			} else {

-				return 0;

-			}

+			if ($r > 0)	$multicurrency->addRate(1);

@@ -350 +315,0 @@
-		return 1;

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modNotification.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modNotification.class.php
@@ -20,6 +20,5 @@
- *  \defgroup   notification	Module notification

- *  \brief      Module for managing notifications (by e-mail or other means)

- *

- *  \file       htdocs/core/modules/modNotification.class.php

- *  \ingroup    notification

- *  \brief      Description and activation file for the module Notification

+ *	\defgroup   notification	Module email notification

+ *	\brief      Module pour gerer les notifications (par mail ou autre)

+ *	\file       htdocs/core/modules/modNotification.class.php

+ *	\ingroup    notification

+ *	\brief      Fichier de description et activation du module Notification

@@ -33,0 +33 @@
+

@@ -48 +48 @@
-		$this->module_position = '22';

+		$this->module_position = '01';

@@ -52 +52 @@
-		$this->descriptionlong = 'Module600Long';

+        $this->descriptionlong = 'Module600Long';

@@ -54 +54 @@
-		$this->version = 'dolibarr';

+        $this->version = 'dolibarr';

@@ -66 +66 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -89 +89 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modOauth.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modOauth.class.php
@@ -26 +26 @@
- *  \brief      Description and activation file for the module Oauth

+ *  \brief      File of class to describe and activate module Oauth

@@ -37,24 +36,0 @@
-	/**

-	 *  Constructor

-	 *

-	 *  @param      DoliDB      $db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-		$this->numero = 66000;

-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "interface";

-		$this->module_position = '31';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Enable OAuth2 authentication";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version

-		$this->version = 'dolibarr';

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'technic';

@@ -62,2 +38,24 @@
-		// Data directories to create when module is enabled.

-		$this->dirs = array();

+    /**

+     *  Constructor

+     *

+     *  @param      DoliDB      $db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+        $this->numero = 66000;

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "interface";

+        $this->module_position = '31';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Enable OAuth authentication";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version

+        $this->version = 'dolibarr';

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'technic';

@@ -65,2 +63,2 @@
-		// Config pages

-		$this->config_page_url = array("oauth.php");

+        // Data directories to create when module is enabled.

+        $this->dirs = array();

@@ -68,2 +66,5 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Config pages

+        $this->config_page_url = array("oauth.php");

+

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -73,4 +74,4 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module                    // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module

-		$this->conflictwith = array();

-		$this->langfiles = array("oauth");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module                    // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module

+        $this->conflictwith = array();

+        $this->langfiles = array("oauth");

@@ -78,2 +79,2 @@
-		// Constants

-		$this->const = array();

+        // Constants

+        $this->const = array();

@@ -81,2 +82,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -84,3 +85,3 @@
-		// Permissions

-		$this->rights = array();

-		$this->rights_class = 'oauth';

+        // Permissions

+        $this->rights = array();

+        $this->rights_class = 'oauth';

@@ -88,7 +89,7 @@
-		$r = 0;

-		// $this->rights[$r][0]     Id permission (unique tous modules confondus)

-		// $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

-		// $this->rights[$r][2]     Non utilise

-		// $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

-		// $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

-		// $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

+        $r = 0;

+        // $this->rights[$r][0]     Id permission (unique tous modules confondus)

+        // $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

+        // $this->rights[$r][2]     Non utilise

+        // $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

+        // $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

+        // $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

@@ -96,6 +97,6 @@
-		/*$r++;

-		$this->rights[$r][0] = 66000;

-		$this->rights[$r][1] = 'OauthAccess';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'read';*/

+        /*$r++;

+        $this->rights[$r][0] = 66000;

+        $this->rights[$r][1] = 'OauthAccess';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'read';*/

@@ -103,3 +104,3 @@
-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

@@ -107,12 +108,12 @@
-		// This is to declare the Top Menu entry:

-		//$this->menu[$r]=array(  'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',               // Put 0 if this is a top menu

-		//                        'type'=>'left',                 // This is a Top menu entry

-		//                        'titre'=>'MenuOauth',

-		//                        'mainmenu'=>'oauth',

-		//                        'url'=>'/oauth/index.php',

-		//                        'langs'=>'oauth',            // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//                        'position'=>300,

-		//                        'enabled'=>'$conf->oauth->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',

-		//                        'perms'=>'$user->rights->oauth->read',    // Use 'perms'=>'1' if you want your menu with no permission rules

-		//                        'target'=>'',

-		//                        'user'=>0);                     // 0=Menu for internal users, 1=external users, 2=both

+        // This is to declare the Top Menu entry:

+        //$this->menu[$r]=array(  'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',               // Put 0 if this is a top menu

+        //                        'type'=>'left',                 // This is a Top menu entry

+        //                        'titre'=>'MenuOauth',

+        //                        'mainmenu'=>'oauth',

+        //                        'url'=>'/oauth/index.php',

+        //                        'langs'=>'oauth',            // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //                        'position'=>300,

+        //                        'enabled'=>'$conf->oauth->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',

+        //                        'perms'=>'$user->rights->oauth->read',    // Use 'perms'=>'1' if you want your menu with no permission rules

+        //                        'target'=>'',

+        //                        'user'=>0);                     // 0=Menu for internal users, 1=external users, 2=both

@@ -120,2 +121,2 @@
-		//$r++;

-	}

+        //$r++;

+    }

@@ -124,11 +125,11 @@
-	/**

-	 *      Function called when module is enabled.

-	 *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *      It also creates data directories

-	 *

-	 *      @param      string  $options    Options when enabling module ('', 'noboxes')

-	 *      @return     int                 1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf;

+    /**

+     *      Function called when module is enabled.

+     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *      It also creates data directories

+     *

+     *      @param      string  $options    Options when enabling module ('', 'noboxes')

+     *      @return     int                 1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf;

@@ -136,2 +137,2 @@
-		// Clean before activation

-		$this->remove($options);

+        // Clean before activation

+        $this->remove($options);

@@ -139 +140 @@
-		$sql = array();

+        $sql = array();

@@ -141,2 +142,2 @@
-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modOpenSurvey.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modOpenSurvey.class.php
@@ -24 +24 @@
- *      \brief      Description and activation file for the module OpenSurvey

+ *      \brief      Description and activation file for module OpenSurvey

@@ -33,0 +34 @@
+

@@ -39,2 +40,2 @@
-	public function __construct($db)

-	{

+    public function __construct($db)

+    {

@@ -66 +67 @@
-		$this->picto = 'poll';

+		$this->picto = '^date@opensurvey';

@@ -78 +79 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -85 +86 @@
-		$this->dictionaries = array();

+        $this->dictionaries = array();

@@ -121,19 +122,18 @@
-		// Menus

-		//-------

-		$r = 0;

-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'type'=>'left',

-			'titre'=>'Survey',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

-			'mainmenu'=>'tools',

-			'leftmenu'=>'opensurvey',

-			'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey',

-			'langs'=>'opensurvey',

-			'position'=>200,

-			'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.

-			'perms'=>'$user->rights->opensurvey->read',

-			'target'=>'',

-			'user'=>0,

-		);

-		$r++;

+        // Menus

+        //-------

+        $r = 0;

+        $this->menu[$r] = array(

+            'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+            'type'=>'left',

+            'titre'=>'Survey',

+            'mainmenu'=>'tools',

+            'leftmenu'=>'opensurvey',

+            'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey',

+            'langs'=>'opensurvey',

+            'position'=>200,

+            'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.

+            'perms'=>'$user->rights->opensurvey->read',

+            'target'=>'',

+            'user'=>0,

+        );

+        $r++;

@@ -141,15 +141,15 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'type'=>'left',

-			'titre'=>'NewSurvey',

-			'mainmenu'=>'tools',

-			'leftmenu'=>'opensurvey_new',

-			'url'=>'/opensurvey/wizard/index.php',

-			'langs'=>'opensurvey',

-			'position'=>210,

-			'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.

-			'perms'=>'$user->rights->opensurvey->write',

-			'target'=>'',

-			'user'=>0,

-		);

-		$r++;

+        $this->menu[$r] = array(

+            'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+            'type'=>'left',

+            'titre'=>'NewSurvey',

+            'mainmenu'=>'tools',

+            'leftmenu'=>'opensurvey_new',

+            'url'=>'/opensurvey/wizard/index.php',

+            'langs'=>'opensurvey',

+            'position'=>210,

+            'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.

+            'perms'=>'$user->rights->opensurvey->write',

+            'target'=>'',

+            'user'=>0,

+        );

+        $r++;

@@ -157,16 +157,16 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'type'=>'left',

-			'titre'=>'List',

-			'mainmenu'=>'tools',

-			'leftmenu'=>'opensurvey_list',

-			'url'=>'/opensurvey/list.php',

-			'langs'=>'opensurvey',

-			'position'=>220,

-			'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.

-			'perms'=>'$user->rights->opensurvey->read',

-			'target'=>'',

-			'user'=>0,

-		);

-		$r++;

-	}

+        $this->menu[$r] = array(

+            'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+            'type'=>'left',

+            'titre'=>'List',

+            'mainmenu'=>'tools',

+            'leftmenu'=>'opensurvey_list',

+            'url'=>'/opensurvey/list.php',

+            'langs'=>'opensurvey',

+            'position'=>220,

+            'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.

+            'perms'=>'$user->rights->opensurvey->read',

+            'target'=>'',

+            'user'=>0,

+        );

+        $r++;

+    }

@@ -179 +179 @@
-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -182,3 +182,4 @@
-	public function init($options = '')

-	{

-		global $conf, $langs;

+    public function init($options = '')

+    {

+        // Permissions

+        $this->remove($options);

@@ -186,4 +187 @@
-		$result = $this->_load_tables('/install/mysql/', 'opensurvey');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

+        $sql = array();

@@ -191,7 +189,2 @@
-		// Permissions

-		$this->remove($options);

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modPaybox.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPaybox.class.php
@@ -24 +24 @@
- *  \brief      Description and activation file for the module Paybox

+ *  \brief      Description and activation file for module Paybox

@@ -32 +32 @@
-class modPaybox extends DolibarrModules

+class modPayBox extends DolibarrModules

@@ -34,8 +34,8 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

@@ -43,5 +43,5 @@
-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 50000;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'paybox';

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 50000;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'paybox';

@@ -49,15 +49,15 @@
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "interface";

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Module to offer an online payment page by credit card with PayBox";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr_deprecated';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'

-		$this->picto = 'paybox@paybox';

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "interface";

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Module to offer an online payment page by credit card with PayBox";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'

+        $this->picto = 'paybox@paybox';

@@ -65,2 +65,2 @@
-		// Data directories to create when module is enabled.

-		$this->dirs = array('/paybox/temp');

+        // Data directories to create when module is enabled.

+        $this->dirs = array('/paybox/temp');

@@ -68,2 +68,2 @@
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.

-		$this->config_page_url = array("paybox.php@paybox");

+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.

+        $this->config_page_url = array("paybox.php@paybox");

@@ -71,2 +71,2 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -76,3 +76,3 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(2, 6); // Minimum version of Dolibarr required by module

-		$this->langfiles = array("paybox");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(2, 6); // Minimum version of Dolibarr required by module

+        $this->langfiles = array("paybox");

@@ -80,4 +80,4 @@
-		// Constants

-		$this->const = array(); // List of particular constants to add when module is enabled

-		//Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),

-		//                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );

+        // Constants

+        $this->const = array(); // List of particular constants to add when module is enabled

+        //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),

+        //                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );

@@ -85,2 +85,2 @@
-		// New pages on tabs

-		$this->tabs = array();

+        // New pages on tabs

+        $this->tabs = array();

@@ -89,3 +89,3 @@
-		// Boxes

-		$this->boxes = array(); // List of boxes

-		$r = 0;

+        // Boxes

+        $this->boxes = array(); // List of boxes

+        $r = 0;

@@ -93,6 +93,6 @@
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.

-		// Example:

-		//$this->boxes[$r][1] = "myboxa.php";

-		//$r++;

-		//$this->boxes[$r][1] = "myboxb.php";

-		//$r++;

+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.

+        // Example:

+        //$this->boxes[$r][1] = "myboxa.php";

+        //$r++;

+        //$this->boxes[$r][1] = "myboxb.php";

+        //$r++;

@@ -101,3 +101,3 @@
-		// Permissions

-		$this->rights = array(); // Permission array used by this module

-		$r = 0;

+        // Permissions

+        $this->rights = array(); // Permission array used by this module

+        $r = 0;

@@ -105,8 +105,8 @@
-		// Add here list of permission defined by an id, a label, a boolean and two constant strings.

-		// Example:

-		// $this->rights[$r][0] = 2000; 				// Permission id (must not be already used)

-		// $this->rights[$r][1] = 'Permision label';	// Permission label

-		// $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

-		// $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		// $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		// $r++;

+        // Add here list of permission defined by an id, a label, a boolean and two constant strings.

+        // Example:

+        // $this->rights[$r][0] = 2000; 				// Permission id (must not be already used)

+        // $this->rights[$r][1] = 'Permision label';	// Permission label

+        // $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)

+        // $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+        // $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+        // $r++;

@@ -115,3 +115,3 @@
-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

@@ -119,39 +119,39 @@
-		// Add here entries to declare new menus

-		// Example to declare the Top Menu entry:

-		// $this->menu[$r]=array(	'fk_menu'=>0,			// Put 0 if this is a top menu

-		//							'type'=>'top',			// This is a Top menu entry

-		//							'titre'=>'MyModule top menu',

-		//							'mainmenu'=>'mymodule',

-		//							'url'=>'/mymodule/pagetop.php',

-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//							'position'=>100,

-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-		//							'target'=>'',

-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

-		// $r++;

-		//

-		// Example to declare a Left Menu entry:

-		// $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

-		//							'type'=>'left',			// This is a Left menu entry

-		//							'titre'=>'MyModule left menu 1',

-		//							'mainmenu'=>'mymodule',

-		//							'url'=>'/mymodule/pagelevel1.php',

-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//							'position'=>100,

-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-		//							'target'=>'',

-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

-		// $r++;

-		//

-		// Example to declare another Left Menu entry:

-		// $this->menu[$r]=array(	'fk_menu'=>'r=1',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

-		//							'type'=>'left',			// This is a Left menu entry

-		//							'titre'=>'MyModule left menu 2',

-		//							'mainmenu'=>'mymodule',

-		//							'url'=>'/mymodule/pagelevel2.php',

-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//							'position'=>100,

-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-		//							'target'=>'',

-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

-		// $r++;

+        // Add here entries to declare new menus

+        // Example to declare the Top Menu entry:

+        // $this->menu[$r]=array(	'fk_menu'=>0,			// Put 0 if this is a top menu

+        //							'type'=>'top',			// This is a Top menu entry

+        //							'titre'=>'MyModule top menu',

+        //							'mainmenu'=>'mymodule',

+        //							'url'=>'/mymodule/pagetop.php',

+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //							'position'=>100,

+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        //							'target'=>'',

+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+        // $r++;

+        //

+        // Example to declare a Left Menu entry:

+        // $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

+        //							'type'=>'left',			// This is a Left menu entry

+        //							'titre'=>'MyModule left menu 1',

+        //							'mainmenu'=>'mymodule',

+        //							'url'=>'/mymodule/pagelevel1.php',

+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //							'position'=>100,

+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        //							'target'=>'',

+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+        // $r++;

+        //

+        // Example to declare another Left Menu entry:

+        // $this->menu[$r]=array(	'fk_menu'=>'r=1',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

+        //							'type'=>'left',			// This is a Left menu entry

+        //							'titre'=>'MyModule left menu 2',

+        //							'mainmenu'=>'mymodule',

+        //							'url'=>'/mymodule/pagelevel2.php',

+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //							'position'=>100,

+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        //							'target'=>'',

+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+        // $r++;

@@ -160,2 +160,2 @@
-		// Exports

-		$r = 1;

+        // Exports

+        $r = 1;

@@ -163,28 +163,28 @@
-		// Example:

-		// $this->export_code[$r]=$this->rights_class.'_'.$r;

-		// $this->export_label[$r]='CustomersInvoicesAndInvoiceLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

-		// $this->export_permission[$r]=array(array("facture","facture","export"));

-		// $this->export_fields_array[$r]=array(

-		//     's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',

-		//     's.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3',

-		//     's.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',

-		//     'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",

-		//     'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId',

-		//     'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",

-		//     'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef',

-		// );

-		// $this->export_entities_array[$r]=array(

-		//     's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',

-		//     's.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company',

-		//     's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",

-		//     'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',

-		//     'f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",

-		//     'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",

-		//     'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product',

-		// );

-		// $this->export_sql_start[$r]='SELECT DISTINCT ';

-		// $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';

-		// $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';

-		// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';

-		// $r++;

-	}

+        // Example:

+        // $this->export_code[$r]=$this->rights_class.'_'.$r;

+        // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

+        // $this->export_permission[$r]=array(array("facture","facture","export"));

+        // $this->export_fields_array[$r]=array(

+        //     's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',

+        //     's.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3',

+        //     's.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',

+        //     'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",

+        //     'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId',

+        //     'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",

+        //     'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef',

+        // );

+        // $this->export_entities_array[$r]=array(

+        //     's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',

+        //     's.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company',

+        //     's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",

+        //     'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',

+        //     'f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",

+        //     'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",

+        //     'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product',

+        // );

+        // $this->export_sql_start[$r]='SELECT DISTINCT ';

+        // $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';

+        // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';

+        // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';

+        // $r++;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modPaymentByBankTransfer.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPaymentByBankTransfer.class.php
@@ -26 +26 @@
- *	\brief      	Description and activation file for the module PaymentByBankTransfer

+ *	\brief      	File to describe and activate the module PaymentByBankTransfer

@@ -36,0 +37 @@
+

@@ -56 +57 @@
-		$this->version = 'dolibarr';

+		$this->version = 'development';

@@ -70 +71 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -122,4 +123,4 @@
-		// Menus

-		//-------

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

-	}

+        // Menus

+        //-------

+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.

+    }

@@ -128,11 +129,11 @@
-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories

-	 *

-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf;

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf;

@@ -140,2 +141,2 @@
-		// Permissions

-		$this->remove($options);

+        // Permissions

+        $this->remove($options);

@@ -143 +144 @@
-		$sql = array();

+        $sql = array();

@@ -145,2 +146,2 @@
-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modPaypal.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPaypal.class.php
@@ -25 +25 @@
- *  \brief      Description and activation file for the module Paypal

+ *  \brief      Description and activation file for module Paypal

@@ -35,8 +35,8 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

@@ -44,5 +44,5 @@
-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 50200;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'paypal';

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 50200;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'paypal';

@@ -50,15 +50,15 @@
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "interface";

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Module to offer an online payment page with PayPal";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'

-		$this->picto = 'paypal@paypal';

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "interface";

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Module to offer an online payment page with PayPal";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'

+        $this->picto = 'paypal@paypal';

@@ -66,2 +66,2 @@
-		// Data directories to create when module is enabled.

-		$this->dirs = array('/paypal/temp');

+        // Data directories to create when module is enabled.

+        $this->dirs = array('/paypal/temp');

@@ -69,2 +69,2 @@
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.

-		$this->config_page_url = array("paypal.php@paypal");

+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.

+        $this->config_page_url = array("paypal.php@paypal");

@@ -72,2 +72,2 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -75 +75 @@
-		$this->requiredby = array(); // List of module ids to disable if this one is disabled

+		$this->requiredby = array('modPaypalPlus'); // List of module ids to disable if this one is disabled

@@ -77,3 +77,3 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module

-		$this->langfiles = array("paypal");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module

+        $this->langfiles = array("paypal");

@@ -81,4 +81,4 @@
-		// Constants

-		$this->const = array(); // List of particular constants to add when module is enabled

-		//Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),

-		//                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );

+        // Constants

+        $this->const = array(); // List of particular constants to add when module is enabled

+        //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),

+        //                            1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );

@@ -86,2 +86,2 @@
-		// New pages on tabs

-		$this->tabs = array();

+        // New pages on tabs

+        $this->tabs = array();

@@ -90,3 +90,3 @@
-		// Boxes

-		$this->boxes = array(); // List of boxes

-		$r = 0;

+        // Boxes

+        $this->boxes = array(); // List of boxes

+        $r = 0;

@@ -94,6 +94,6 @@
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.

-		// Example:

-		//$this->boxes[$r][1] = "myboxa.php";

-		//$r++;

-		//$this->boxes[$r][1] = "myboxb.php";

-		//$r++;

+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.

+        // Example:

+        //$this->boxes[$r][1] = "myboxa.php";

+        //$r++;

+        //$this->boxes[$r][1] = "myboxb.php";

+        //$r++;

@@ -102,3 +102,3 @@
-		// Permissions

-		$this->rights = array(); // Permission array used by this module

-		$r = 0;

+        // Permissions

+        $this->rights = array(); // Permission array used by this module

+        $r = 0;

@@ -107,18 +107,18 @@
-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

-		/*$this->menu[$r]=array(

-			'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'mainmenu'=>'billing',

-			'leftmenu'=>'customers_bills_payment_paypal',

-			'type'=>'left',			                // This is a Left menu entry

-			'titre'=>'PaypalImportPayment',

-			'url'=>'/paypal/importpayments.php',

-			'langs'=>'paypal',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>501,

-			'enabled'=>'$conf->paypal->enabled && isModEnabled("banque") && $conf->global->MAIN_FEATURES_LEVEL >= 2',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'$user->rights->banque->consolidate',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-			'target'=>'',

-			'user'=>2

-		);				                // 0=Menu for internal users, 1=external users, 2=both

-		$r++;*/

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

+        /*$this->menu[$r]=array(

+	        'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+	        'mainmenu'=>'billing',

+	        'leftmenu'=>'customers_bills_payment_paypal',

+	        'type'=>'left',			                // This is a Left menu entry

+	        'titre'=>'PaypalImportPayment',

+	        'url'=>'/paypal/importpayments.php',

+	        'langs'=>'paypal',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+	        'position'=>501,

+	        'enabled'=>'$conf->paypal->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+	        'perms'=>'$user->rights->banque->consolidate',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+	        'target'=>'',

+	        'user'=>2

+        );				                // 0=Menu for internal users, 1=external users, 2=both

+        $r++;*/

@@ -126,39 +126,39 @@
-		// Add here entries to declare new menus

-		// Example to declare the Top Menu entry:

-		// $this->menu[$r]=array(	'fk_menu'=>0,			// Put 0 if this is a top menu

-		//							'type'=>'top',			// This is a Top menu entry

-		//							'titre'=>'MyModule top menu',

-		//							'mainmenu'=>'mymodule',

-		//							'url'=>'/mymodule/pagetop.php',

-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//							'position'=>100,

-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-		//							'target'=>'',

-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

-		// $r++;

-		//

-		// Example to declare a Left Menu entry:

-		// $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

-		//							'type'=>'left',			// This is a Left menu entry

-		//							'titre'=>'MyModule left menu 1',

-		//							'mainmenu'=>'mymodule',

-		//							'url'=>'/mymodule/pagelevel1.php',

-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//							'position'=>100,

-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-		//							'target'=>'',

-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

-		// $r++;

-		//

-		// Example to declare another Left Menu entry:

-		// $this->menu[$r]=array(	'fk_menu'=>'r=1',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

-		//							'type'=>'left',			// This is a Left menu entry

-		//							'titre'=>'MyModule left menu 2',

-		//							'mainmenu'=>'mymodule',

-		//							'url'=>'/mymodule/pagelevel2.php',

-		//							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//							'position'=>100,

-		//							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-		//							'target'=>'',

-		//							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

-		// $r++;

+        // Add here entries to declare new menus

+        // Example to declare the Top Menu entry:

+        // $this->menu[$r]=array(	'fk_menu'=>0,			// Put 0 if this is a top menu

+        //							'type'=>'top',			// This is a Top menu entry

+        //							'titre'=>'MyModule top menu',

+        //							'mainmenu'=>'mymodule',

+        //							'url'=>'/mymodule/pagetop.php',

+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //							'position'=>100,

+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        //							'target'=>'',

+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+        // $r++;

+        //

+        // Example to declare a Left Menu entry:

+        // $this->menu[$r]=array(	'fk_menu'=>'r=0',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

+        //							'type'=>'left',			// This is a Left menu entry

+        //							'titre'=>'MyModule left menu 1',

+        //							'mainmenu'=>'mymodule',

+        //							'url'=>'/mymodule/pagelevel1.php',

+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //							'position'=>100,

+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        //							'target'=>'',

+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+        // $r++;

+        //

+        // Example to declare another Left Menu entry:

+        // $this->menu[$r]=array(	'fk_menu'=>'r=1',		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)

+        //							'type'=>'left',			// This is a Left menu entry

+        //							'titre'=>'MyModule left menu 2',

+        //							'mainmenu'=>'mymodule',

+        //							'url'=>'/mymodule/pagelevel2.php',

+        //							'langs'=>'mylangfile',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //							'position'=>100,

+        //							'perms'=>'1',			// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+        //							'target'=>'',

+        //							'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both

+        // $r++;

@@ -167,2 +167,2 @@
-		// Exports

-		$r = 1;

+        // Exports

+        $r = 1;

@@ -170,27 +170,27 @@
-		// Example:

-		// $this->export_code[$r]=$this->rights_class.'_'.$r;

-		// $this->export_label[$r]='CustomersInvoicesAndInvoiceLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

-		// $this->export_permission[$r]=array(array("facture","facture","export"));

-		// $this->export_fields_array[$r]=array(

-		//    's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',

-		//    's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',

-		//    's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",

-		//    'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

-		//    'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",

-		//    'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",

-		//    'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'

-		// );

-		// $this->export_entities_array[$r]=array(

-		//    's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',

-		//    's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',

-		//    'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",

-		//    'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",

-		//    'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",

-		//    'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'

-		// );

-		// $this->export_sql_start[$r]='SELECT DISTINCT ';

-		// $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';

-		// $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';

-		// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';

-		// $r++;

-	}

+        // Example:

+        // $this->export_code[$r]=$this->rights_class.'_'.$r;

+        // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines';	// Translation key (used only if key ExportDataset_xxx_z not found)

+        // $this->export_permission[$r]=array(array("facture","facture","export"));

+        // $this->export_fields_array[$r]=array(

+        //    's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',

+        //    's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',

+        //    's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",

+        //    'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',

+        //    'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",

+        //    'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",

+        //    'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'

+        // );

+        // $this->export_entities_array[$r]=array(

+        //    's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',

+        //    's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',

+        //    'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",

+        //    'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",

+        //    'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",

+        //    'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'

+        // );

+        // $this->export_sql_start[$r]='SELECT DISTINCT ';

+        // $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';

+        // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';

+        // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';

+        // $r++;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modPrelevement.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPrelevement.class.php
@@ -26 +26 @@
- *	\brief      	Description and activation file for the module Prelevement

+ *	\brief      	File to describe and enable the module Prelevement

@@ -70 +70 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -126,4 +126,4 @@
-		// Menus

-		//-------

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

-	}

+        // Menus

+        //-------

+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.

+    }

@@ -132,11 +132,11 @@
-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories

-	 *

-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf;

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf;

@@ -144,2 +144,2 @@
-		// Permissions

-		$this->remove($options);

+        // Permissions

+        $this->remove($options);

@@ -147,4 +147,4 @@
-		$sql = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".((int) $conf->entity).")",

-		);

+        $sql = array(

+            "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity,

+            "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")",

+        );

@@ -152,2 +152,2 @@
-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modPrinting.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPrinting.class.php
@@ -26 +26 @@
- *  \brief      Description and activation file for the module Direct Printing

+ *  \brief      File of class to describe and activate module Direct Printing

@@ -37,23 +36,0 @@
-	/**

-	 *  Constructor

-	 *

-	 *  @param      DoliDB      $db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-		$this->numero = 64000;

-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "interface";

-		$this->module_position = '52';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Enable Direct Printing System.";

-		$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'printer';

@@ -61,2 +38,23 @@
-		// Data directories to create when module is enabled.

-		$this->dirs = array();

+    /**

+     *  Constructor

+     *

+     *  @param      DoliDB      $db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+        $this->numero = 64000;

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "interface";

+        $this->module_position = '52';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Enable Direct Printing System.";

+        $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'printer';

@@ -64,2 +62,2 @@
-		// Config pages

-		$this->config_page_url = array("printing.php@printing");

+        // Data directories to create when module is enabled.

+        $this->dirs = array();

@@ -67,2 +65,5 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Config pages

+        $this->config_page_url = array("printing.php@printing");

+

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -72,4 +73,4 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module

-		$this->conflictwith = array();

-		$this->langfiles = array("printing");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module

+        $this->conflictwith = array();

+        $this->langfiles = array("printing");

@@ -77,2 +78,2 @@
-		// Constants

-		$this->const = array();

+        // Constants

+        $this->const = array();

@@ -80,2 +81,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -83,3 +84,3 @@
-		// Permissions

-		$this->rights = array();

-		$this->rights_class = 'printing';

+        // Permissions

+        $this->rights = array();

+        $this->rights_class = 'printing';

@@ -87,7 +88,7 @@
-		$r = 0;

-		// $this->rights[$r][0]     Id permission (unique tous modules confondus)

-		// $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

-		// $this->rights[$r][2]     Non utilise

-		// $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

-		// $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

-		// $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

+        $r = 0;

+        // $this->rights[$r][0]     Id permission (unique tous modules confondus)

+        // $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

+        // $this->rights[$r][2]     Non utilise

+        // $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

+        // $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

+        // $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

@@ -95,6 +96,6 @@
-		$r++;

-		$this->rights[$r][0] = 64001;

-		$this->rights[$r][1] = 'DirectPrint';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'read';

+        $r++;

+        $this->rights[$r][0] = 64001;

+        $this->rights[$r][1] = 'DirectPrint';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'read';

@@ -102,3 +103,3 @@
-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

@@ -106,11 +107,11 @@
-		// This is to declare the Top Menu entry:

-		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu

-								'type'=>'left', // This is a Top menu entry

-								'titre'=>'MenuDirectPrinting',

-								'url'=>'/printing/index.php?mainmenu=home&leftmenu=admintools',

-								'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-								'position'=>300,

-								'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)',

-								'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules

-								'target'=>'',

-								'user'=>0); // 0=Menu for internal users, 1=external users, 2=both

+        // This is to declare the Top Menu entry:

+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu

+                                'type'=>'left', // This is a Top menu entry

+                                'titre'=>'MenuDirectPrinting',

+                                'url'=>'/printing/index.php?mainmenu=home&leftmenu=admintools',

+                                'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+                                'position'=>300,

+                                'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)',

+                                'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules

+                                'target'=>'',

+                                'user'=>0); // 0=Menu for internal users, 1=external users, 2=both

@@ -118,2 +119,2 @@
-		$r++;

-	}

+        $r++;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modProduct.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modProduct.class.php
@@ -2,9 +2,9 @@
-/* Copyright (C) 2003		Rodolphe Quiedeville	<rodolphe@quiedeville.org>

- * Copyright (C) 2004-2012	Laurent Destailleur		<eldy@users.sourceforge.net>

- * Copyright (C) 2004		Sebastien Di Cintio		<sdicintio@ressource-toi.org>

- * Copyright (C) 2004		Benoit Mortier			<benoit.mortier@opensides.be>

- * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@inodbox.com>

- * Copyright (C) 2012-2013	Juanjo Menent			<jmenent@2byte.es>

- * Copyright (C) 2014		Christophe Battarel		<contact@altairis.fr>

- * Copyright (C) 2014		Cedric Gross			<c.gross@kreiz-it.fr>

- * Copyright (C) 2020-2021	Alexandre Spangaro		<aspangaro@open-dsi.fr>

+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>

+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>

+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>

+ * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@inodbox.com>

+ * Copyright (C) 2012-2013 Juanjo Menent		<jmenent@2byte.es>

+ * Copyright (C) 2014      Christophe Battarel	<contact@altairis.fr>

+ * Copyright (C) 2014      Cedric Gross			<c.gross@kreiz-it.fr>

+ * Copyright (C) 2020	   Alexandre Spangaro	<aspangaro@open-dsi.fr>

@@ -31 +31 @@
- *	\brief      Description and activation file for the module to manage catalog of predefined products

+ *	\brief      File to describe module to manage catalog of predefined products

@@ -54 +54 @@
-		$this->module_position = '26';

+		$this->module_position = '25';

@@ -71 +71 @@
-		$this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants", "modBom"); // List of module ids to disable if this one is disabled

+		$this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled

@@ -73 +73 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -107 +107 @@
-			1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>'Home'),

+			1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>''),

@@ -130,8 +129,0 @@
-		$this->rights[$r][0] = 33; // id de la permission

-		$this->rights[$r][1] = 'Read prices products'; // libelle de la permission

-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'product_advance';

-		$this->rights[$r][5] = 'read_prices';

-		$r++;

-

@@ -143 +135 @@
-		$r++;

+        $r++;

@@ -150 +142 @@
-		$r++;

+        $r++;

@@ -157,6 +149,6 @@
-		$r++;

-

-		// Menus

-		//-------

-

-		$this->menu = 1; // This module adds menu entries. They are coded into menu manager.

+        $r++;

+

+        // Menus

+        //-------

+

+        $this->menu = 1; // This module adds menu entries. They are coded into menu manager.

@@ -171 +163 @@
-								'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+								'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

@@ -178,5 +169,0 @@
-		$usenpr = 0;

-		if (is_object($mysoc)) {

-			$usenpr = $mysoc->useNPR();

-		}

-

@@ -186,2 +172,0 @@
-

-		$alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe";

@@ -198,3 +183,3 @@
-			$alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

-			$alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode",

-			$alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

+			'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

+			'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",

+			'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

@@ -207 +191,0 @@
-			'p.price_min'=>"MinPriceHT",'p.price_min_ttc'=>"MinPriceTTC",

@@ -211,15 +195,5 @@
-		if (is_object($mysoc) && $usenpr) {

-			$this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice'));

-		}

-		if (isModEnabled('stock')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('e.ref'=>'DefaultWarehouse', 'p.tobatch'=>'ManageLotSerial', 'p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-		}

-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra';

+		if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';

+		if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice'));

+		if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

+		if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';

@@ -227,12 +201,4 @@
-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote'));

-		}

-		if (getDolGlobalInt('PRODUCT_USE_UNITS')) {

-			$this->export_fields_array[$r]['p.fk_unit'] = 'Unit';

-		}

+		if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote'));

+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';

@@ -243,2 +209,2 @@
-			$alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text",

-			$alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text",

+			'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text",

+			'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",

@@ -250,3 +216 @@
-			'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric",

-			'p.price_min'=>"Numeric", 'p.price_min_ttc'=>"Numeric",

-			'p.tva_tx'=>'Numeric',

+			'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric',

@@ -255,15 +219,5 @@
-		if (isModEnabled('stock')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('e.ref'=>'Text', 'p.tobatch'=>'Numeric', 'p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text'));

-		}

+		if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

+		if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

+		if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text'));

@@ -271,33 +225,11 @@
-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category'));

-		}

-		if (isModEnabled('stock')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_dependencies_array[$r] = array('category'=>'p.rowid');

-		}

-		if (isModEnabled('stock')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_dependencies_array[$r] = array('category'=>'p.rowid');

-		}

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category'));

+		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

+		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

+		if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid');

+		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

+		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

+		if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid');

@@ -306,9 +238,2 @@
-		if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {

-			$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid';

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';

-		}

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid';

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';

@@ -316,6 +241 @@
-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';

-		}

-		if (isModEnabled('stock')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = p.fk_default_warehouse';

-		}

+		if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';

@@ -323,5 +243,4 @@
-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields"

-		}

-

-		if (getDolGlobalString('PRODUIT_MULTIPRICES')) {

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields"

+

+		if (!empty($conf->global->PRODUIT_MULTIPRICES))

+		{

@@ -333 +252 @@
-			$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label",

+			$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",

@@ -339,3 +258 @@
-			if (is_object($mysoc) && $usenpr) {

-				$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

-			}

+			if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

@@ -348 +265 @@
-			$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 'p.label'=>"Label",

+			$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",

@@ -359,2 +275,0 @@
-			$this->export_sql_end[$r] .= ' AND pr.date_price = (SELECT MAX(pr2.date_price) FROM '.MAIN_DB_PREFIX.'product_price as pr2 WHERE pr2.fk_product = pr.fk_product AND pr2.price_level = pr.price_level AND pr2.entity IN ('.getEntity('product').'))'; // export only latest prices not full history

-			$this->export_sql_end[$r] .= ' ORDER BY p.ref, pr.price_level';

@@ -363,33 +278,30 @@
-		if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {

-			// Exports product multiprice

-			$r++;

-			$this->export_code[$r] = $this->rights_class.'_'.$r;

-			$this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)

-			$this->export_permission[$r] = array(array("produit", "export"));

-			$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label",

-				's.nom'=>'ThirdParty',

-				's.code_client'=>'CodeClient',

-				'pr.price_base_type'=>"PriceBase",

-				'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",

-				'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",

-				'pr.tva_tx'=>'PriceVATRate',

-				'pr.default_vat_code'=>'PriceVATCode',

-				'pr.datec'=>'DateCreation');

-			if (is_object($mysoc) && $usenpr) {

-				$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

-			}

-			$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 'p.label'=>"Label",

-				's.nom'=>'company',

-				's.code_client'=>'company',

-				'pr.price_base_type'=>"product", 'pr.price'=>"product",

-				'pr.price_ttc'=>"product",

-				'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",

-				'pr.tva_tx'=>'product',

-				'pr.default_vat_code'=>'product',

-				'pr.recuperableonly'=>'product',

-				'pr.datec'=>"product");

-			$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-			$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';

-			$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

+		if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))

+		{

+		    // Exports product multiprice

+		    $r++;

+		    $this->export_code[$r] = $this->rights_class.'_'.$r;

+		    $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)

+		    $this->export_permission[$r] = array(array("produit", "export"));

+		    $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",

+		        's.nom'=>'ThirdParty',

+		        'pr.price_base_type'=>"PriceBase",

+		        'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",

+		        'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",

+		        'pr.tva_tx'=>'PriceVATRate',

+		        'pr.default_vat_code'=>'PriceVATCode',

+		        'pr.datec'=>'DateCreation');

+		    if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

+		    $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",

+		        's.nom'=>'company',

+		        'pr.price_base_type'=>"product", 'pr.price'=>"product",

+		        'pr.price_ttc'=>"product",

+		        'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",

+		        'pr.tva_tx'=>'product',

+		        'pr.default_vat_code'=>'product',

+		        'pr.recuperableonly'=>'product',

+		        'pr.datec'=>"product");

+		    $this->export_sql_start[$r] = 'SELECT DISTINCT ';

+		    $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';

+		    $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

@@ -398 +310,2 @@
-		if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) {

+		if (!empty($conf->global->PRODUIT_SOUSPRODUITS))

+		{

@@ -400,5 +313,5 @@
-			$r++;

-			$this->export_code[$r] = $this->rights_class.'_'.$r;

-			$this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)

-			$this->export_permission[$r] = array(array("produit", "export"));

-			$this->export_fields_array[$r] = array(

+        	$r++;

+    		$this->export_code[$r] = $this->rights_class.'_'.$r;

+    		$this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)

+    		$this->export_permission[$r] = array(array("produit", "export"));

+    		$this->export_fields_array[$r] = array(

@@ -406,5 +319,5 @@
-				$alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

-				$alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode",

-				$alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

-				'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',

-				'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',

+				'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

+                'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",

+                'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

+    			'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',

+    			'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',

@@ -414,8 +327,4 @@
-			if (isModEnabled('stock')) {

-				$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

-			}

-			if (isModEnabled('barcode')) {

-				$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-			}

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));

-			$this->export_TypeFields_array[$r] = array(

+    		if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

+    		if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

+    		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));

+    		$this->export_TypeFields_array[$r] = array(

@@ -423,4 +332,4 @@
-				$alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text",

-				$alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text",

-				'p.note'=>"Text", 'p.note_public'=>"Text",

-				'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',

+    			'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text",

+    			'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",

+    			'p.note'=>"Text", 'p.note_public'=>"Text",

+    			'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',

@@ -430,8 +339,4 @@
-			if (isModEnabled('stock')) {

-				$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

-			}

-			if (isModEnabled('barcode')) {

-				$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-			}

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));

-			$this->export_entities_array[$r] = array(

+    		if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

+    		if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

+    		$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));

+    		$this->export_entities_array[$r] = array(

@@ -439,2 +344,2 @@
-				$alias_product_perentity . '.accountancy_code_sell'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export'=>'virtualproduct',

-				$alias_product_perentity . '.accountancy_code_buy'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export'=>'virtualproduct',

+				'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct',

+                'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct',

@@ -446,22 +351,13 @@
-			if (isModEnabled('stock')) {

-				$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));

-			}

-			if (isModEnabled('barcode')) {

-				$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));

-			}

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));

-			$keyforselect = 'product';

-			$keyforelement = 'product';

-			$keyforaliasextra = 'extra';

-			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));

-			$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-			$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

-			if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {

-				$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);

-			}

-			$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';

-			$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';

-			$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

-			$this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';

+    		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));

+    		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));

+            $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));

+    		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';

+    		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+            $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));

+    		$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));

+    		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

+    		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

+    		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';

+    		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';

+    		$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

+    		$this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';

@@ -484,2 +380,2 @@
-			'p.ref' => "Ref*",

-			'p.label' => "Label*",

+	        'p.ref' => "Ref*",

+            'p.label' => "Label*",

@@ -492,5 +388,5 @@
-			'p.fk_country' => 'CountryCode',

-			'p.accountancy_code_sell' => "ProductAccountancySellCode",

-			'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",

-			'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",

-			'p.accountancy_code_buy' => "ProductAccountancyBuyCode",

+            'p.fk_country' => 'CountryCode',

+            'p.accountancy_code_sell' => "ProductAccountancySellCode",

+            'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",

+            'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",

+            'p.accountancy_code_buy' => "ProductAccountancyBuyCode",

@@ -502,2 +398,2 @@
-			'p.weight_units' => "WeightUnits",

-			'p.length' => "Length",

+            'p.weight_units' => "WeightUnits",

+            'p.length' => "Length",

@@ -505 +401 @@
-			'p.width' => "Width",

+            'p.width' => "Width",

@@ -507,5 +403,5 @@
-			'p.height' => "Height",

-			'p.height_units' => "HeightUnits",

-			'p.surface' => "Surface",

-			'p.surface_units' => "SurfaceUnits",

-			'p.volume' => "Volume",

+            'p.height' => "Height",

+            'p.height_units' => "HeightUnits",

+            'p.surface' => "Surface",

+            'p.surface_units' => "SurfaceUnits",

+            'p.volume' => "Volume",

@@ -522 +418 @@
-			'p.cost_price' => "CostPrice"

+			'p.cost_price' => "CostPrice",

@@ -524,4 +420,11 @@
-

-		$this->import_convertvalue_array[$r] = array(

-				'p.weight_units' => array(

-						'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        if (!empty($conf->stock->enabled)) {//if Stock module enabled

+            $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

+                'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning

+                'p.pmp' => 'PMPValue', //weighted average price

+                'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature

+            ));

+        }

+

+        $this->import_convertvalue_array[$r] = array(

+        	    'p.weight_units' => array(

+	        	    	'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

@@ -574,20 +477,7 @@
-				'p.fk_country' => array(

-					'rule' => 'fetchidfromcodeid',

-					'classfile' => '/core/class/ccountry.class.php',

-					'class' => 'Ccountry',

-					'method' => 'fetch',

-					'dict' => 'DictionaryCountry'

-				),

-				'p.finished'=> array(

-					'rule' => 'fetchidfromcodeorlabel',

-					'classfile' => '/core/class/cproductnature.class.php',

-					'class' => 'CProductNature',

-					'method' => 'fetch',

-					'dict' => 'DictionaryProductNature'

-				),

-				'p.accountancy_code_sell'=>array('rule'=>'accountingaccount'),

-				'p.accountancy_code_sell_intra'=>array('rule'=>'accountingaccount'),

-				'p.accountancy_code_sell_export'=>array('rule'=>'accountingaccount'),

-				'p.accountancy_code_buy'=>array('rule'=>'accountingaccount'),

-				'p.accountancy_code_buy_intra'=>array('rule'=>'accountingaccount'),

-				'p.accountancy_code_buy_export'=>array('rule'=>'accountingaccount'),

+                'p.fk_country' => array(

+                    'rule' => 'fetchidfromcodeid',

+                    'classfile' => '/core/class/ccountry.class.php',

+                    'class' => 'Ccountry',

+                    'method' => 'fetch',

+                    'dict' => 'DictionaryCountry'

+                )

@@ -596,53 +486,6 @@
-		$this->import_regex_array[$r] = array(

-			'p.ref' => '[^ ]',

-			'p.price_base_type' => '\AHT\z|\ATTC\z',

-			'p.tosell' => '^[0|1]$',

-			'p.tobuy' => '^[0|1]$',

-			'p.fk_product_type' => '^[0|1]$',

-			'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

-			'p.recuperableonly' => '^[0|1]$',

-		);

-

-		if (isModEnabled('stock')) {//if Stock module enabled

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

-				'p.fk_default_warehouse'=>'DefaultWarehouse',

-				'p.tobatch'=>'ManageLotSerial',

-				'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning

-				'p.pmp' => 'PMPValue', //weighted average price

-				'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature

-			));

-

-			$this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(

-				'p.tobatch' => '^[0|1|2]$'

-			));

-

-			$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(

-					'p.fk_default_warehouse' => array(

-					'rule' => 'fetchidfromref',

-					'classfile' => '/product/stock/class/entrepot.class.php',

-					'class' => 'Entrepot',

-					'method' => 'fetch',

-					'element'=> 'Warehouse'

-				)

-			));

-		}

-

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));

-		}

-		if (is_object($mysoc) && $usenpr) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type'));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));

-		}

-		if (getDolGlobalInt('PRODUCT_USE_UNITS')) {

-			$this->import_fields_array[$r]['p.fk_unit'] = 'Unit';

-		}

-

+		if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));

+		if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));

+		if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type'));

+		if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));

+		if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));

+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';

@@ -651 +494 @@
-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")";

+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")";

@@ -653,7 +496,9 @@
-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+		    while ($obj = $this->db->fetch_object($resql))

+		    {

+		        $fieldname = 'extra.'.$obj->name;

+		        $fieldlabel = ucfirst($obj->label);

+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

+		        $import_extrafield_sample[$fieldname] = $fieldlabel;

+		    }

@@ -662,0 +508,10 @@
+		$this->import_regex_array[$r] = array(

+            'p.ref' => '[^ ]',

+            'p.price_base_type' => '\AHT\z|\ATTC\z',

+            'p.tosell' => '^[0|1]$',

+            'p.tobuy' => '^[0|1]$',

+            'p.fk_product_type' => '^[0|1]$',

+            'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

+            'p.recuperableonly' => '^[0|1]$',

+            'p.finished' => '^[0|1]$'

+        );

@@ -666,9 +521,9 @@
-			'p.ref' => "ref:PREF123456",

-			'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),

-			'p.label' => "Product name in default language",

-			'p.description' => "Product description in default language",

-			'p.note_public' => "a public note (free text)",

-			'p.note' => "a private note (free text)",

-			'p.customcode' => 'customs code',

-			'p.fk_country' => 'FR',

-			'p.price' => "100",

+            'p.ref' => "PREF123456",

+            'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),

+            'p.label' => "Product name in default language",

+            'p.description' => "Product description in default language",

+            'p.note_public' => "a public note (free text)",

+            'p.note' => "a private note (free text)",

+            'p.customcode' => 'customs code',

+            'p.fk_country' => 'FR',

+            'p.price' => "100",

@@ -676 +531 @@
-			'p.price_ttc' => "110",

+            'p.price_ttc' => "110",

@@ -678,14 +533,14 @@
-			'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",

-			'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'

-			'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",

-			'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",

-			'p.fk_product_type' => "0 (product) / 1 (service)",

-			'p.duration' => "eg. 365d/12m/1y",

-			'p.url' => 'link to product (no https)',

-			'p.accountancy_code_sell' => "",

-			'p.accountancy_code_sell_intra' => "",

-			'p.accountancy_code_sell_export' => "",

-			'p.accountancy_code_buy' => "",

-			'p.accountancy_code_buy_intra' => "",

-			'p.accountancy_code_buy_export' => "",

-			'p.weight' => "",

+            'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",

+            'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'

+            'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",

+            'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",

+            'p.fk_product_type' => "0 (product) / 1 (service)",

+            'p.duration' => "eg. 365d/12m/1y",

+            'p.url' => 'link to product (no https)',

+            'p.accountancy_code_sell' => "",

+            'p.accountancy_code_sell_intra' => "",

+            'p.accountancy_code_sell_export' => "",

+            'p.accountancy_code_buy' => "",

+            'p.accountancy_code_buy_intra' => "",

+            'p.accountancy_code_buy_export' => "",

+            'p.weight' => "",

@@ -693 +548 @@
-			'p.length' => "",

+            'p.length' => "",

@@ -695 +550 @@
-			'p.width' => "",

+            'p.width' => "",

@@ -697 +552 @@
-			'p.height' => "",

+            'p.height' => "",

@@ -699 +554 @@
-			'p.surface' => "",

+            'p.surface' => "",

@@ -701 +556 @@
-			'p.volume' => "",

+            'p.volume' => "",

@@ -703,34 +558,22 @@
-			'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"'

-		);

-		//clauses copied from import_fields_array

-		if (isModEnabled('stock')) {

-			$import_sample = array_merge($import_sample, array(

-				'p.tobatch'=>"0 (don't use) / 1 (use batch) / 2 (use serial number)",

-				'p.seuil_stock_alerte' => '',

-				'p.pmp' => '0',

-				'p.desiredstock' => ''

-			));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {

-			$import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));

-		}

-		if (is_object($mysoc) && $usenpr) {

-			$import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-			$import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-			$import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));

-		}

-		if (isModEnabled('barcode')) {

-			$import_sample = array_merge($import_sample, array('p.barcode'=>''));

-		}

-		if (getDolGlobalInt('PRODUCT_USE_UNITS')) {

-			$import_sample = array_merge(

-				$import_sample,

-				array(

-					'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"'

-				)

-			);

-

+            'p.finished' => '0 (raw material) / 1 (finished goods)'

+        );

+        //clauses copied from import_fields_array

+        if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(

+                'p.seuil_stock_alerte' => '',

+                'p.pmp' => '0',

+                'p.desiredstock' => ''

+            ));

+        if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));

+        if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));

+        if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));

+        if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));

+        if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>''));

+        if (!empty($conf->global->PRODUCT_USE_UNITS)) {

+            $import_sample = array_merge(

+                $import_sample,

+                array(

+                    'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"'

+                )

+            );

+

+            if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array();

@@ -748,33 +591,5 @@
-		$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');

-		if (isModEnabled('barcode')) {

-			$this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled

-		}

-

-		if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE')) {

-			// Import products limit and desired stock by product and warehouse

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_stock_by_warehouse';

-			$this->import_label[$r] = "ProductStockWarehouse"; // Translation key

-			$this->import_icon[$r] = $this->picto;

-			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('pwp'=>MAIN_DB_PREFIX.'product_warehouse_properties');

-			$this->import_fields_array[$r] = array('pwp.fk_product'=>"Product*",

-				'pwp.fk_entrepot'=>"Warehouse*", 'pwp.seuil_stock_alerte'=>"StockLimit",

-				'pwp.desiredstock'=>"DesiredStock");

-			$this->import_regex_array[$r] = array(

-				'pwp.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product',

-				'pwp.fk_entrepot' => 'rowid@'.MAIN_DB_PREFIX.'entrepot',

-			);

-			$this->import_convertvalue_array[$r] = array(

-				'pwp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')

-				,'pwp.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'Entrepot')

-			);

-			$this->import_examplevalues_array[$r] = array('pwp.fk_product'=>"ref:PRODUCT_REF or id:123456",

-				'pwp.fk_entrepot'=>"ref:WAREHOUSE_REF or id:123456",

-				'pwp.seuil_stock_alerte'=>"100",

-				'pwp.desiredstock'=>"110"

-			);

-			$this->import_updatekeys_array[$r] = array('pwp.fk_product'=>'Product', 'pwp.fk_entrepot'=>'Warehouse');

-		}

-

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

+        $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');

+        if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled

+

+		if (!empty($conf->fournisseur->enabled))

+		{

@@ -787 +602 @@
-			$this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price', 'extra'=>MAIN_DB_PREFIX.'product_fournisseur_price_extrafields');

+			$this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');

@@ -790,9 +605,8 @@
-				'sp.fk_product'=>"ProductOrService*",

-				'sp.fk_soc' => "Supplier*",

-				'sp.ref_fourn' => 'SupplierRef*',

-				'sp.quantity' => "QtyMin*",

-				'sp.tva_tx' => 'VATRate',

-				'sp.default_vat_code' => 'VATCode',

-				'sp.delivery_time_days' => 'NbDaysToDelivery',

-				'sp.supplier_reputation' => 'SupplierReputation',

-				'sp.status' => 'Status'

+			    'sp.fk_product'=>"ProductOrService*",

+                'sp.fk_soc' => "Supplier*",

+                'sp.ref_fourn' => 'SupplierRef*',

+                'sp.quantity' => "QtyMin*",

+                'sp.tva_tx' => 'VATRate',

+                'sp.default_vat_code' => 'VATCode',

+                'sp.delivery_time_days' => 'DeliveryDelay',

+                'sp.supplier_reputation' => 'SupplierReputation'

@@ -800,10 +614,4 @@
-			if (is_object($mysoc) && $usenpr) {

-				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));

-			}

-			if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

-			}

-			if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

-			}

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

+			if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));

+			if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

+			if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

+            $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

@@ -815,28 +623,10 @@
-			if (isModEnabled("multicurrency")) {

-				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

-					'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line

-					'sp.multicurrency_code'=>'CurrencyCode',

-					'sp.multicurrency_tx'=>'CurrencyRate',

-					'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',

-					'sp.multicurrency_price'=>'CurrencyPrice',

-				));

-			}

-

-			if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {

-				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct'));

-			}

-

-			// Add extra fields

-			$import_extrafield_sample = array();

-			$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND  elementtype = 'product_fournisseur_price' AND entity IN (0, ".$conf->entity.")";

-			$resql = $this->db->query($sql);

-			if ($resql) {    // This can fail when class is used on old database (during migration for example)

-				while ($obj = $this->db->fetch_object($resql)) {

-					$fieldname = 'extra.'.$obj->name;

-					$fieldlabel = ucfirst($obj->label);

-					$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-					$import_extrafield_sample[$fieldname] = $fieldlabel;

-				}

-			}

-			// End add extra fields

-			$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product_fournisseur_price'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

+            if ($conf->multicurrency->enabled)

+            {

+                $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

+                    'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line

+                    'sp.multicurrency_code'=>'CurrencyCode',

+                    'sp.multicurrency_tx'=>'CurrencyRate',

+                    'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',

+                    'sp.multicurrency_price'=>'CurrencyPrice',

+                ));

+            }

@@ -850,12 +640,11 @@
-				'sp.fk_product' => "ref:PRODUCT_REF or id:123456",

-				'sp.fk_soc' => "My Supplier",

-				'sp.ref_fourn' => "XYZ-F123456",

-				'sp.quantity' => "5",

-				'sp.tva_tx' => '10',

-				'sp.price'=>"50",

-				'sp.unitprice'=>'50',

-				'sp.remise_percent'=>'0',

-				'sp.default_vat_code' => '',

-				'sp.delivery_time_days' => '5',

-				'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER',

-				'sp.status' => '1'

+                'sp.fk_product' => "PRODUCT_REF or id:123456",

+                'sp.fk_soc' => "My Supplier",

+                'sp.ref_fourn' => "XYZ-F123456",

+                'sp.quantity' => "5",

+                'sp.tva_tx' => '10',

+			    'sp.price'=>"50",

+			    'sp.unitprice'=>'50',

+			    'sp.remise_percent'=>'0',

+			    'sp.default_vat_code' => '',

+                'sp.delivery_time_days' => '5',

+                'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'

@@ -863,32 +652,22 @@
-			if (is_object($mysoc) && $usenpr) {

-				$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));

-			}

-			if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-				$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

-			}

-			if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-				$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

-			}

-			$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(

-				'sp.price' => "50.00",

-				'sp.unitprice' => '10',

-				// TODO Make this field not required and calculate it from price and qty

-				'sp.remise_percent' => '20'

-			));

-			if (isModEnabled("multicurrency")) {

-				$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(

-					'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',

-					'sp.multicurrency_code'=>'GBP',

-					'sp.multicurrency_tx'=>'1.12345',

-					'sp.multicurrency_unitprice'=>'',

-					// TODO Make this field not required and calculate it from price and qty

-					'sp.multicurrency_price'=>''

-				));

-			}

-			if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {

-				$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(

-					'sp.packaging'=>'10',

-				));

-			}

-

-			$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier', 'sp.quantity'=>"QtyMin");

+            if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));

+            if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

+            if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

+            $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(

+                'sp.price' => "50.00",

+                'sp.unitprice' => '10',

+                // TODO Make this field not required and calculate it from price and qty

+                'sp.remise_percent' => '20'

+            ));

+            if ($conf->multicurrency->enabled)

+            {

+                $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(

+                    'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',

+                    'sp.multicurrency_code'=>'GBP',

+                    'sp.multicurrency_tx'=>'1.12345',

+                    'sp.multicurrency_unitprice'=>'',

+                    // TODO Make this field not required and calculate it from price and qty

+                    'sp.multicurrency_price'=>''

+                ));

+            }

+

+			$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');

@@ -897 +676,2 @@
-		if (getDolGlobalString('PRODUIT_MULTIPRICES')) {

+		if (!empty($conf->global->PRODUIT_MULTIPRICES))

+		{

@@ -911,6 +691,2 @@
-			if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) {

-				$this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';

-			}

-			if (is_object($mysoc) && $usenpr) {

-				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR'));

-			}

+			if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';

+			if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR'));

@@ -919 +695 @@
-				'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')

+			    'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')

@@ -921 +697 @@
-			$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:PRODUCT_REF or id:123456",

+			$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456",

@@ -926,2 +702,2 @@
-				'pr.recuperableonly'=>'0',

-				'pr.date_price'=>'2020-12-31');

+			    'pr.recuperableonly'=>'0',

+				'pr.date_price'=>'2013-04-10');

@@ -930,5 +706,6 @@
-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			// Import translations of product names and descriptions

-			$r++;

-			$this->import_code[$r] = $this->rights_class.'_languages';

-			$this->import_label[$r] = "ProductsOrServicesTranslations";

+		if (!empty($conf->global->MAIN_MULTILANGS))

+		{

+		    // Import translations of product names and descriptions

+		    $r++;

+		    $this->import_code[$r] = $this->rights_class.'_languages';

+		    $this->import_label[$r] = "ProductsOrServicesTranslations";

@@ -937 +714 @@
-			$this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');

+		    $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');

@@ -944 +721 @@
-			$this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');

+			$this->import_examplevalues_array[$r] = array('l.fk_product'=>'PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');

@@ -950,16 +727,16 @@
-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories

-	 *

-	 *  @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

-	 *  @return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		$this->remove($options);

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

+     *  @return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        $this->remove($options);

+

+        $sql = array();

+

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modProductBatch.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modProductBatch.class.php
@@ -26 +26 @@
- *  \brief      Description and activation file for the module productbatch

+ *  \brief      Description and activation file for module productbatch

@@ -43 +43 @@
-		global $langs, $conf;

+        global $langs, $conf;

@@ -45 +45 @@
-		$this->db = $db;

+        $this->db = $db;

@@ -68 +68 @@
-		$this->config_page_url = array("product_lot.php@product");

+		$this->config_page_url = array("product_lot_extrafields.php@product");

@@ -75 +75 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -80 +79,0 @@
-		// Constants

@@ -82 +80,0 @@
-		$r = 0;

@@ -84,6 +82 @@
-		$this->const[$r][0] = "PRODUCTBATCH_LOT_ADDON";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "mod_lot_free";

-		$this->const[$r][3] = 'Module to control lot number';

-		$this->const[$r][4] = 0;

-		$r++;

+        $this->tabs = array();

@@ -91,14 +84,6 @@
-		$this->const[$r][0] = "PRODUCTBATCH_SN_ADDON";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "mod_sn_free";

-		$this->const[$r][3] = 'Module to control serial number';

-		$this->const[$r][4] = 0;

-		$r++;

-

-		$this->tabs = array();

-

-		// Dictionaries

-		if (!isset($conf->productbatch->enabled)) {

-			$conf->productbatch = new stdClass();

-			$conf->productbatch->enabled = 0;

-		}

+        // Dictionaries

+	    if (!isset($conf->productbatch->enabled))

+        {

+        	$conf->productbatch = new stdClass();

+        	$conf->productbatch->enabled = 0;

+        }

@@ -107,2 +92,2 @@
-		// Boxes

-		$this->boxes = array(); // List of boxes

+        // Boxes

+        $this->boxes = array(); // List of boxes

@@ -129 +114 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -134 +119 @@
-		global $db, $conf;

+	    global $db, $conf;

@@ -139,4 +124,4 @@
-			if (!getDolGlobalString('CASHDESK_NO_DECREASE_STOCK')) {

-				include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

-				$res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);

-			}

+    		if (empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {

+    		    include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

+    		    $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);

+    		}

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modProjet.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modProjet.class.php
@@ -8,2 +8 @@
- * Copyright (C) 2014	   Charles-Fr BENKE		<charles.fr@benke.fr>

- * Copyright (C) 2023      Gauthier VERDOL      <gauthier.verdol@atm-consulting.fr>

+ * Copyright (C) 2014	   Charles-Fr BENKE	<charles.fr@benke.fr>

@@ -30 +29 @@
- *	\brief      Description and activation file for the module project

+ *	\brief      Fichier de description et activation du module Projet

@@ -70 +69 @@
-		$this->requiredby = array('modEventOrganization'); // List of module ids to disable if this one is disabled

+		$this->requiredby = array(); // List of module ids to disable if this one is disabled

@@ -72 +71 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -127,0 +127,13 @@
+		$this->const[$r][0] = "MAIN_DELAY_PROJECT_TO_CLOSE";

+		$this->const[$r][1] = "chaine";

+		$this->const[$r][2] = "7";

+		$this->const[$r][3] = "";

+		$this->const[$r][4] = 0;

+		$r++;

+		$this->const[$r][0] = "MAIN_DELAY_TASKS_TODO";

+		$this->const[$r][1] = "chaine";

+		$this->const[$r][2] = "7";

+		$this->const[$r][3] = "";

+		$this->const[$r][4] = 0;

+		$r++;

+

@@ -129,7 +141,6 @@
-		$this->boxes = array(

-			0=>array('file'=>'box_project.php', 'enabledbydefaulton'=>'Home'),	// open projects

-			1=>array('file'=>'box_project_opportunities.php', 'enabledbydefaulton'=>'Home'),	// open opportunities

-			2=>array('file'=>'box_task.php', 'enabledbydefaulton'=>'Home'),

-			3=>array('file'=>'box_validated_projects.php', 'enabledbydefaulton'=>'Home'),	// task without timespent

-			4=>array('file'=>'box_funnel_of_prospection.php', 'enabledbydefaulton'=>'Home'),

-		);

+		$this->boxes = array();

+		$r = 0;

+		$this->boxes[$r][1] = "box_project.php";

+		$r++;

+		$this->boxes[$r][1] = "box_task.php";

+		$r++;

@@ -144 +155 @@
-		$this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission

+		$this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission

@@ -180 +191 @@
-		$this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // libelle de la permission

+		$this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission

@@ -194,6 +204,0 @@
-		$r++;

-		$this->rights[$r][0] = 145; // id de la permission

-		$this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission

-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'time';

@@ -206 +211 @@
-		// Exports

+		//Exports

@@ -216 +221 @@
-			's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',

+			's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',

@@ -218 +223 @@
-			'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.title'=>"Text",

+			'p.rowid'=>"List:projet:ref::project", 'p.ref'=>"Text", 'p.title'=>"Text",

@@ -220 +225 @@
-			'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', 'p.budget_amount'=>'Numeric',

+			'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric',

@@ -222 +227 @@
-			'ptt.rowid'=>'Numeric', 'ptt.element_date'=>'Date', 'ptt.element_duration'=>"Duree", 'ptt.fk_user'=>"FormSelect:select_dolusers", 'ptt.note'=>"Text"

+			'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text"

@@ -233 +238 @@
-			'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.budget_amount'=>'Budget', 'p.description'=>"Description"

+			'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description"

@@ -235,11 +240,11 @@
-		// Add multicompany field

-		if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {

-			$nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1

-			if (isModEnabled('multicompany') && $nbofallowedentities > 1) {

-				$this->export_fields_array[$r] += array('p.entity'=>'Entity');

-			}

-		}

-		if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {

-			unset($this->export_fields_array[$r]['p.opp_percent']);

-			unset($this->export_fields_array[$r]['p.opp_amount']);

-			unset($this->export_fields_array[$r]['cls.code']);

+	    // Add multicompany field

+        if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))

+        {

+            $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1

+            if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity');

+        }

+		if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))

+		{

+		    unset($this->export_fields_array[$r]['p.opp_percent']);

+		    unset($this->export_fields_array[$r]['p.opp_amount']);

+		    unset($this->export_fields_array[$r]['cls.code']);

@@ -251,3 +256 @@
-		$keyforselect = 'projet';

-		$keyforelement = 'project';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra';

@@ -258,4 +261,2 @@
-		// Add extra fields for task

-		$keyforselect = 'projet_task';

-		$keyforelement = 'projecttask';

-		$keyforaliasextra = 'extra2';

+        // Add extra fields for task

+		$keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2';

@@ -263,4 +264,4 @@
-		// End add extra fields

-		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.element_date'=>'TaskTimeDate', 'ptt.element_duration'=>"TimeSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));

-		$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.element_date'=>'task_time', 'ptt.element_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time"));

-		if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {

+        // End add extra fields

+		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));

+		$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time"));

+		if (empty($conf->global->PROJECT_HIDE_TASKS)) {

@@ -270 +271 @@
-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';

@@ -272,5 +273,5 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";

+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';

+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";

@@ -278 +279 @@
-		if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {

+		if (empty($conf->global->PROJECT_HIDE_TASKS)) {

@@ -283,34 +283,0 @@
-		// Import project/opportunities

-		$r++;

-		$this->import_code[$r] = 'projects';

-		$this->import_label[$r] = 'ImportDatasetProjects';

-		$this->import_icon[$r] = 'project';

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet', 'extra'=>MAIN_DB_PREFIX.'projet_extrafields'); // List of tables to insert into (insert done in same order)

-		$this->import_fields_array[$r] = array('t.ref'=>'ProjectRef*', 't.title'=>'Label*', 't.description'=>"Description", 't.fk_soc' => 'ThirdPartyName', 't.public'=>"Public", 't.fk_statut'=>"Status");

-		$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('t.fk_opp_status'=>"OpportunityStatus", 't.opp_percent'=>"OpportunityProbability", 't.opp_amount'=>"OpportunityAmount", 't.note_public'=>"NotePublic", 't.note_private'=>"NotePrivate", 't.budget_amount'=>"Budget", 't.dateo'=>"DateStart", 't.datee'=>"DateEnd"));

-		// Add extra fields

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0,".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

-		$this->import_convertvalue_array[$r] = array(

-			't.ref'=>array('rule'=>'getrefifauto', 'class'=>(!getDolGlobalString('PROJECT_ADDON') ? 'mod_project_simple' : $conf->global->PROJECT_ADDON), 'path'=>"/core/modules/project/".(!getDolGlobalString('PROJECT_ADDON') ? 'mod_project_simple' : $conf->global->PROJECT_ADDON).'.php'),

-			't.fk_soc' => array(

-				'rule'    => 'fetchidfromref',

-				'file'    => '/societe/class/societe.class.php',

-				'class'   => 'Societe',

-				'method'  => 'fetch',

-				'element' => 'ThirdParty'

-			),

-		);

-		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');

-		$this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');

-		$this->import_examplevalues_array[$r] = array('t.fk_soc'=>'ThirdParty', 't.ref'=>"auto or PJ2010-1234", 't.title'=>"My project", 't.fk_statut'=>'0,1 or 2', 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");

@@ -319,27 +286,30 @@
-		if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {

-			$r++;

-			$this->import_code[$r] = 'tasksofprojects';

-			$this->import_label[$r] = 'ImportDatasetTasks';

-			$this->import_icon[$r] = 'task';

-			$this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon

-			$this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)

-			$this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation");

-			// Add extra fields

-			$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";

-			$resql = $this->db->query($sql);

-			if ($resql) {    // This can fail when class is used on old database (during migration for example)

-				while ($obj = $this->db->fetch_object($resql)) {

-					$fieldname = 'extra.'.$obj->name;

-					$fieldlabel = ucfirst($obj->label);

-					$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				}

-			}

-			// End add extra fields

-			$this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

-			$this->import_convertvalue_array[$r] = array(

-				't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),

-				't.ref'=>array('rule'=>'getrefifauto', 'class'=>(!getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON), 'path'=>"/core/modules/project/task/".(!getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON).'.php')

-			);

-			//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');

-			$this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');

-			$this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");

+		if (empty($conf->global->PROJECT_HIDE_TASKS))

+		{

+    		$r++;

+    		$this->import_code[$r] = 'tasksofprojects';

+    		$this->import_label[$r] = 'ImportDatasetTasks';

+    		$this->import_icon[$r] = 'task';

+    		$this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon

+    		$this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)

+    		$this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation");

+    		// Add extra fields

+    		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";

+    		$resql = $this->db->query($sql);

+    		if ($resql)    // This can fail when class is used on old database (during migration for example)

+    		{

+    		    while ($obj = $this->db->fetch_object($resql))

+    		    {

+    		        $fieldname = 'extra.'.$obj->name;

+    		        $fieldlabel = ucfirst($obj->label);

+    		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

+    		    }

+    		}

+    		// End add extra fields

+    		$this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)

+    		$this->import_convertvalue_array[$r] = array(

+    		    't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),

+    		    't.ref'=>array('rule'=>'getrefifauto')

+    		);

+    		//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');

+    		$this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');

+    		$this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");

@@ -355 +325 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -370 +340,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -374 +345,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -386 +358,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -390 +363,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -398,6 +372,6 @@
-		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".((int) $conf->entity);

-		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".((int) $conf->entity).")";

-		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".((int) $conf->entity);

-		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".((int) $conf->entity).")";

-		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".((int) $conf->entity);

-		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".((int) $conf->entity).")";

+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;

+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";

+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;

+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";

+		$sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;

+		$sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modPropale.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modPropale.class.php
@@ -8 +7,0 @@
- * Copyright (C) 2020		Ahmad Jamaly Rabib		<rabib@metroworks.co.jp>

@@ -26 +25 @@
- *	\brief      Module to manage commercial proposals

+ *	\brief      Module pour gerer la tenue de propositions commerciales

@@ -29 +28 @@
- *	\brief      Description and activation file for the module customer proposal

+ *	\brief      Fichier de description et activation du module Propale

@@ -38,0 +38 @@
+

@@ -71 +71 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -81 +81 @@
-		$this->const[$r][2] = "cyan";

+		$this->const[$r][2] = "azur";

@@ -107,7 +106,0 @@
-		$this->const[$r][0] = "PROPOSAL_ALLOW_ONLINESIGN";

-		$this->const[$r][1] = "chaine";

-		$this->const[$r][2] = "1";

-		$this->const[$r][3] = "";

-		$this->const[$r][4] = 0;

-		$r++;

-

@@ -122,2 +115,2 @@
-			0=>array('file'=>'box_graph_propales_permonth.php', 'enabledbydefaulton'=>'Home'),

-			1=>array('file'=>'box_propales.php', 'enabledbydefaulton'=>'Home'),

+           	0=>array('file'=>'box_graph_propales_permonth.php', 'enabledbydefaulton'=>'Home'),

+           	1=>array('file'=>'box_propales.php', 'enabledbydefaulton'=>'Home'),

@@ -147 +140 @@
-		$this->rights[$r][1] = 'Validate commercial proposals'; // Validate proposal

+		$this->rights[$r][1] = 'Validate commercial proposals'; // libelle de la permission

@@ -159 +152 @@
-		$this->rights[$r][5] = 'send';

+        $this->rights[$r][5] = 'send';

@@ -163 +156 @@
-		$this->rights[$r][1] = 'Close commercial proposals'; // Set proposal to signed or refused

+		$this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission

@@ -166,2 +159 @@
-		$this->rights[$r][4] = 'propal_advance';

-		$this->rights[$r][5] = 'close';

+		$this->rights[$r][4] = 'cloturer';

@@ -198 +190 @@
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone',

+			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone',

@@ -200,18 +192,4 @@
-			'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal",

-			'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC");

-		if (isModEnabled("multicurrency")) {

-			$this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency';

-			$this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';

-			$this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(

-			'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic", 'c.note_private'=>"NotePrivate", 'c.date_livraison'=>'DeliveryDate',

-			'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',

-			'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin'));

-		if (isModEnabled("project")) {

-			$this->export_fields_array[$r]['pj.ref'] = 'ProjectRef';

-		}

-		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(

-			'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',

+			'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount",

+			'c.total_ht'=>"TotalHT", 'c.total'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',

+			'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',

+			'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',

@@ -219,2 +196,0 @@
-		));

-		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(

@@ -222,7 +198,8 @@
-		));

-		// Add multicompany field

-		if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {

-			$nbofallowedentities = count(explode(',', getEntity('propal')));

-			if (isModEnabled('multicompany') && $nbofallowedentities > 1) {

-				$this->export_fields_array[$r]['c.entity'] = 'Entity';

-			}

+		);

+		if (!empty($conf->multicurrency->enabled))

+		{

+		    $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency';

+		    $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';

+		    $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

+		    $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

+		    $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

@@ -231 +208 @@
-		//	's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text',

+		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text',

@@ -233 +210 @@
-		//	'c.fin_validite'=>"Date",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.note_private'=>"Text",

+		//	'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",

@@ -238 +215 @@
-			's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text',

+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text',

@@ -240 +217 @@
-			'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.note_private'=>"Text", 'c.date_livraison'=>'Date',

+			'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',

@@ -242,2 +219 @@
-			'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text',

-			'c.entity'=>'List:entity:label:rowid',

+			'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text'

@@ -246 +222 @@
-			's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company',

+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company',

@@ -248,7 +224,3 @@
-			'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.total_ht'=>"propal",

-			'c.total_ttc'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.note_private'=>"propal", 'c.date_livraison'=>"propal",

-			'c.fk_user_author'=>'user', 'uc.login'=>'user',

-			'c.fk_user_valid'=>'user', 'uv.login'=>'user',

-			'pj.ref'=>'project',

-			'cd.rowid'=>'propal_line',

-			'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",

+			'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal",

+			'c.total'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line',

+			'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",

@@ -258,3 +230 @@
-		$keyforselect = 'propal';

-		$keyforelement = 'propal';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'propal'; $keyforelement = 'propal'; $keyforaliasextra = 'extra';

@@ -262,3 +232 @@
-		$keyforselect = 'propaldet';

-		$keyforelement = 'propal_line';

-		$keyforaliasextra = 'extra2';

+		$keyforselect = 'propaldet'; $keyforelement = 'propal_line'; $keyforaliasextra = 'extra2';

@@ -266,3 +234 @@
-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra3';

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3';

@@ -270,3 +236 @@
-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extra4';

+		$keyforselect = 'societe'; $keyforelement = 'societe'; $keyforaliasextra = 'extra4';

@@ -278,4 +242,2 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';

-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+

+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -294,174 +256 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

-		}

-

-		// Imports

-		//--------

-		$r = 0;

-

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'_'.$r;

-		$this->import_label[$r] = 'Proposals'; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'propal', 'extra' => MAIN_DB_PREFIX.'propal_extrafields');

-		$this->import_tables_creator_array[$r] = array('c'=>'fk_user_author'); // Fields to store import user id

-		$this->import_fields_array[$r] = array(

-			'c.ref' => 'Ref*',

-			'c.ref_client' => 'RefCustomer',

-			'c.fk_soc' => 'ThirdPartyName*',

-			'c.datec' => 'DateCreation',

-			'c.datep' => 'DatePropal',

-			'c.fin_validite' => 'DateEndPropal',

-			'c.total_ht' => 'TotalHT',

-			'c.total_ttc' => 'TotalTTC',

-			'c.fk_statut' => 'Status*',

-			'c.note_public' => 'NotePublic',

-			'c.note_private' => 'NotePrivate',

-			'c.date_livraison' => 'DeliveryDate',

-			'c.fk_user_valid' => 'ValidatedById'

-		);

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'propal' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propal'];

-		$this->import_regex_array[$r] = ['c.ref' => '[^ ]'];

-		$import_sample = [

-			'c.ref' => 'PROV0077',

-			'c.ref_client' => 'Client1',

-			'c.fk_soc' => 'MyBigCompany',

-			'c.datec' => '2020-01-01',

-			'c.datep' => '2020-01-01',

-			'c.fin_validite' => '2020-01-01',

-			'c.total_ht' => '0',

-			'c.total_ttc' => '0',

-			'c.fk_statut' => '1',

-			'c.note_public' => '',

-			'c.note_private' => '',

-			'c.date_livraison' => '2020-01-01',

-			'c.fk_user_valid' => '1',

-			'c.multicurrency_code' => '',

-			'c.multicurrency_tx' => '1',

-			'c.multicurrency_total_ht' => '0',

-			'c.multicurrency_total_tva' => '0',

-			'c.multicurrency_total_ttc' => '0'

-		];

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('c.ref'=>'Ref');

-		$this->import_convertvalue_array[$r] = array(

-			'c.ref' => array(

-				'rule'=>'getrefifauto',

-				'class'=>(!getDolGlobalString('PROPALE_ADDON') ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON),

-				'path'=>"/core/modules/propale/".(!getDolGlobalString('PROPALE_ADDON') ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON).'.php',

-				'classobject'=>'Propal',

-				'pathobject'=>'/comm/propal/class/propal.class.php',

-			),

-			'c.fk_soc' => array(

-				'rule' => 'fetchidfromref',

-				'file' => '/societe/class/societe.class.php',

-				'class' => 'Societe',

-				'method' => 'fetch',

-				'element' => 'ThirdParty'

-			)

-		);

-

-		//Import Proposal Lines

-		$r++;

-		$this->import_code[$r] = $this->rights_class.'line_'.$r;

-		$this->import_label[$r] = "ProposalLines"; // Translation key

-		$this->import_icon[$r] = $this->picto;

-		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon

-		$this->import_tables_array[$r] = array(

-			'cd' => MAIN_DB_PREFIX.'propaldet',

-			'extra' => MAIN_DB_PREFIX.'propaldet_extrafields'

-		);

-		$this->import_fields_array[$r] = array(

-			'cd.fk_propal' => 'Proposal*',

-			'cd.fk_parent_line' => 'ParentLine',

-			'cd.fk_product' => 'IdProduct',

-			'cd.description' => 'LineDescription',

-			'cd.product_type' => 'TypeOfLineServiceOrProduct',

-			'cd.tva_tx' => 'LineVATRate',

-			'cd.qty' => 'LineQty',

-			'cd.remise_percent' => 'Reduc. Percent',

-			'cd.price' => 'Price',

-			'cd.subprice' => 'Sub Price',

-			'cd.total_ht' => 'LineTotalHT',

-			'cd.total_tva' => 'LineTotalVAT',

-			'cd.total_ttc' => 'LineTotalTTC',

-			'cd.date_start' => 'Start Date',

-			'cd.date_end' => 'End Date',

-			'cd.buy_price_ht' => 'LineBuyPriceHT'

-		);

-		if (isModEnabled("multicurrency")) {

-			$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';

-			$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';

-			$this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';

-			$this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';

-			$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';

-		}

-		// Add extra fields

-		$import_extrafield_sample = array();

-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'propaldet' AND entity IN (0, ".$conf->entity.")";

-		$resql = $this->db->query($sql);

-		if ($resql) {

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

-		}

-		// End add extra fields

-		$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propaldet');

-		$this->import_regex_array[$r] = array('cd.product_type' => '[0|1]$');

-		$import_sample = array(

-			'cd.fk_propal' => 'PROV(0001)',

-			'cd.fk_parent_line' => '',

-			'cd.fk_product' => '',

-			'cd.description' => 'Line description',

-			'cd.product_type' => '1',

-			'cd.tva_tx' => '0',

-			'cd.qty' => '2',

-			'cd.remise_percent' => '0',

-			'cd.price' => '',

-			'cd.subprice' => '5000',

-			'cd.total_ht' => '10000',

-			'cd.total_tva' => '0',

-			'cd.total_ttc' => '10100',

-			'cd.date_start' => '',

-			'cd.date_end' => '',

-			'cd.buy_price_ht' => '7000',

-			'cd.multicurrency_code' => 'JPY',

-			'cd.multicurrency_tx' => '1',

-			'cd.multicurrency_total_ht' => '10000',

-			'cd.multicurrency_total_tva' => '0',

-			'cd.multicurrency_total_ttc' => '10100'

-		);

-		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);

-		$this->import_updatekeys_array[$r] = array('cd.fk_propal' => 'Quotation Id', 'cd.fk_product' => 'Product Id');

-		$this->import_convertvalue_array[$r] = array(

-			'cd.fk_propal' => array(

-				'rule'=>'fetchidfromref',

-				'file'=>'/comm/propal/class/propal.class.php',

-				'class'=>'Propal',

-				'method'=>'fetch'

-			)

-		);

+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

@@ -476 +265 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -491 +280,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -495 +285,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -503,2 +294,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'propal' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','propal',".((int) $conf->entity).")",

+				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'propal' AND entity = ".$conf->entity,

+				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','propal',".$conf->entity.")",

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modReceiptPrinter.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modReceiptPrinter.class.php
@@ -26 +26 @@
- *  \brief      Description and activation file for the module Receipt Printer

+ *  \brief      File of class to describe and activate module Receipt Printer

@@ -37,17 +37,18 @@
-	/**

-	 *  Constructor

-	 *

-	 *  @param      DoliDB      $db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-		$this->numero = 67000;

-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "interface";

-		$this->module_position = '53';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "ReceiptPrinterDesc";

+

+    /**

+     *  Constructor

+     *

+     *  @param      DoliDB      $db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+        $this->numero = 67000;

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "interface";

+        $this->module_position = '53';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "ReceiptPrinterDesc";

@@ -55,6 +56,6 @@
-		$this->version = 'dolibarr';

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'printer';

+        $this->version = 'experimental';

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'printer';

@@ -62,2 +63,2 @@
-		// Data directories to create when module is enabled.

-		$this->dirs = array();

+        // Data directories to create when module is enabled.

+        $this->dirs = array();

@@ -65,2 +66,2 @@
-		// Config pages

-		$this->config_page_url = array("receiptprinter.php");

+        // Config pages

+        $this->config_page_url = array("receiptprinter.php");

@@ -68,2 +69,2 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -73,4 +74,4 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(3, 9, -2); // Minimum version of Dolibarr required by module

-		$this->conflictwith = array();

-		$this->langfiles = array("receiptprinter");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(3, 9, -2); // Minimum version of Dolibarr required by module

+        $this->conflictwith = array();

+        $this->langfiles = array("receiptprinter");

@@ -78,2 +79,2 @@
-		// Constants

-		$this->const = array();

+        // Constants

+        $this->const = array();

@@ -81,2 +82,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -84,3 +85,3 @@
-		// Permissions

-		$this->rights = array();

-		$this->rights_class = 'receiptprinter';

+        // Permissions

+        $this->rights = array();

+        $this->rights_class = 'receiptprinter';

@@ -88,7 +89,7 @@
-		$r = 0;

-		// $this->rights[$r][0]     Id permission (unique tous modules confondus)

-		// $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

-		// $this->rights[$r][2]     Non utilise

-		// $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

-		// $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

-		// $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

+        $r = 0;

+        // $this->rights[$r][0]     Id permission (unique tous modules confondus)

+        // $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)

+        // $this->rights[$r][2]     Non utilise

+        // $this->rights[$r][3]     1=Permis par defaut, 0=Non permis par defaut

+        // $this->rights[$r][4]     Niveau 1 pour nommer permission dans code

+        // $this->rights[$r][5]     Niveau 2 pour nommer permission dans code

@@ -96,6 +97,6 @@
-		$r++;

-		$this->rights[$r][0] = 67001;

-		$this->rights[$r][1] = 'ReceiptPrinter';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'read';

+        $r++;

+        $this->rights[$r][0] = 67000;

+        $this->rights[$r][1] = 'ReceiptPrinter';

+        $this->rights[$r][2] = 'r';

+        $this->rights[$r][3] = 0;

+        $this->rights[$r][4] = 'read';

@@ -103,3 +104,3 @@
-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

@@ -107,12 +108,12 @@
-		// This is to declare the Top Menu entry:

-		//$this->menu[$r]=array(  'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',               // Put 0 if this is a top menu

-		//                        'type'=>'left',                 // This is a Top menu entry

-		//                        'titre'=>'MenuDirectPrinting',

-		//                        'mainmenu'=>'printing',

-		//                        'url'=>'/printing/index.php',

-		//                        'langs'=>'printing',            // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-		//                        'position'=>300,

-		//                        'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',

-		//                        'perms'=>'$user->rights->printing->read',    // Use 'perms'=>'1' if you want your menu with no permission rules

-		//                        'target'=>'',

-		//                        'user'=>0);                     // 0=Menu for internal users, 1=external users, 2=both

+        // This is to declare the Top Menu entry:

+        //$this->menu[$r]=array(  'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',               // Put 0 if this is a top menu

+        //                        'type'=>'left',                 // This is a Top menu entry

+        //                        'titre'=>'MenuDirectPrinting',

+        //                        'mainmenu'=>'printing',

+        //                        'url'=>'/printing/index.php',

+        //                        'langs'=>'printing',            // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //                        'position'=>300,

+        //                        'enabled'=>'$conf->printing->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',

+        //                        'perms'=>'$user->rights->printing->read',    // Use 'perms'=>'1' if you want your menu with no permission rules

+        //                        'target'=>'',

+        //                        'user'=>0);                     // 0=Menu for internal users, 1=external users, 2=both

@@ -120,2 +121,2 @@
-		$r++;

-	}

+        $r++;

+    }

@@ -124,11 +125,13 @@
-	/**

-	 *      Function called when module is enabled.

-	 *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *      It also creates data directories

-	 *

-	 *      @param      string  $options    Options when enabling module ('', 'noboxes')

-	 *      @return     int                 1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $langs;

+    /**

+     *      Function called when module is enabled.

+     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *      It also creates data directories

+     *

+     *      @param      string  $options    Options when enabling module ('', 'noboxes')

+     *      @return     int                 1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        global $conf, $langs;

+        // Clean before activation

+        $this->remove($options);

@@ -136,15 +139,6 @@
-		$result = $this->_load_tables('/install/mysql/', 'receiptprinter');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Clean before activation

-		$this->remove($options);

-

-		// @TODO Move create/delete into sql file and insert into data file

-		$templateexample = '{dol_align_center}\r\n{dol_print_text}{dol_value_mysoc_name}\r\n{dol_print_text}{dol_value_mysoc_address}\r\n{dol_print_text}{dol_value_mysoc_zip}{dol_value_mysoc_town}\r\n{dol_line_feed}\r\n{dol_print_text}Facture {dol_value_object_ref}\r\n{dol_line_feed}\r\n{dol_align_left}\r\n{dol_print_object_lines}\r\n{dol_line_feed}\r\n{dol_print_object_tax}\r\n{dol_line_feed}\r\n{dol_print_object_total}\r\n{dol_line_feed}\r\n{dol_cut_paper_full}';

-		$sql = array(

-			"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;",

-			"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;",

-			"DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$this->db->escape($langs->trans('Example'))."';",

-			"INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$this->db->escape($langs->trans('Example'))."', '".$this->db->escape($templateexample)."', 1);",

+        $templateexample = '<dol_align_center>\r\n<dol_print_text><dol_value_mysoc_name>\r\n<dol_print_text><dol_value_mysoc_address>\r\n<dol_print_text><dol_value_mysoc_zip><dol_value_mysoc_town>\r\n<dol_line_feed>\r\n<dol_print_text>Facture <dol_value_object_ref>\r\n<dol_line_feed>\r\n<dol_align_left>\r\n<dol_print_object_lines>\r\n<dol_line_feed>\r\n<dol_print_object_tax>\r\n<dol_line_feed>\r\n<dol_print_object_total>\r\n<dol_line_feed>\r\n<dol_cut_paper_full>';

+        $sql = array(

+            "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;",

+            "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;",

+        	"DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$langs->trans('Example')."';",

+			"INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$langs->trans('Example')."', '".$templateexample."', 1);",

@@ -152,3 +146,2 @@
-

-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modReception.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modReception.class.php
@@ -19,6 +19,5 @@
- *  \defgroup   reception     Module Reception

- *  \brief      Module to manage receptions of products

- *

- *  \file       htdocs/core/modules/modReception.class.php

- *  \ingroup    reception

- *  \brief      Description and activation file for the module Reception

+ *	\defgroup   reception     Module reception

+ *	\brief      Module pour gerer les réceptions de produits

+ *	\file       htdocs/core/modules/modReception.class.php

+ *	\ingroup    reception

+ *	\brief      Fichier de description et activation du module Reception

@@ -51 +50 @@
-		$this->description = "ReceptionDescription";

+		$this->description = "Gestion des réceptions fournisseurs";

@@ -54 +53 @@
-		$this->version = 'dolibarr';

+		$this->version = 'experimental';

@@ -61,3 +60,3 @@
-							"/reception/receipt/temp",

-							"/doctemplates/receptions"

-							);

+		                    "/reception/receipt/temp",

+		                    "/doctemplates/receptions"

+		                    );

@@ -142 +141 @@
-		$this->rights[$r][5] = 'send';

+        $this->rights[$r][5] = 'send';

@@ -190,4 +189,2 @@
-		if ($idcontacts && getDolGlobalString('RECEPTION_ADD_CONTACTS_IN_EXPORT')) {

-			$this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');

-		}

-		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");

+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');

+		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");

@@ -207,3 +204 @@
-		if ($idcontacts && getDolGlobalString('RECEPTION_ADD_CONTACTS_IN_EXPORT')) {

-			$this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');

-		}

+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');

@@ -211,9 +206,6 @@
-		if ($idcontacts && getDolGlobalString('RECEPTION_ADD_CONTACTS_IN_EXPORT')) {

-			$keyforselect = 'socpeople';

-			$keyforelement = 'contact';

-			$keyforaliasextra = 'extra3';

-			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		}

-		$keyforselect = 'reception';

-		$keyforelement = 'reception';

-		$keyforaliasextra = 'extra';

+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))

+		{

+		    $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3';

+		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+		}

+		$keyforselect = 'reception'; $keyforelement = 'reception'; $keyforaliasextra = 'extra';

@@ -221,3 +213 @@
-		$keyforselect = 'commande_fournisseur_dispatch';

-		$keyforelement = 'reception_line';

-		$keyforaliasextra = 'extra2';

+		$keyforselect = 'commande_fournisseur_dispatch'; $keyforelement = 'reception_line'; $keyforaliasextra = 'extra2';

@@ -230,3 +220 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -239,4 +227,4 @@
-		if ($idcontacts && getDolGlobalString('RECEPTION_ADD_CONTACTS_IN_EXPORT')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$this->db->sanitize($idcontacts).')';

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';

+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) {

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';

+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';

@@ -246,3 +234 @@
-		if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);

-		}

+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;

@@ -257 +243 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -272 +258,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -276 +263,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -286,4 +274,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".((int) $conf->entity).")",

-			//"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name IN ('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE') AND entity = ".((int) $conf->entity),

-			//"INSERT INTO ".MAIN_DB_PREFIX."const (name, value, entity) VALUES ('STOCK_CALCULATE_ON_RECEPTION_CLOSE', 1, ".((int) $conf->entity).")"

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".$conf->entity.")",

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modResource.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modResource.class.php
@@ -26 +26 @@
- * 	\brief		Description and activation file for the module Resource

+ * 	\brief		Description and activation file for module Resource

@@ -29 +28,0 @@
-

@@ -35,0 +35 @@
+

@@ -43 +43 @@
-		global $langs, $conf;	// $langs may be used by the tpl files.

+		global $langs, $conf;

@@ -58 +58 @@
-		$this->module_position = '20';

+		$this->module_position = '16';

@@ -98 +98 @@
-		$this->phpmin = array(7, 0);

+		$this->phpmin = array(5, 4);

@@ -123 +123 @@
-		// 'order'				to add a tab in sales order view

+		// 'order'				to add a tab in customer order view

@@ -188 +188 @@
-			'fk_menu'=>'fk_mainmenu=agenda',

+			'fk_menu'=>'fk_mainmenu=tools',

@@ -191,2 +191 @@
-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'),

-			'mainmenu'=>'agenda',

+			'mainmenu'=>'tools',

@@ -204 +203 @@
-			'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus

+			'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus

@@ -207 +206 @@
-			'mainmenu'=> 'agenda',

+			'mainmenu'=> 'tools',

@@ -219 +218 @@
-			'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus

+			'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus

@@ -222 +221 @@
-			'mainmenu'=> 'agenda',

+			'mainmenu'=> 'tools',

@@ -242,9 +241,4 @@
-

-		$this->export_fields_array[$r] = array('r.rowid' => 'IdResource', 'r.ref' => 'ResourceFormLabel_ref', 'c.rowid' => 'ResourceTypeID', 'c.code' => 'ResourceTypeCode', 'c.label' => 'ResourceTypeLabel', 'r.description' => 'ResourceFormLabel_description', 'r.note_private' => "NotePrivate", 'r.note_public' => "NotePublic", 'r.asset_number' => 'AssetNumber', 'r.datec' => "DateCreation", 'r.tms' => "DateLastModification");

-		$this->export_TypeFields_array[$r] = array('r.rowid' => 'List:resource:ref', 'r.ref' => 'Text', 'r.asset_number' => 'Text', 'r.description' => 'Text', 'c.rowid' => 'List:c_type_resource:label', 'c.code' => 'Text', 'c.label' => 'Text', 'r.datec' => 'Date', 'r.tms' => 'Date', 'r.note_private' => 'Text', 'r.note_public' => 'Text');

-		$this->export_entities_array[$r] = array('r.rowid' => 'resource', 'r.ref' => 'resource', 'c.rowid' => 'resource', 'c.code' => 'resource', 'c.label' => 'resource', 'r.description' => 'resource', 'r.note_private' => "resource", 'r.resource' => "resource", 'r.asset_number' => 'resource', 'r.datec' => "resource", 'r.tms' => "resource");

-

-		$keyforselect = 'resource';

-		$keyforelement = 'resource';

-		$keyforaliasextra = 'extra';

-

+		$this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification");

+		$this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text');

+		$this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource");

+		$keyforselect = 'resource'; $keyforelement = 'resource'; $keyforaliasextra = 'extra';

@@ -255,5 +249,4 @@
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'resource as r';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.code = r.fk_code_type_resource';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid';

-		$this->export_sql_end[$r] .= ' WHERE r.entity IN ('.getEntity('resource').')';

-

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'resource as r ';

+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource';

+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid';

+		$this->export_sql_end[$r] .= ' AND r.entity IN ('.getEntity('resource').')';

@@ -275 +268 @@
-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.")";

+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")";

@@ -277,2 +270,4 @@
-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

-			while ($obj = $this->db->fetch_object($resql)) {

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+			while ($obj = $this->db->fetch_object($resql))

+			{

@@ -307,0 +303,2 @@
+		$result = $this->loadTables();

+

@@ -309,0 +307,13 @@
+

+	/**

+	 * Create tables, keys and data required by module

+	 * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys

+	 * and create data commands must be stored in directory /resource/sql/

+	 * This function is called by this->init

+	 *

+	 * 	@return		int		<=0 if KO, >0 if OK

+	 */

+	protected function loadTables()

+	{

+		return $this->_load_tables('/resource/sql/');

+	}

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modSalaries.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSalaries.class.php
@@ -30 +30 @@
- *  \brief      Description and activation file for the module salaries

+ *  \brief      File to activate module salaries

@@ -39,0 +40 @@
+

@@ -77 +78 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -103 +104 @@
-		$this->rights[$r][1] = 'Read employee salaries and payments (yours and your subordinates)';

+		$this->rights[$r][1] = 'Read payments of employee salaries';

@@ -127,7 +127,0 @@
-		$this->rights[$r][1] = 'Read salaries and payments of all employees';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'readall';

-

-		$r++;

-		$this->rights[$r][0] = 519;

@@ -139 +132,0 @@
-

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modService.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modService.class.php
@@ -2,6 +2,6 @@
-/* Copyright (C) 2003		Rodolphe Quiedeville	<rodolphe@quiedeville.org>

- * Copyright (C) 2004-2014	Laurent Destailleur		<eldy@users.sourceforge.net>

- * Copyright (C) 2004		Sebastien Di Cintio		<sdicintio@ressource-toi.org>

- * Copyright (C) 2004		Benoit Mortier			<benoit.mortier@opensides.be>

- * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@inodbox.com>

- * Copyright (C) 2020-2021	Alexandre Spangaro		<aspangaro@open-dsi.fr>

+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ * Copyright (C) 2004-2014 Laurent Destailleur  <eldy@users.sourceforge.net>

+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>

+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>

+ * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@inodbox.com>

+ * Copyright (C) 2020	   Alexandre Spangaro	<aspangaro@open-dsi.fr>

@@ -28 +28 @@
- *	\brief      Description and activation file for the module Service

+ *	\brief      Fichier de description et activation du module Service

@@ -37,0 +38 @@
+

@@ -70 +71 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -95 +96 @@
-		$r++;

+        $r++;

@@ -102,9 +103 @@
-		$r++;

-

-		$this->rights[$r][0] = 533; // id de la permission

-		$this->rights[$r][1] = 'Read prices services'; // libelle de la permission

-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'service_advance';

-		$this->rights[$r][5] = 'read_prices';

-		$r++;

+        $r++;

@@ -117 +110 @@
-		$r++;

+        $r++;

@@ -124 +117 @@
-		$r++;

+        $r++;

@@ -137 +130 @@
-		 'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+		 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

@@ -144,6 +137 @@
-		$usenpr = 0;

-		if (is_object($mysoc)) {

-			$usenpr = $mysoc->useNPR();

-		}

-

-		// Exports

+        // Exports

@@ -152,2 +139,0 @@
-

-		$alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe";

@@ -164,3 +150,3 @@
-			$alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

-			$alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode",

-			$alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

+			'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

+			'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",

+			'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

@@ -175,15 +161,5 @@
-		if (is_object($mysoc) && $usenpr) {

-			$this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice'));

-		}

-		if (isModEnabled('stock')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-		}

-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra';

+		if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';

+		if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice'));

+		if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

+		if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';

@@ -191,12 +167,4 @@
-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote'));

-		}

-		if (getDolGlobalInt('PRODUCT_USE_UNITS')) {

-			$this->export_fields_array[$r]['p.fk_unit'] = 'Unit';

-		}

+		if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote'));

+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';

@@ -206,3 +174,3 @@
-			'p.description'=>"Text", 'p.url'=>"Text",

-			$alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text",

-			$alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text",

+			'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text",

+			'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", 'p.accountancy_code_buy'=>"Text",

+			'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",

@@ -217,15 +185,5 @@
-		if (isModEnabled('stock')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text'));

-		}

+		if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

+		if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

+		if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text'));

@@ -233,33 +191,11 @@
-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category'));

-		}

-		if (isModEnabled('stock')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_dependencies_array[$r] = array('category'=>'p.rowid');

-		}

-		if (isModEnabled('stock')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_dependencies_array[$r] = array('category'=>'p.rowid');

-		}

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category'));

+		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

+		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

+		if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid');

+		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));

+		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

+		if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation'));

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid');

@@ -268,9 +204,2 @@
-		if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {

-			$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);

-		}

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid';

-		}

-		if (getDolGlobalInt('MAIN_MULTILANGS')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';

-		}

+		if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid';

+		if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';

@@ -278,10 +207,8 @@
-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';

-		}

-		$this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';

-		if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {

-			$this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields"

-		}

-

-		if (!isModEnabled("product")) {	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)

-			if (getDolGlobalString('PRODUIT_MULTIPRICES')) {

+		if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';

+        $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';

+        if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields"

+

+		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)

+		{

+			if (!empty($conf->global->PRODUIT_MULTIPRICES))

+			{

@@ -292 +219 @@
-				$this->export_permission[$r] = array(array("service", "export"));

+				$this->export_permission[$r] = array(array("produit", "export"));

@@ -299,3 +226 @@
-				if (is_object($mysoc) && $usenpr) {

-					$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

-				}

+				if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

@@ -313,2 +238,2 @@
-					'pr.recuperableonly'=>'product',

-					'pr.date_price'=>"product");

+				    'pr.recuperableonly'=>'product',

+				    'pr.date_price'=>"product");

@@ -321,31 +246,30 @@
-			if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {

-				// Exports product multiprice

-				$r++;

-				$this->export_code[$r] = $this->rights_class.'_'.$r;

-				$this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)

-				$this->export_permission[$r] = array(array("service", "export"));

-				$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",

-					's.nom'=>'ThirdParty',

-					'pr.price_base_type'=>"PriceBase",

-					'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",

-					'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",

-					'pr.tva_tx'=>'PriceVATRate',

-					'pr.default_vat_code'=>'PriceVATCode',

-					'pr.datec'=>'DateCreation');

-				if (is_object($mysoc) && $usenpr) {

-					$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

-				}

-				$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",

-					's.nom'=>'company',

-					'pr.price_base_type'=>"product", 'pr.price'=>"product",

-					'pr.price_ttc'=>"product",

-					'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",

-					'pr.tva_tx'=>'product',

-					'pr.default_vat_code'=>'product',

-					'pr.recuperableonly'=>'product',

-					'pr.datec'=>"product");

-				$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-				$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

-				$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity

-				$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';

-				$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

+			if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))

+			{

+			    // Exports product multiprice

+			    $r++;

+			    $this->export_code[$r] = $this->rights_class.'_'.$r;

+			    $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)

+			    $this->export_permission[$r] = array(array("produit", "export"));

+			    $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",

+			        's.nom'=>'ThirdParty',

+			        'pr.price_base_type'=>"PriceBase",

+			        'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",

+			        'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",

+			        'pr.tva_tx'=>'PriceVATRate',

+			        'pr.default_vat_code'=>'PriceVATCode',

+			        'pr.datec'=>'DateCreation');

+			    if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';

+			    $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",

+			        's.nom'=>'company',

+			        'pr.price_base_type'=>"product", 'pr.price'=>"product",

+			        'pr.price_ttc'=>"product",

+			        'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",

+			        'pr.tva_tx'=>'product',

+			        'pr.default_vat_code'=>'product',

+			        'pr.recuperableonly'=>'product',

+			        'pr.datec'=>"product");

+			    $this->export_sql_start[$r] = 'SELECT DISTINCT ';

+			    $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

+			    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity

+			    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';

+			    $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

@@ -354,43 +278,36 @@
-			if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) {

-				// Exports virtual products

-				$r++;

-				$this->export_code[$r] = $this->rights_class.'_'.$r;

-				$this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)

-				$this->export_permission[$r] = array(array("service", "export"));

-				$this->export_fields_array[$r] = array(

-					'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl",

-					$alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

-					$alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode",

-					$alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

-					'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',

-					'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',

-					'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell",

-					'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'

-				);

-				if (isModEnabled('stock')) {

-					$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

-				}

-				if (isModEnabled('barcode')) {

-					$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-				}

-				$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));

-				$this->export_TypeFields_array[$r] = array(

-					'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text",

-					$alias_product_perentity . 'p.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text",

-					$alias_product_perentity . 'p.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text",

-					'p.note'=>"Text", 'p.note_public'=>"Text",

-					'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',

-					'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",

-					'p.datec'=>'Date', 'p.tms'=>'Date'

-				);

-				if (isModEnabled('stock')) {

-					$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

-				}

-				if (isModEnabled('barcode')) {

-					$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-				}

-				$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));

-				$this->export_entities_array[$r] = array(

-					'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct",

-					$alias_product_perentity . '.accountancy_code_sell'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export'=>'virtualproduct',

-					$alias_product_perentity . '.accountancy_code_buy'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export'=>'virtualproduct',

+			if (!empty($conf->global->PRODUIT_SOUSPRODUITS))

+			{

+			    // Exports virtual products

+			    $r++;

+			    $this->export_code[$r] = $this->rights_class.'_'.$r;

+			    $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)

+			    $this->export_permission[$r] = array(array("produit", "export"));

+			    $this->export_fields_array[$r] = array(

+			        'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl",

+			    	'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",

+			    	'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",

+					'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",

+			    	'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',

+			    	'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',

+			        'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell",

+			        'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'

+			    );

+			    if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));

+			    if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

+			    $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));

+			    $this->export_TypeFields_array[$r] = array(

+			        'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text",

+			    	'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text",

+					'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",

+			    	'p.note'=>"Text", 'p.note_public'=>"Text",

+			    	'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',

+			        'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",

+			        'p.datec'=>'Date', 'p.tms'=>'Date'

+			    );

+			    if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));

+			    if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

+			    $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));

+			    $this->export_entities_array[$r] = array(

+			        'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct",

+			    	'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct',

+			    	'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct',

@@ -398,26 +315,17 @@
-					'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct',

-					'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct",

-					'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct"

-				);

-				if (isModEnabled('stock')) {

-					$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));

-				}

-				if (isModEnabled('barcode')) {

-					$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));

-				}

-				$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));

-				$keyforselect = 'product';

-				$keyforelement = 'product';

-				$keyforaliasextra = 'extra';

-				include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-				$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));

-				$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));

-				$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-				$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

-				if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {

-					$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity);

-				}

-				$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';

-				$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';

-				$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

-				$this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';

+			        'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct',

+			        'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct",

+			        'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct"

+			    );

+			    if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));

+			    if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));

+			    $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));

+			    $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';

+			    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+			    $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));

+			    $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));

+			    $this->export_sql_start[$r] = 'SELECT DISTINCT ';

+			    $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

+			    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';

+			    $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';

+			    $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile

+			    $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';

@@ -440,40 +348,40 @@
-		$this->import_fields_array[$r] = array(

-			'p.ref' => "Ref*",

-			'p.label' => "Label*",

-			'p.fk_product_type' => "Type*",

-			'p.tosell' => "OnSell*",

-			'p.tobuy' => "OnBuy*",

-			'p.description' => "Description",

-			'p.url' => "PublicUrl",

-			'p.customcode' => 'CustomCode',

-			'p.fk_country' => 'CountryCode',

-			'p.accountancy_code_sell' => "ProductAccountancySellCode",

-			'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",

-			'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",

-			'p.accountancy_code_buy' => "ProductAccountancyBuyCode",

-			'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",

-			'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",

-			'p.note_public' => "NotePublic",

-			'p.note' => "NotePrivate",

-			'p.weight' => "Weight",

-			'p.weight_units' => "WeightUnits",

-			'p.length' => "Length",

-			'p.length_units' => "LengthUnits",

-			'p.width' => "Width",

-			'p.width_units' => "WidthUnits",

-			'p.height' => "Height",

-			'p.height_units' => "HeightUnits",

-			'p.surface' => "Surface",

-			'p.surface_units' => "SurfaceUnits",

-			'p.volume' => "Volume",

-			'p.volume_units' => "VolumeUnits",

-			'p.duration' => "Duration", //duration of service

-			'p.finished' => 'Nature',

-			'p.price' => "SellingPriceHT", //without

-			'p.price_min' => "MinPrice",

-			'p.price_ttc' => "SellingPriceTTC", //with tax

-			'p.price_min_ttc' => "SellingMinPriceTTC",

-			'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card

-			'p.tva_tx' => 'VATRate',

-			'p.datec' => 'DateCreation',

-			'p.cost_price' => "CostPrice",

+        $this->import_fields_array[$r] = array(

+        	'p.ref' => "Ref*",

+        	'p.label' => "Label*",

+        	'p.fk_product_type' => "Type*",

+        	'p.tosell' => "OnSell*",

+        	'p.tobuy' => "OnBuy*",

+        	'p.description' => "Description",

+        	'p.url' => "PublicUrl",

+        	'p.customcode' => 'CustomCode',

+        	'p.fk_country' => 'CountryCode',

+        	'p.accountancy_code_sell' => "ProductAccountancySellCode",

+        	'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",

+        	'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",

+        	'p.accountancy_code_buy' => "ProductAccountancyBuyCode",

+        	'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",

+        	'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",

+        	'p.note_public' => "NotePublic",

+        	'p.note' => "NotePrivate",

+        	'p.weight' => "Weight",

+        	'p.weight_units' => "WeightUnits",

+        	'p.length' => "Length",

+        	'p.length_units' => "LengthUnit",

+        	'p.width' => "Width",

+            'p.width_units' => "WidthUnits",

+        	'p.height' => "Height",

+        	'p.height_units' => "HeightUnit",

+        	'p.surface' => "Surface",

+        	'p.surface_units' => "SurfaceUnit",

+        	'p.volume' => "Volume",

+        	'p.volume_units' => "VolumeUnits",

+        	'p.duration' => "Duration", //duration of service

+        	'p.finished' => 'Nature',

+        	'p.price' => "SellingPriceHT", //without

+        	'p.price_min' => "MinPrice",

+        	'p.price_ttc' => "SellingPriceTTC", //with tax

+        	'p.price_min_ttc' => "SellingMinPriceTTC",

+        	'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card

+        	'p.tva_tx' => 'VATRate',

+        	'p.datec' => 'DateCreation',

+        	'p.cost_price' => "CostPrice",

@@ -481,112 +389,72 @@
-

-		$this->import_convertvalue_array[$r] = array(

-			'p.weight_units' => array(

-				'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

-				'classfile' => '/core/class/cunits.class.php',

-				'class' => 'CUnits',

-				'method' => 'fetch',

-				'units' => 'weight',

-				'dict' => 'DictionaryMeasuringUnits'

-			),

-			'p.length_units' => array(

-				'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

-				'classfile' => '/core/class/cunits.class.php',

-				'class' => 'CUnits',

-				'method' => 'fetch',

-				'units' => 'size',

-				'dict' => 'DictionaryMeasuringUnits'

-			),

-			'p.width_units' => array(

-				'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

-				'classfile' => '/core/class/cunits.class.php',

-				'class' => 'CUnits',

-				'method' => 'fetch',

-				'units' => 'size',

-				'dict' => 'DictionaryMeasuringUnits'

-			),

-			'p.height_units' => array(

-				'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

-				'classfile' => '/core/class/cunits.class.php',

-				'class' => 'CUnits',

-				'method' => 'fetch',

-				'units' => 'size',

-				'dict' => 'DictionaryMeasuringUnits'

-			),

-			'p.surface_units' => array(

-				'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

-				'classfile' => '/core/class/cunits.class.php',

-				'class' => 'CUnits',

-				'method' => 'fetch',

-				'units' => 'surface',

-				'dict' => 'DictionaryMeasuringUnits'

-			),

-			'p.volume_units' => array(

-				'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

-				'classfile' => '/core/class/cunits.class.php',

-				'class' => 'CUnits',

-				'method' => 'fetch',

-				'units' => 'volume',

-				'dict' => 'DictionaryMeasuringUnits'

-			),

-			'p.fk_country' => array(

-				'rule' => 'fetchidfromcodeid',

-				'classfile' => '/core/class/ccountry.class.php',

-				'class' => 'Ccountry',

-				'method' => 'fetch',

-				'dict' => 'DictionaryCountry'

-			)

-		);

-

-		$this->import_regex_array[$r] = array(

-			'p.ref' => '[^ ]',

-			'p.price_base_type' => '\AHT\z|\ATTC\z',

-			'p.tosell' => '^[0|1]$',

-			'p.tobuy' => '^[0|1]$',

-			'p.fk_product_type' => '^[0|1]$',

-			'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

-			'p.recuperableonly' => '^[0|1]$',

-		);

-

-		if (isModEnabled('stock')) {//if Stock module enabled

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

-				'p.fk_default_warehouse'=>'DefaultWarehouse',

-				'p.tobatch'=>'ManageLotSerial',

-				'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning

-				'p.pmp' => 'PMPValue', //weighted average price

-				'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature

-			));

-

-			$this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(

-				'p.tobatch' => '^[0|1|2]$'

-			));

-

-			$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(

-				'p.fk_default_warehouse' => array(

-					'rule' => 'fetchidfromref',

-					'classfile' => '/product/stock/class/entrepot.class.php',

-					'class' => 'Entrepot',

-					'method' => 'fetch',

-					'element'=> 'Warehouse'

-				)

-			));

-		}

-

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));

-		}

-		if (is_object($mysoc) && $usenpr) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type'));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));

-		}

-		if (isModEnabled('barcode')) {

-			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));

-		}

-		if (getDolGlobalInt('PRODUCT_USE_UNITS')) {

-			$this->import_fields_array[$r]['p.fk_unit'] = 'Unit';

-		}

-		// Add extra fields

+        if (!empty($conf->stock->enabled)) {//if Stock module enabled

+        	$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

+        		'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning

+        		'p.pmp' => 'PMPValue', //weighted average price

+        		'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature

+        	));

+        }

+

+        $this->import_convertvalue_array[$r] = array(

+        	'p.weight_units' => array(

+        		'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        		'classfile' => '/core/class/cunits.class.php',

+        		'class' => 'CUnits',

+        		'method' => 'fetch',

+        		'units' => 'weight',

+        		'dict' => 'DictionaryMeasuringUnits'

+        	),

+        	'p.length_units' => array(

+        		'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        		'classfile' => '/core/class/cunits.class.php',

+        		'class' => 'CUnits',

+        		'method' => 'fetch',

+        		'units' => 'size',

+        		'dict' => 'DictionaryMeasuringUnits'

+        	),

+        	'p.width_units' => array(

+        		'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        		'classfile' => '/core/class/cunits.class.php',

+        		'class' => 'CUnits',

+        		'method' => 'fetch',

+        		'units' => 'size',

+        		'dict' => 'DictionaryMeasuringUnits'

+        	),

+        	'p.height_units' => array(

+        		'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        		'classfile' => '/core/class/cunits.class.php',

+        		'class' => 'CUnits',

+        		'method' => 'fetch',

+        		'units' => 'size',

+        		'dict' => 'DictionaryMeasuringUnits'

+        	),

+        	'p.surface_units' => array(

+        		'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        		'classfile' => '/core/class/cunits.class.php',

+        		'class' => 'CUnits',

+        		'method' => 'fetch',

+        		'units' => 'surface',

+        		'dict' => 'DictionaryMeasuringUnits'

+        	),

+        	'p.volume_units' => array(

+        		'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table

+        		'classfile' => '/core/class/cunits.class.php',

+        		'class' => 'CUnits',

+        		'method' => 'fetch',

+        		'units' => 'volume',

+        		'dict' => 'DictionaryMeasuringUnits'

+        	),

+        	'p.fk_country' => array(

+        		'rule' => 'fetchidfromcodeid',

+        		'classfile' => '/core/class/ccountry.class.php',

+        		'class' => 'Ccountry',

+        		'method' => 'fetch',

+        		'dict' => 'DictionaryCountry'

+        	)

+        );

+        if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));

+        if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));

+        if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type'));

+        if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));

+        if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));

+		if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';

+        // Add extra fields

@@ -594 +462 @@
-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.")";

+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";

@@ -596,7 +464,9 @@
-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-				$import_extrafield_sample[$fieldname] = $fieldlabel;

-			}

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+		    while ($obj = $this->db->fetch_object($resql))

+		    {

+		        $fieldname = 'extra.'.$obj->name;

+		        $fieldlabel = ucfirst($obj->label);

+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

+		        $import_extrafield_sample[$fieldname] = $fieldlabel;

+		    }

@@ -607,2 +477,2 @@
-			'p.ref'=>'[^ ]',

-			'p.price_base_type' => 'HT|TTC',

+            'p.ref'=>'[^ ]',

+			'p.price_base_type' => '\AHT\z|\ATTC\z',

@@ -610,3 +480,3 @@
-			'p.tobuy'=>'^[0|1]$',

-			'p.fk_product_type'=>'^[0|1]$',

-			'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

+            'p.tobuy'=>'^[0|1]$',

+            'p.fk_product_type'=>'^[0|1]$',

+            'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

@@ -618 +488 @@
-			'p.ref' => "ref:PREF123456",

+			'p.ref' => "PREF123456",

@@ -655 +525 @@
-			'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"'

+			'p.finished' => '0 (raw material) / 1 (finished goods)'

@@ -658,2 +528 @@
-		if (isModEnabled('stock')) {

-			$import_sample = array_merge($import_sample, array(

+		if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(

@@ -663,18 +532,7 @@
-			));

-		}

-		if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {

-			$import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));

-		}

-		if (is_object($mysoc) && $usenpr) {

-			$import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-			$import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));

-		}

-		if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-			$import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));

-		}

-		if (isModEnabled('barcode')) {

-			$import_sample = array_merge($import_sample, array('p.barcode'=>''));

-		}

-		if (getDolGlobalInt('PRODUCT_USE_UNITS')) {

+		));

+		if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));

+		if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));

+		if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));

+		if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));

+		if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>''));

+		if (!empty($conf->global->PRODUCT_USE_UNITS)) {

@@ -686,5 +544,3 @@
-			);

-

-			if (!is_array($this->import_convertvalue_array[$r])) {

-				$this->import_convertvalue_array[$r] = array();

-			}

+				);

+

+			if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array();

@@ -703,7 +559,7 @@
-		if (isModEnabled('barcode')) {

-			$this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled

-		}

-

-		if (!isModEnabled("product")) {	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)

-			if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {

-				// Import suppliers prices (note: this code is duplicated in module Service)

+		if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled

+

+		if (empty($conf->product->enabled))	// We enable next import templates only if module product not already enabled (to avoid duplicate entries)

+		{

+			if (!empty($conf->fournisseur->enabled))

+			{

+			    // Import suppliers prices (note: this code is duplicated in module Service)

@@ -718,8 +574,8 @@
-					'sp.fk_product'=>"ProductOrService*",

-					'sp.fk_soc' => "Supplier*",

-					'sp.ref_fourn' => 'SupplierRef*',

-					'sp.quantity' => "QtyMin*",

-					'sp.tva_tx' => 'VATRate',

-					'sp.default_vat_code' => 'VATCode',

-					'sp.delivery_time_days' => 'NbDaysToDelivery',

-					'sp.supplier_reputation' => 'SupplierReputation'

+				    'sp.fk_product'=>"ProductOrService*",

+				    'sp.fk_soc' => "Supplier*",

+				    'sp.ref_fourn' => 'SupplierRef*',

+				    'sp.quantity' => "QtyMin*",

+				    'sp.tva_tx' => 'VATRate',

+				    'sp.default_vat_code' => 'VATCode',

+				    'sp.delivery_time_days' => 'DeliveryDelay',

+				    'sp.supplier_reputation' => 'SupplierReputation'

@@ -727,9 +583,3 @@
-				if (is_object($mysoc) && $usenpr) {

-					$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));

-				}

-				if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-					$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

-				}

-				if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-					$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

-				}

+				if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));

+				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

+				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

@@ -742,8 +592,9 @@
-				if (isModEnabled("multicurrency")) {

-					$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

-					'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line

-					'sp.multicurrency_code'=>'CurrencyCode',

-					'sp.multicurrency_tx'=>'CurrencyRate',

-					'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',

-					'sp.multicurrency_price'=>'CurrencyPrice',

-					));

+				if (!empty($conf->multicurrency->enabled))

+				{

+				    $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(

+				        'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line

+				        'sp.multicurrency_code'=>'CurrencyCode',

+				        'sp.multicurrency_tx'=>'CurrencyRate',

+				        'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',

+				        'sp.multicurrency_price'=>'CurrencyPrice',

+				    ));

@@ -755 +606 @@
-					);

+				);

@@ -757 +608 @@
-					'sp.fk_product' => "ref:PRODUCT_REF or id:123456",

+					'sp.fk_product' => "PRODUCT_REF or id:123456",

@@ -768,10 +619,4 @@
-					);

-				if (is_object($mysoc) && $usenpr) {

-					$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));

-				}

-				if (is_object($mysoc) && $mysoc->useLocalTax(1)) {

-					$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

-				}

-				if (is_object($mysoc) && $mysoc->useLocalTax(2)) {

-					$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

-				}

+				);

+				if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));

+				if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));

+				if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));

@@ -783,2 +628,3 @@
-					));

-				if (isModEnabled("multicurrency")) {

+				));

+				if (!empty($conf->multicurrency->enabled))

+				{

@@ -786,6 +632,6 @@
-					'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',

-					'sp.multicurrency_code'=>'GBP',

-					'sp.multicurrency_tx'=>'1.12345',

-					'sp.multicurrency_unitprice'=>'',

-					// TODO Make this field not required and calculate it from price and qty

-					'sp.multicurrency_price'=>''

+						'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',

+						'sp.multicurrency_code'=>'GBP',

+						'sp.multicurrency_tx'=>'1.12345',

+						'sp.multicurrency_unitprice'=>'',

+						// TODO Make this field not required and calculate it from price and qty

+						'sp.multicurrency_price'=>''

@@ -794,5 +639,0 @@
-				if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {

-					$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(

-						'sp.packagning'=>'10',

-					));

-				}

@@ -803,2 +644,3 @@
-			if (getDolGlobalString('PRODUIT_MULTIPRICES')) {

-				// Import products multiprices

+			if (!empty($conf->global->PRODUIT_MULTIPRICES))

+			{

+			    // Import products multiprices

@@ -817,6 +659,2 @@
-				if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) {

-					$this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';

-				}

-				if (is_object($mysoc) && $usenpr) {

-					$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR'));

-				}

+				if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';

+				if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR'));

@@ -825 +663 @@
-					'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')

+				    'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')

@@ -827 +665 @@
-				$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:SERVICE_REF or id:123456",

+				$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456",

@@ -832 +670 @@
-					'pr.recuperableonly'=>'0',

+				    'pr.recuperableonly'=>'0',

@@ -836,2 +674,3 @@
-			if (getDolGlobalInt('MAIN_MULTILANGS')) {

-				// Import translations of product names and descriptions

+			if (!empty($conf->global->MAIN_MULTILANGS))

+			{

+			    // Import translations of product names and descriptions

@@ -850 +689 @@
-				$this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');

+				$this->import_examplevalues_array[$r] = array('l.fk_product'=>'SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');

@@ -862 +701 @@
-	 *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modSocialNetworks.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSocialNetworks.class.php
@@ -24 +24 @@
- *  \brief      Description and activation file for the module SocialNetworks

+ *  \brief      Description and activation file for module SocialNetworks

@@ -33 +33,2 @@
-	/**

+

+    /**

@@ -37,4 +38,4 @@
-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

+     */

+    public function __construct($db)

+    {

+    	global $langs, $conf;

@@ -42,2 +43,2 @@
-		$this->db = $db;

-		$this->numero = 3400;

+        $this->db = $db;

+        $this->numero = 3400;

@@ -47,6 +48,6 @@
-		$this->family = "interface";

-		// Module position in the family on 2 digits ('01', '10', '20', ...)

-		$this->module_position = '20';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";

+        $this->family = "interface";

+        // Module position in the family on 2 digits ('01', '10', '20', ...)

+        $this->module_position = '20';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";

@@ -54,5 +55,5 @@
-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'share-alt';

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'email';

@@ -60,2 +61,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -63 +64 @@
-		// Config pages

+        // Config pages

@@ -66,3 +67,3 @@
-		// Dependencies

-		$this->hidden = getDolGlobalString('MODULE_SOCIALNETWORKS_DISABLED'); // A condition to hide module

-		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled

+        // Dependencies

+        $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module

+		$this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled

@@ -71,2 +72,2 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->langfiles = array();

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->langfiles = array();

@@ -74 +75 @@
-		// Constants

+        // Constants

@@ -77,2 +78,2 @@
-		// New pages on tabs

-		$this->tabs = array();

+        // New pages on tabs

+        $this->tabs = array();

@@ -80,2 +81,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -83,3 +84,3 @@
-		// Main menu entries

-		$this->menu = array();

-	}

+        // Main menu entries

+        $this->menu = array();

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modSociete.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSociete.class.php
@@ -8 +7,0 @@
- * Copyright (C) 2022      Ferran Marcet        <fmarcet@2byte.es>

@@ -29 +28 @@
- *	\brief      Description and activation file for the module societe (thirdparty)

+ *	\brief      Fichier de description et activation du module Societe

@@ -38,0 +38 @@
+

@@ -46 +46 @@
-		global $conf, $user, $mysoc, $langs;

+		global $conf, $user;

@@ -73 +73 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -125,8 +125,14 @@
-		$this->boxes = array(

-			0=>array('file'=>'box_clients.php', 'enabledbydefaulton'=>'Home'),

-			1=>array('file'=>'box_prospect.php', 'enabledbydefaulton'=>'Home'),

-			2=>array('file'=>'box_contacts.php', 'enabledbydefaulton'=>'Home'),

-			3=>array('file'=>'box_activity.php', 'enabledbydefaulton'=>'Home', 'note'=>'(WarningUsingThisBoxSlowDown)'),

-			4=>array('file'=>'box_goodcustomers.php', 'enabledbydefaulton'=>'Home', 'note'=>'(WarningUsingThisBoxSlowDown)'),

-		);

-

+		$this->boxes = array();

+		$r = 0;

+		$this->boxes[$r][1] = "box_clients.php";

+		$r++;

+		$this->boxes[$r][1] = "box_prospect.php";

+		$r++;

+		$this->boxes[$r][1] = "box_contacts.php";

+		$r++;

+		$this->boxes[$r][1] = "box_activity.php";

+		$this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)';

+		$r++;

+		$this->boxes[$r][1] = "box_goodcustomers.php";

+		$this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)';

+		$r++;

@@ -150 +156 @@
-		$this->rights[$r][4] = 'thirdparty_customer_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on

+		$this->rights[$r][4] = 'thirparty_customer_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on

@@ -160 +166 @@
-		*/

+        */

@@ -174 +180 @@
-		$this->rights[$r][4] = 'thirdparty_customer_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on

+		$this->rights[$r][4] = 'thirparty_customer_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on

@@ -184 +190 @@
-		*/

+        */

@@ -200,8 +206 @@
-		$r++;

-		$this->rights[$r][0] = 130;

-		$this->rights[$r][1] = 'Modify thirdparty information payment';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'thirdparty_paymentinformation_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on

-		$this->rights[$r][5] = 'write';

-

-		// 262 : Restrict access to sales representative

+		// 262 : Resteindre l'acces des commerciaux

@@ -210 +209 @@
-		$this->rights[$r][1] = 'Read all third parties (and their objects) by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).';

+		$this->rights[$r][1] = 'Read all third parties by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).';

@@ -215,10 +213,0 @@
-

-		/*

-		$r++;

-		$this->rights[$r][0] = 263;

-		$this->rights[$r][1] = 'Read all third parties (without their objects) by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'client';

-		$this->rights[$r][5] = 'readallthirdparties_advance';

-		*/

@@ -275,2 +264 @@
-			's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 'ps.nom'=>"ParentCompany",

-			's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification",

+			's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification",

@@ -278,2 +266,2 @@
-			's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom'=>'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax",

-			's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.canvas' => "Canvas", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4",

+			's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax",

+			's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4",

@@ -281,6 +269,10 @@
-			't.code'=>"ThirdPartyType", 'ce.code'=>"DictionaryStaff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel',

-			'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode',

-			's.outstanding_limit'=>'OutstandingBill', 'pbacc.ref'=>'PaymentBankAccount', 'incoterm.code'=>'IncotermLabel'

-		);

-		if (getDolGlobalString('SOCIETE_USEPREFIX')) {

-			$this->export_fields_array[$r]['s.prefix'] = 'Prefix';

+			't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel',

+			'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode'

+		);

+		if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix';

+		if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel';

+		// Add multicompany field

+		if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))

+		{

+			$nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1

+			if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity');

@@ -288,16 +280 @@
-		if (getDolGlobalString('PRODUIT_MULTIPRICES')) {

-			$this->export_fields_array[$r]['s.price_level'] = 'PriceLevel';

-		}

-		if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {

-			$this->export_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode');

-		}

-		// Add multicompany field

-		if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {

-			$nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1

-			if (isModEnabled('multicompany') && $nbofallowedentities > 1) {

-				$this->export_fields_array[$r] += array('s.entity'=>'Entity');

-			}

-		}

-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra';

@@ -306 +283,8 @@
-

+		//$this->export_TypeFields_array[$r]=array(

+		//	's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",

+		//	's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",

+		//	'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",

+		//	's.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text",

+		//	't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',

+		//	's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'

+		//);

@@ -308,26 +292,12 @@
-			's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 'ps.nom'=>"Text",

-			's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date",

-			's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",

-			's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text",

-			'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>'List:c_country:label:label', 'c.code'=>'Text',

-			's.phone'=>"Text", 's.fax'=>"Text",

-			's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.canvas' => "Text",

-			's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text",

-			's.tva_intra'=>"Text", 's.capital'=>"Numeric",

-			's.note_private'=>"Text", 's.note_public'=>"Text",

-			't.code'=>"List:c_typent:libelle:code",

-			'ce.code'=>"List:c_effectif:libelle:code",

-			"cfj.libelle"=>"Text",

-			's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',

-			'st.code'=>'List:c_stcomm:libelle:code',

-			'payterm.libelle'=>'Text', 'paymode.libelle'=>'Text',

-			's.outstanding_limit'=>'Numeric', 'pbacc.ref'=>'Text', 'incoterm.code'=>'Text',

-			'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text',

-			's.entity'=>'List:entity:label:rowid', 's.price_level'=>'Numeric',

-			's.accountancy_code_sell'=>'Text', 's.accountancy_code_buy'=>'Text'

-		);

-

-		$this->export_entities_array[$r] = array(	// We define here only fields that use another picto

-			'u.login'=>'user',

-			'u.firstname'=>'user',

-			'u.lastname'=>'user');

+			's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date",

+			's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text",

+			's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",

+			's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text",

+			's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text",

+			'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',

+			'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text',

+			'paymode.libelle'=>'Text', 's.entity'=>'Numeric',

+			's.price_level'=>'Numeric'

+		);

+

+		$this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto

@@ -338 +307,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON s.parent = ps.rowid';

@@ -344 +312,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = s.fk_pays';

@@ -349,2 +316,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as pbacc ON s.fk_account = pbacc.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';

@@ -352,3 +318,3 @@
-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.((int) $user->id).' ';

-			if (getDolGlobalString('SOCIETE_EXPORT_SUBORDINATES_CHILDS')) {

+		if (is_object($user) && empty($user->rights->societe->client->voir)) {

+			$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';

+			if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {

@@ -356 +322 @@
-				$this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.$this->db->sanitize(implode(',', $subordinatesids)).')' : '';

+				$this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';

@@ -370,2 +336 @@
-			'd.nom'=>'State', 'r.nom'=>'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail",

-			'c.note_private'=>'NotePrivate', 'c.note_public'=>"NotePublic",

+			'd.nom'=>'State', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail",

@@ -377,17 +342,2 @@
-			's.note_private'=>'NotePrivate', 's.note_public'=>"NotePublic",

-			't.code'=>"ThirdPartyType"

-		);

-		// Add multicompany field

-		if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {

-			if (isModEnabled('multicompany')) {

-				$nbofallowedentities = count(explode(',', getEntity('contact')));

-				if ($nbofallowedentities > 1) {

-					$this->export_fields_array[$r]['c.entity'] = 'Entity';

-				}

-

-				$nbofallowedentities = count(explode(',', getEntity('societe')));

-				if ($nbofallowedentities > 1) {

-					$this->export_fields_array[$r]['s.entity'] = 'Entity';

-				}

-			}

-		}

+			't.libelle'=>"ThirdPartyType"

+		);

@@ -397 +347 @@
-			'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'r.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text",

+			'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text",

@@ -400 +350 @@
-			's.rowid'=>"Numeric", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",

+			's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",

@@ -402 +352 @@
-			's.client'=>"Numeric", 's.fournisseur'=>"Numeric",

+			's.client'=>"Text", 's.fournisseur'=>"Text",

@@ -404,5 +354,3 @@
-			't.code'=>"List:c_stcomm:libelle:code",

-			'c.entity'=>'List:entity:label:rowid',

-			's.entity'=>'List:entity:label:rowid',

-		);

-		$this->export_entities_array[$r] = array(	// We define here only fields that use another picto

+			't.libelle'=>"Text"

+		);

+		$this->export_entities_array[$r] = array(

@@ -413,2 +361 @@
-			't.code'=>"company",

-			's.entity'=>'company',

+			't.libelle'=>"company"

@@ -416 +363,2 @@
-		if (!isModEnabled("supplier_order") && !isModEnabled("supplier_invoice")) {

+		if (empty($conf->fournisseur->enabled))

+		{

@@ -420,3 +368 @@
-		$keyforselect = 'socpeople';

-		$keyforelement = 'contact';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra';

@@ -424,3 +370 @@
-		$keyforselect = 'societe';

-		$keyforelement = 'company';

-		$keyforaliasextra = 'extrasoc';

+		$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';

@@ -432,3 +376 @@
-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

-		}

+		if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';

@@ -436 +377,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays';

@@ -440,4 +381,4 @@
-		$this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('contact').')';

-		if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {

-			$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.((int) $user->id).' ';

-			if (getDolGlobalString('SOCIETE_EXPORT_SUBORDINATES_CHILDS')) {

+		$this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('socpeople').')';

+		if (is_object($user) && empty($user->rights->societe->client->voir)) {

+			$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';

+			if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {

@@ -445 +386 @@
-				$this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.$this->db->sanitize(implode(',', $subordinatesids)).')' : '';

+				$this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';

@@ -467 +408 @@
-			's.nom' => "ThirdPartyName*",

+			's.nom' => "Name*",

@@ -469,2 +410 @@
-			's.parent' => "ParentCompany",

-			's.status' => "Status*",

+			's.status' => "Status",

@@ -483,0 +424 @@
+			's.skype' => "Skype",

@@ -505,3 +445,0 @@
-			's.outstanding_limit'=>'OutstandingBill',

-			's.fk_account'=>'PaymentBankAccount',

-			's.fk_incoterms'=>'IncotermLabel',

@@ -516,18 +454 @@
-		if (getDolGlobalString('PRODUIT_MULTIPRICES')) {

-			$this->import_fields_array[$r]['s.price_level'] = 'PriceLevel';

-		}

-		if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {

-			$this->import_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode');

-		}

-		// Add social networks fields

-		if (isModEnabled('socialnetworks')) {

-			$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1";

-			$resql = $this->db->query($sql);

-			if ($resql) {

-				while ($obj = $this->db->fetch_object($resql)) {

-					$fieldname = 's.socialnetworks_'.$obj->code;

-					$fieldlabel = ucfirst($obj->label);

-					$this->import_fields_array[$r][$fieldname] = $fieldlabel;

-				}

-			}

-		}

+		if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel';

@@ -535 +456 @@
-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";

+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";

@@ -537 +458,2 @@
-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

@@ -559 +481 @@
-				'dict' => 'DictionaryStateCode'

+				'dict' => 'DictionaryState'

@@ -576,42 +498 @@
-			's.parent' => array(

-				'rule' => 'fetchidfromref',

-				'file' => '/societe/class/societe.class.php',

-				'class' => 'Societe',

-				'method' => 'fetch',

-				'element' => 'ThirdParty'

-			),

-			's.outstanding_limit' => array('rule' => 'numeric'),

-			's.fk_account' => array(

-				'rule' => 'fetchidfromcodeid',

-				'classfile' => '/compta/bank/class/account.class.php',

-				'class' => 'Account',

-				'method' => 'fetch',

-				'element' => 'BankAccount'

-			),

-			's.fk_stcomm' => array(

-				'rule' => 'fetchidfromcodeid',

-				'classfile' => '/core/class/cgenericdic.class.php',

-				'class' => 'CGenericDic',

-				'method' => 'fetch',

-				'dict' => 'DictionaryProspectStatus',

-				'element' => 'c_stcomm',

-				'table_element' => 'c_stcomm'

-			),

-			/*

-			's.fk_prospectlevel' => array(

-				'rule' => 'fetchidfromcodeid',

-				'classfile' => '/core/class/cgenericdic.class.php',

-				'class' => 'CGenericDic',

-				'method' => 'fetch',

-				'dict' => 'DictionaryProspectLevel',

-				'element' => 'c_prospectlevel',

-				'table_element' => 'c_prospectlevel'

-			),*/

-		//          TODO

-		//          's.fk_incoterms' => array(

-		//              'rule' => 'fetchidfromcodeid',

-		//              'classfile' => '/core/class/cincoterm.class.php',

-		//              'class' => 'Cincoterm',

-		//              'method' => 'fetch',

-		//              'dict' => 'IncotermLabel'

-		//			)

+			's.fk_stcomm' => array('rule' => 'zeroifnull'),

@@ -629 +509,0 @@
-			's.fk_incoterms' => 'rowid@'.MAIN_DB_PREFIX.'c_incoterms',

@@ -639 +518,0 @@
-			's.parent' => "TPMotherCompany",

@@ -653,0 +533 @@
+			's.skype' => "Skype name",

@@ -675,3 +554,0 @@
-			's.outstanding_limit' => "5000",

-			's.fk_account' => "rowid or ref",

-			's.fk_incoterms' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_incoterms"',

@@ -684,3 +561 @@
-			's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.'c_currencies"',

-			's.accountancy_code_sell' => '707',

-			's.accountancy_code_buy' => '607',

+			's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.'c_currencies"'

@@ -689,3 +564 @@
-			's.nom' => 'ThirdPartyName',

-			's.zip' => 'Zip',

-			's.email' => 'Email',

+			's.nom' => 'Name',

@@ -697,34 +570,2 @@
-		if (isModEnabled('socialnetworks')) {

-			$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1";

-			$resql = $this->db->query($sql);

-			if ($resql) {

-				while ($obj = $this->db->fetch_object($resql)) {

-					$fieldname = 's.socialnetworks_'.$obj->code;

-					$fieldlabel = ucfirst($obj->label);

-					$this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;

-				}

-			}

-		}

-		// Add profids as criteria to search duplicates

-		$langs->load("companies");

-		$i=1;

-		while ($i <= 6) {

-			if ($i == 1) {

-				$this->import_updatekeys_array[$r]['s.siren'] = 'ProfId1'.(empty($mysoc->country_code) ? '' : $mysoc->country_code);

-			}

-			if ($i == 2) {

-				$this->import_updatekeys_array[$r]['s.siret'] = 'ProfId2'.(empty($mysoc->country_code) ? '' : $mysoc->country_code);

-			}

-			if ($i == 3) {

-				$this->import_updatekeys_array[$r]['s.ape'] = 'ProfId3'.(empty($mysoc->country_code) ? '' : $mysoc->country_code);

-			}

-			if ($i >= 4) {

-				//var_dump($langs->trans('ProfId'.$i.(empty($mysoc->country_code) ? '' : $mysoc->country_code)));

-				if ($langs->trans('ProfId'.$i.(empty($mysoc->country_code) ? '' : $mysoc->country_code)) != '-') {

-					$this->import_updatekeys_array[$r]['s.idprof'.$i] = 'ProfId'.$i.(empty($mysoc->country_code) ? '' : $mysoc->country_code);

-				}

-			}

-			$i++;

-		}

-

-		// Import list of contacts/addresses of thirparties and attributes

+

+		// Import list of contacts/additional addresses and attributes

@@ -752,2 +593,2 @@
-			's.birthday' => "DateOfBirth",

-			's.poste' => "PostOrFunction",

+			's.birthday' => "BirthdayDate",

+			's.poste' => "Role",

@@ -758,0 +600 @@
+			's.skype' => "Skype",

@@ -762,12 +603,0 @@
-		// Add social networks fields

-		if (isModEnabled('socialnetworks')) {

-			$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1";

-			$resql = $this->db->query($sql);

-			if ($resql) {

-				while ($obj = $this->db->fetch_object($resql)) {

-					$fieldname = 's.socialnetworks_'.$obj->code;

-					$fieldlabel = ucfirst($obj->label);

-					$this->import_fields_array[$r][$fieldname] = $fieldlabel;

-				}

-			}

-		}

@@ -775 +605 @@
-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";

+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";

@@ -777 +607,2 @@
-		if ($resql) {    // This can fail when class is used on an old database (during a migration for example)

+		if ($resql)    // This can fail when class is used on an old database (during a migration for example)

+		{

@@ -802 +633 @@
-				'dict' => 'DictionaryCanton'

+				'dict' => 'DictionaryState'

@@ -835,0 +667 @@
+			's.skype' => "skype username",

@@ -840,14 +672,2 @@
-			's.rowid' => 'Id',

-			's.lastname' => "Lastname",

-		);

-		if (isModEnabled('socialnetworks')) {

-			$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1";

-			$resql = $this->db->query($sql);

-			if ($resql) {

-				while ($obj = $this->db->fetch_object($resql)) {

-					$fieldname = 's.socialnetworks_'.$obj->code;

-					$fieldlabel = ucfirst($obj->label);

-					$this->import_updatekeys_array[$r][$fieldname] = $fieldlabel;

-				}

-			}

-		}

+			's.rowid' => 'Id'

+		);

@@ -869 +689 @@
-			'sr.number' => "BankAccountNumber",

+			'sr.number' => "BankAccountNumber*",

@@ -878 +697,0 @@
-			'sr.frstrecur' => "WithdrawMode",

@@ -894,4 +713,2 @@
-			'sr.datec' => 'date used for creating direct debit UMR formatted as '.dol_print_date(

-				dol_now(),

-				'%Y-%m-%d'

-			),

+			'sr.datec' => 'date used for creating direct debit UMR formatted as '.dol_print_date(dol_now(),

+					'%Y-%m-%d'),

@@ -910 +726,0 @@
-			'sr.frstrecur' => 'FRST',

@@ -951 +767,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -955 +772,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modStock.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modStock.class.php
@@ -6 +5,0 @@
- * Copyright (C) 2021	   Ferran Marcet        <fmarcet@2byte.es>

@@ -27 +26 @@
- *	\brief      Description and activation file for the module Stock

+ *	\brief      Fichier de description et activation du module Stock

@@ -37,0 +37 @@
+

@@ -72 +72 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -84 +84 @@
-		$this->const[$r][2] = "standard";

+		$this->const[$r][2] = "Standard";

@@ -91,2 +91,2 @@
-		$this->const[$r][2] = "stdmovement";

-		$this->const[$r][3] = 'Name of PDF model of stock movement';

+		$this->const[$r][2] = "StdMouvement";

+		$this->const[$r][3] = 'Name of PDF model of stock mouvement';

@@ -116,76 +116,60 @@
-		$r = 0;

-

-		$this->rights[$r][0] = 1001;

-		$this->rights[$r][1] = 'Read stocks';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'lire';

-		$this->rights[$r][5] = '';

-

-		$r++;

-		$this->rights[$r][0] = 1002;

-		$this->rights[$r][1] = 'Create/Modify stocks';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'creer';

-		$this->rights[$r][5] = '';

-

-		$r++;

-		$this->rights[$r][0] = 1003;

-		$this->rights[$r][1] = 'Delete stock';

-		$this->rights[$r][2] = 'd';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'supprimer';

-		$this->rights[$r][5] = '';

-

-		$r++;

-		$this->rights[$r][0] = 1004;

-		$this->rights[$r][1] = 'Read stock movements';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'mouvement';

-		$this->rights[$r][5] = 'lire';

-

-		$r++;

-		$this->rights[$r][0] = 1005;

-		$this->rights[$r][1] = 'Create/modify stock movements';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'mouvement';

-		$this->rights[$r][5] = 'creer';

-

-		$r++;

-		$this->rights[$r][0] = 1011;

-		$this->rights[$r][1] = 'inventoryReadPermission'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-

-		$r++;

-		$this->rights[$r][0] = 1012;

-		$this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-

-		$r++;

-		$this->rights[$r][0] = 1013;

-		$this->rights[$r][1] = 'inventoryDeletePermission'; // Permission label

-		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-		$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-		$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-

-		if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {

-			$r++;

-			$this->rights[$r][0] = 1014;

-			$this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label

-			$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-			$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-			$this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-

-			$r++;

-			$this->rights[$r][0] = 1015;

-			$this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label

-			$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

-			$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

-			$this->rights[$r][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+		$this->rights[0][0] = 1001;

+		$this->rights[0][1] = 'Lire les stocks';

+		$this->rights[0][2] = 'r';

+		$this->rights[0][3] = 0;

+		$this->rights[0][4] = 'lire';

+		$this->rights[0][5] = '';

+

+		$this->rights[1][0] = 1002;

+		$this->rights[1][1] = 'Creer/Modifier les stocks';

+		$this->rights[1][2] = 'w';

+		$this->rights[1][3] = 0;

+		$this->rights[1][4] = 'creer';

+		$this->rights[1][5] = '';

+

+		$this->rights[2][0] = 1003;

+		$this->rights[2][1] = 'Supprimer les stocks';

+		$this->rights[2][2] = 'd';

+		$this->rights[2][3] = 0;

+		$this->rights[2][4] = 'supprimer';

+		$this->rights[2][5] = '';

+

+		$this->rights[3][0] = 1004;

+		$this->rights[3][1] = 'Lire mouvements de stocks';

+		$this->rights[3][2] = 'r';

+		$this->rights[3][3] = 0;

+		$this->rights[3][4] = 'mouvement';

+		$this->rights[3][5] = 'lire';

+

+		$this->rights[4][0] = 1005;

+		$this->rights[4][1] = 'Creer/modifier mouvements de stocks';

+		$this->rights[4][2] = 'w';

+		$this->rights[4][3] = 0;

+		$this->rights[4][4] = 'mouvement';

+		$this->rights[4][5] = 'creer';

+

+		if ($conf->global->MAIN_FEATURES_LEVEL >= 2)

+		{

+    		$this->rights[5][0] = 1011;

+    		$this->rights[5][1] = 'inventoryReadPermission'; // Permission label

+    		$this->rights[5][3] = 0; // Permission by default for new user (0/1)

+    		$this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+    		$this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+

+    		$this->rights[6][0] = 1012;

+    		$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label

+    		$this->rights[6][3] = 0; // Permission by default for new user (0/1)

+    		$this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+    		$this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+

+    		$this->rights[8][0] = 1014;

+    		$this->rights[8][1] = 'inventoryValidatePermission'; // Permission label

+    		$this->rights[8][3] = 0; // Permission by default for new user (0/1)

+    		$this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+    		$this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+

+    		$this->rights[9][0] = 1015;

+    		$this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label

+    		$this->rights[9][3] = 0; // Permission by default for new user (0/1)

+    		$this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

+    		$this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

@@ -207,5 +191,3 @@
-		// Export warehouses

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_emplacement';

-		$this->export_label[$r] = "Warehouses"; // Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->export_icon[$r] = "warehouse";

+		$r++;

+		$this->export_code[$r] = $this->rights_class;

+		$this->export_label[$r] = "WarehousesAndProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)

@@ -214,3 +196,4 @@
-			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town',

-			'd.code_departement'=>'Departement', 'c.code'=>'CountryCode',

-			'e.phone'=>'Phone', 'e.fax'=>'Fax', 'e.statut'=>'Status', 'pe.rowid'=>'ParentWarehouse', 'pe.ref'=>'LocationSummary'

+			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address',

+			'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description",

+			'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation',

+			'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice'

@@ -219,46 +202,5 @@
-			'e.ref'=>'Text', 'e.description'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text',

-			'd.code_departement'=>'List:c_departements:code_departement:code_departement:', 'c.code'=>'List:c_country:code:code:',

-			'e.phone'=>'Text', 'e.fax'=>'Text', 'e.statut'=>'Text', 'pe.rowid'=>'List:entrepot:ref:rowid:stock', 'pe.ref'=>'Text'

-		);

-		$this->export_entities_array[$r] = array();	// We define here only fields that use another icon that the one defined into export_icon

-		$this->export_aggregate_array[$r] = array();	// TODO Not used yet

-		$keyforselect = 'warehouse';

-		$keyforelement = 'warehouse';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'entrepot as e';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON d.rowid = e.fk_departement';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON c.rowid = e.fk_pays';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as pe ON pe.rowid = e.fk_parent';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot_extrafields as extra ON extra.fk_object = e.rowid';

-		$this->export_sql_end[$r] .= ' WHERE e.entity IN ('.getEntity('stock').')';

-

-		// Export stock (without batch number)

-		$r++;

-		$this->export_code[$r] = $this->rights_class.'_emplacement_product';

-		$this->export_label[$r] = "Stocks"; // Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->export_icon[$r] = "warehouse";

-		$this->export_permission[$r] = array(array("stock", "lire"));

-		$this->export_fields_array[$r] = array(

-			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town',

-			'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note",

-			'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration",

-			'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice',

-			'p.seuil_stock_alerte'=>'StockLimit', 'p.barcode'=>'BarCode', 'bt.libelle'=>'BarcodeType',

-		);

-		if (isModEnabled('barcode')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-		}

-		$this->export_TypeFields_array[$r] = array(

-			'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text',

-			'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",

-			'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree",

-			'p.datec'=>'Date', 'p.tms'=>'Date', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric',

-			'ps.reel'=>'Numeric',

-			'p.seuil_stock_alerte'=>'Numeric', 'p.barcode'=>'Text', 'bt.libelle'=>'List:c_barcode_type:libelle',

-		);

-		if (isModEnabled('barcode')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-		}

+			'e.rowid'=>'List:entrepot:ref::stock', 'e.ref'=>'Text', 'e.lieu'=>'Text', 'e.address'=>'Text', 'e.zip'=>'Text', 'e.town'=>'Text', 'p.rowid'=>"List:product:label::product",

+			'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text", 'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric',

+			'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric',

+			'ps.reel'=>'Numeric'

+		);

@@ -266,9 +208,5 @@
-			'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product",

-			'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product",

-			'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product',

-			'ps.reel'=>'stock',

-			'p.seuil_stock_alerte'=>'product', 'p.barcode'=>'product', 'bt.libelle'=>'c_barcode_type',

-		);	// We define here only fields that use another icon that the one defined into export_icon

-		if (isModEnabled('barcode')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-		}

+			'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse',

+			'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product",

+			'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product",

+			'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product', 'ps.reel'=>'stock'

+		);

@@ -277,3 +215 @@
-		$keyforselect = 'product';

-		$keyforelement = 'product';

-		$keyforaliasextra = 'extra';

+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';

@@ -284,4 +220 @@
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_barcode_type as bt ON bt.rowid = p.fk_barcode_type';

-		$this->export_sql_end[$r] .= ', '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';

+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';

@@ -290,3 +223,3 @@
-

-		// Export stock including batch number

-		if (isModEnabled('productbatch')) {

+		if ($conf->productbatch->enabled)

+		{

+			// Export of stock including lot number

@@ -298,3 +231,2 @@
-			$this->export_code[$r] = $this->rights_class.'_emplacement_product_lot';

-			$this->export_label[$r] = "StocksWithBatch"; // Translation key (used only if key ExportDataset_xxx_z not found)

-			$this->export_icon[$r] = "warehouse";

+			$this->export_code[$r] = $this->rights_class.'_lot';

+			$this->export_label[$r] = "WarehousesAndProductsBatchDetail"; // Translation key (used only if key ExportDataset_xxx_z not found)

@@ -303,6 +235,4 @@
-				'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town',

-				'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note",

-				'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration",

-				'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice',

-				'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.qty'=>'Qty',

-				'pl.eatby'=>'EatByDate', 'pl.sellby'=>'SellByDate'

+				'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address',

+				'e.zip'=>'Zip', 'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description",

+				'p.note'=>"Note", 'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation',

+				'p.tms'=>'DateModification', 'pb.rowid'=>'Id', 'pb.batch'=>'Batch', 'pb.qty'=>'Qty', 'pl.eatby'=>'EatByDate', 'pl.sellby'=>'SellByDate'

@@ -310,3 +239,0 @@
-			if (isModEnabled('barcode')) {

-				$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-			}

@@ -315,5 +242,3 @@
-				'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",

-				'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree",

-				'p.datec'=>'DateCreation', 'p.tms'=>'DateModification', 'p.pmp'=>'PMPValue', 'p.cost_price'=>'CostPrice',

-				'pb.batch'=>'Text', 'pb.qty'=>'Numeric',

-				'pl.eatby'=>'Date', 'pl.sellby'=>'Date'

+				'p.rowid'=>"List:product:label::product", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",

+				'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date',

+				'pb.batch'=>'Text', 'pb.qty'=>'Numeric', 'pl.eatby'=>'Date', 'pl.sellby'=>'Date'

@@ -321,3 +245,0 @@
-			if (isModEnabled('barcode')) {

-				$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-			}

@@ -325,9 +247,6 @@
-				'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product",

-				'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product",

-				'p.datec'=>'product', 'p.tms'=>'product', 'p.pmp'=>'product', 'p.cost_price'=>'product',

-				'pb.rowid'=>'batch', 'pb.batch'=>'batch', 'pb.qty'=>'batch',

-				'pl.eatby'=>'batch', 'pl.sellby'=>'batch'

-			);	// We define here only fields that use another icon that the one defined into export_icon

-			if (isModEnabled('barcode')) {

-				$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-			}

+				'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse',

+				'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product",

+				'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product",

+				'p.datec'=>'product', 'p.tms'=>'product', 'pb.rowid'=>'stockbatch', 'pb.batch'=>'stockbatch', 'pb.qty'=>'stockbatch', 'pl.eatby'=>'batch',

+				'pl.sellby'=>'batch'

+			);

@@ -336,3 +255 @@
-			$keyforselect = 'product_lot';

-			$keyforelement = 'batch';

-			$keyforaliasextra = 'extra';

+			$keyforselect = 'product_lot'; $keyforelement = 'batch'; $keyforaliasextra = 'extra';

@@ -340 +256,0 @@
-

@@ -342,3 +258 @@
-			$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product_batch as pb';

-			$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps ON ps.rowid = pb.fk_product_stock';

-			$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = ps.fk_product';

+			$this->export_sql_end[$r]  = ' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)';

@@ -348 +262 @@
-			$this->export_sql_end[$r] .= ' WHERE ps.fk_entrepot = e.rowid';

+			$this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';

@@ -352 +266 @@
-		// Export of stock movements

+		// Export of stock movement

@@ -356 +269,0 @@
-		$this->export_icon[$r] = "movement";

@@ -359,8 +272,6 @@
-			'sm.rowid'=>'MovementId', 'sm.value'=>'Qty', 'sm.datem'=>'DateMovement', 'sm.label'=>'MovementLabel', 'sm.inventorycode'=>'InventoryCode',

-			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip', 'e.town'=>'Town',

-			'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note",

-			'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'

-		);

-		if (isModEnabled('barcode')) {

-			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));

-		}

+			'e.rowid'=>'IdWarehouse', 'e.ref'=>'LocationSummary', 'e.description'=>'DescWareHouse', 'e.lieu'=>'LieuWareHouse', 'e.address'=>'Address', 'e.zip'=>'Zip',

+			'e.town'=>'Town', 'p.rowid'=>"ProductId", 'p.ref'=>"Ref", 'p.fk_product_type'=>"Type", 'p.label'=>"Label", 'p.description'=>"Description", 'p.note'=>"Note",

+			'p.price'=>"Price", 'p.tva_tx'=>'VAT', 'p.tosell'=>"OnSell", 'p.tobuy'=>'OnBuy', 'p.duration'=>"Duration", 'p.datec'=>'DateCreation',

+			'p.tms'=>'DateModification', 'sm.rowid'=>'MovementId', 'sm.value'=>'Qty', 'sm.datem'=>'DateMovement', 'sm.label'=>'MovementLabel',

+			'sm.inventorycode'=>'InventoryCode'

+		);

@@ -368 +278,0 @@
-			'sm.rowid'=>'Numeric', 'sm.value'=>'Numeric', 'sm.datem'=>'Date', 'sm.batch'=>'Text', 'sm.label'=>'Text', 'sm.inventorycode'=>'Text',

@@ -370,6 +280,4 @@
-			'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",

-			'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date'

-		);

-		if (isModEnabled('barcode')) {

-			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));

-		}

+			'p.rowid'=>"List:product:label::product", 'p.ref'=>"Text", 'p.fk_product_type'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.note'=>"Text",

+			'p.price'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.duration'=>"Duree", 'p.datec'=>'Date', 'p.tms'=>'Date',

+			'sm.rowid'=>'Numeric', 'sm.value'=>'Numeric', 'sm.datem'=>'Date', 'sm.batch'=>'Text', 'sm.label'=>'Text', 'sm.inventorycode'=>'Text'

+		);

@@ -377,5 +285,7 @@
-			'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse', 'e.town'=>'warehouse',

-			'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product", 'p.note'=>"product",

-			'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", 'p.datec'=>'product', 'p.tms'=>'product'

-		);	// We define here only fields that use another icon that the one defined into export_icon

-		if (isModEnabled('productbatch')) {

+			'e.rowid'=>'warehouse', 'e.ref'=>'warehouse', 'e.description'=>'warehouse', 'e.lieu'=>'warehouse', 'e.address'=>'warehouse', 'e.zip'=>'warehouse',

+			'e.town'=>'warehouse', 'p.rowid'=>"product", 'p.ref'=>"product", 'p.fk_product_type'=>"product", 'p.label'=>"product", 'p.description'=>"product",

+			'p.note'=>"product", 'p.price'=>"product", 'p.tva_tx'=>'product', 'p.tosell'=>"product", 'p.tobuy'=>"product", 'p.duration'=>"product", 'p.datec'=>'product',

+			'p.tms'=>'product', 'sm.rowid'=>'movement', 'sm.value'=>'movement', 'sm.datem'=>'movement', 'sm.label'=>'movement', 'sm.inventorycode'=>'movement'

+		);

+		if ($conf->productbatch->enabled)

+		{

@@ -386,3 +295,0 @@
-		if (isModEnabled('barcode')) {

-			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));

-		}

@@ -391 +297,0 @@
-

@@ -406 +312 @@
-		$this->import_icon[$r] = "warehouse";

+		$this->import_icon[$r] = $this->picto;

@@ -411,8 +317,2 @@
-				'e.description'=>"DescWareHouse",

-				'e.lieu'=>"LieuWareHouse",

-				'e.address'=>"Address",

-				'e.zip'=>'Zip',

-				'e.fk_departement'=>'StateCode',

-				'e.fk_pays'=>'CountryCode',

-				'e.phone'=>'Phone',

-				'e.fax'=>'Fax',

+				'e.description'=>"DescWareHouse", 'e.lieu'=>"LieuWareHouse",

+				'e.address'=>"Address", 'e.zip'=>'Zip', 'e.fk_pays'=>'CountryCode',

@@ -420 +320 @@
-				'e.fk_parent'=>'ParentWarehouse'

+                'e.fk_parent'=>'ParentWarehouse'

@@ -424 +323,0 @@
-				'e.fk_departement'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryStateCode'),

@@ -426 +325 @@
-				'e.fk_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'ref')

+                'e.fk_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'ref')

@@ -430,8 +329,2 @@
-				'e.description'=>"Central Warehouse",

-				'e.lieu'=>"Central",

-				'e.address'=>"Route 66",

-				'e.zip'=>'28080',

-				'e.fk_departement'=>'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',

-				'e.fk_pays'=>'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',

-				'e.phone'=>'(+33)(0)123456789',

-				'e.fax'=>'(+33)(0)123456790',

+				'e.description'=>"Central Warehouse", 'e.lieu'=>"Central",

+				'e.address'=>"Route 66", 'e.zip'=>'28080', 'e.fk_pays'=>'US',

@@ -439,3 +332,2 @@
-				'e.fk_parent'=>'id or ref of warehouse'

-		);

-		$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');

+                'e.fk_parent'=>''

+        );

@@ -447 +339 @@
-		$this->import_icon[$r] = "stock";

+		$this->import_icon[$r] = $this->picto;

@@ -457 +349 @@
-			'ps.fk_product'=>"id or ref of product", 'ps.fk_entrepot'=>"id or ref of warehouse", 'ps.reel'=>"10"

+		    'ps.fk_product'=>"PREF123456", 'ps.fk_entrepot'=>"ALM001", 'ps.reel'=>"10"

@@ -461 +353 @@
-			'UPDATE '.MAIN_DB_PREFIX.'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);'

+		    'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);'

@@ -478,5 +369,0 @@
-		$result = $this->_load_tables('/install/mysql/', 'stock');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

@@ -487,5 +374,6 @@
-		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/stocks/template_warehouse.odt';

-		$dirodt = DOL_DATA_ROOT.'/doctemplates/stocks';

-		$dest = $dirodt.'/template_warehouse.odt';

-

-		if (file_exists($src) && !file_exists($dest)) {

+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt';

+		$dirodt = DOL_DATA_ROOT.'/doctemplates/stock';

+		$dest = $dirodt.'/template_stock.odt';

+

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -495 +383,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -505,4 +394,4 @@
-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".((int) $conf->entity),

-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".((int) $conf->entity).")",

-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".((int) $conf->entity),

-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".((int) $conf->entity).")",

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")",

+			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity,

+			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")",

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modStripe.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modStripe.class.php
@@ -24 +24 @@
- *  \brief      Description and activation file for the module Stripe

+ *  \brief      Description and activation file for module Stripe

@@ -34,8 +34,8 @@
-	/**

-	 *   Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *   @param      DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

+    /**

+     *   Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *   @param      DoliDB		$db      Database handler

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

@@ -43,5 +43,5 @@
-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 50300;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'stripe';

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 50300;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'stripe';

@@ -49,15 +49,15 @@
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "interface";

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Module to offer an online payment page by credit card with Stripe";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'

-		$this->picto = 'stripe';

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "interface";

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Module to offer an online payment page by credit card with Stripe";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'

+        $this->picto = 'stripe';

@@ -65,2 +65,2 @@
-		// Data directories to create when module is enabled.

-		$this->dirs = array();

+        // Data directories to create when module is enabled.

+        $this->dirs = array();

@@ -68,2 +68,2 @@
-		// Config pages. Put here list of php page names stored in admin directory used to setup module.

-		$this->config_page_url = array("stripe.php@stripe");

+        // Config pages. Put here list of php page names stored in admin directory used to setup module.

+        $this->config_page_url = array("stripe.php@stripe");

@@ -71,7 +71,7 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

-		$this->depends = array(); // 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->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(5, 0); // Minimum version of Dolibarr required by module

-		$this->langfiles = array("stripe");

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

+        $this->depends = array(); // 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->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(5, 0); // Minimum version of Dolibarr required by module

+        $this->langfiles = array("stripe");

@@ -79,2 +79,2 @@
-		// Constants

-		$this->const = array(); // List of particular constants to add when module is enabled

+        // Constants

+        $this->const = array(); // List of particular constants to add when module is enabled

@@ -82,2 +82,2 @@
-		// New pages on tabs

-		$this->tabs = array();

+        // New pages on tabs

+        $this->tabs = array();

@@ -85,3 +85,3 @@
-		// List of boxes

-		$this->boxes = array();

-		$r = 0;

+        // List of boxes

+        $this->boxes = array();

+        $r = 0;

@@ -89,3 +89,3 @@
-		// Permissions

-		$this->rights = array(); // Permission array used by this module

-		$r = 0;

+        // Permissions

+        $this->rights = array(); // Permission array used by this module

+        $r = 0;

@@ -93,17 +93,17 @@
-		// Main menu entries

-		$r = 0;

-		/* $this->menu[$r]=array(

-			'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-			'mainmenu'=>'billing',

-			'leftmenu'=>'customers_bills_payment_stripe',

-			'type'=>'left',			                // This is a Left menu entry

-			'titre'=>'StripeImportPayment',

-			'url'=>'/stripe/importpayments.php',

-			'langs'=>'stripe',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position'=>500,

-			'enabled'=>'$conf->stripe->enabled && isModEnabled("banque") && $conf->global->MAIN_FEATURES_LEVEL >= 2',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-			'perms'=>'$user->rights->banque->modifier',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-			'target'=>'',

-			'user'=>2

-		);				                // 0=Menu for internal users, 1=external users, 2=both

-		$r++;*/

+        // Main menu entries

+        $r = 0;

+        /* $this->menu[$r]=array(

+            'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+	        'mainmenu'=>'billing',

+        	'leftmenu'=>'customers_bills_payment_stripe',

+        	'type'=>'left',			                // This is a Left menu entry

+	        'titre'=>'StripeImportPayment',

+	        'url'=>'/stripe/importpayments.php',

+	        'langs'=>'stripe',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+	        'position'=>500,

+	        'enabled'=>'$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+	        'perms'=>'$user->rights->banque->modifier',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+	        'target'=>'',

+	        'user'=>2

+        );				                // 0=Menu for internal users, 1=external users, 2=both

+        $r++;*/

@@ -111,2 +111,2 @@
-		$this->menu[$r] = array(

-			'fk_menu'=>'fk_mainmenu=bank',

+        $this->menu[$r] = array(

+        	'fk_menu'=>'fk_mainmenu=bank',

@@ -115 +114,0 @@
-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),

@@ -121 +120 @@
-			'enabled' => 'isModEnabled("stripe") && isModenabled("banque")',

+			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',

@@ -127 +126 @@
-		$r++;

+        $r++;

@@ -135 +134 @@
-			'enabled' => 'isModEnabled("stripe") && isModenabled("banque") && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 1',

+			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',

@@ -141 +140 @@
-		$r++;

+        $r++;

@@ -149 +148 @@
-			'enabled' => 'isModEnabled("stripe") && isModenabled("banque") && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 2',

+			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',

@@ -155,2 +154,2 @@
-		$r++;

-		$this->menu[$r] = array(

+        $r++;

+	    $this->menu[$r] = array(

@@ -163 +162 @@
-			'enabled' => 'isModEnabled("stripe") && isModenabled("banque")',

+			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',

@@ -169,3 +168,3 @@
-		// Exports

-		$r = 1;

-	}

+        // Exports

+        $r = 1;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modSupplierProposal.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modSupplierProposal.class.php
@@ -29 +29 @@
- *	\brief      Description and activation file for the module supplier proposal

+ *	\brief      File to describe and activate module SupplierProposal

@@ -38,0 +39 @@
+

@@ -64,2 +65,2 @@
-		// Config pages. Put here list of php page names stored in admin directory used to setup module.

-		$this->config_page_url = array("supplier_proposal.php");

+		 // Config pages. Put here list of php page names stored in admin directory used to setup module.

+        $this->config_page_url = array("supplier_proposal.php");

@@ -72 +73 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -129 +130 @@
-		$this->rights[$r][4] = 'send_advance';

+        $this->rights[$r][4] = 'send_advance';

@@ -143 +144 @@
-		// Main menu entries

+ 		// Main menu entries

@@ -154 +155 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -157 +158 @@
-	public function init($options = '')

+    public function init($options = '')

@@ -169 +170,2 @@
-		if (file_exists($src) && !file_exists($dest)) {

+		if (file_exists($src) && !file_exists($dest))

+		{

@@ -173 +175,2 @@
-			if ($result < 0) {

+			if ($result < 0)

+			{

@@ -181,2 +184,2 @@
-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'supplier_proposal' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".((int) $conf->entity).")",

+				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'supplier_proposal' AND entity = ".$conf->entity,

+				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".$conf->entity.")",

@@ -200,5 +203,5 @@
-		$sql = array(

-			"DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"		// To delete/clean deprecated entries

-		);

-

-		return $this->_remove($sql, $options);

+	    $sql = array(

+	        "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"		// To delete/clean deprecated entries

+	    );

+

+	    return $this->_remove($sql, $options);

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modTakePos.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modTakePos.class.php
@@ -25 +25 @@
- *  \brief      Description and activation file for the module TakePos

+ *  \brief      Description and activation file for module TakePos

@@ -28 +27,0 @@
-include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';

@@ -43,3 +42,3 @@
-		global $langs, $conf;

-

-		$this->db = $db;

+        global $langs, $conf;

+

+        $this->db = $db;

@@ -82 +81 @@
-									'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)

+		                        	'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)

@@ -87 +86 @@
-									'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)

+		                        	'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)

@@ -91 +90 @@
-								);

+		                        );

@@ -102,2 +101 @@
-		// List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))

-		$this->depends = array('always'=>array("modBanque", "modFacture", "modProduct", "modCategorie"), 'FR'=>array('modBlockedLog'));

+		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled

@@ -107 +105 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -124 +122,2 @@
-		if (!isset($conf->takepos) || !isset($conf->takepos->enabled)) {

+		if (!isset($conf->takepos) || !isset($conf->takepos->enabled))

+		{

@@ -131 +130 @@
-		$this->tabs = array();

+        $this->tabs = array();

@@ -134,4 +133,4 @@
-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

-		//

-		// Where objecttype can be

+        // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //

+        // Where objecttype can be

@@ -147 +146 @@
-		// 'order'            to add a tab in sales order view

+		// 'order'            to add a tab in customer order view

@@ -159 +158 @@
-		// Dictionaries

+        // Dictionaries

@@ -161,3 +160,17 @@
-

-

-		// Boxes/Widgets

+        /* Example:

+        $this->dictionaries=array(

+            'langs'=>'mylangfile@takepos',

+            'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),		// List of tables we want to see into dictonnary editor

+            'tablib'=>array("Table1","Table2","Table3"),													// Label of tables

+            'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),	// Request to select fields

+            'tabsqlsort'=>array("label ASC","label ASC","label ASC"),																					// Sort order

+            'tabfield'=>array("code,label","code,label","code,label"),																					// List of fields (result of select to show dictionary)

+            'tabfieldvalue'=>array("code,label","code,label","code,label"),																				// List of fields (list of fields to edit a record)

+            'tabfieldinsert'=>array("code,label","code,label","code,label"),																			// List of fields (list of fields for insert)

+            'tabrowid'=>array("rowid","rowid","rowid"),																									// Name of columns with primary key (try to always name it 'rowid')

+            'tabcond'=>array($conf->takepos->enabled,$conf->takepos->enabled,$conf->takepos->enabled)												// Condition to show each dictionary

+        );

+        */

+

+

+        // Boxes/Widgets

@@ -165,5 +178,5 @@
-		$this->boxes = array(

-			//0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'),

-			//1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'),

-			//2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos')

-		);

+        $this->boxes = array(

+        	//0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'),

+        	//1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'),

+        	//2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos')

+        );

@@ -189 +202 @@
-		$this->rights[$r][1] = 'Use Point Of Sale (record a sale, add products, record payment)';

+		$this->rights[$r][1] = 'Use Point Of Sale';

@@ -193,14 +205,0 @@
-

-		$r++;

-		$this->rights[$r][0] = 50152;

-		$this->rights[$r][1] = 'Can modify added sales lines (prices, discount)';

-		$this->rights[$r][2] = 'a';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'editlines';

-

-		$r++;

-		$this->rights[$r][0] = 50153;

-		$this->rights[$r][1] = 'Edit ordered sales lines (useful only when option "Order printers" has been enabled). Allow to edit sales lines even after the order has been printed';

-		$this->rights[$r][2] = 'a';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'editorderedlines';

@@ -221 +219,0 @@
-								'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth"'),

@@ -225,2 +223,2 @@
-								'enabled'=>'isModEnabled("takepos")', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.

-								'perms'=>'$user->hasRight("takepos", "run")', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules

+								'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.

+								'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules

@@ -265 +263 @@
-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')

+     *	@param      string	$options    Options when enabling module ('', 'noboxes')

@@ -270,82 +268,9 @@
-		global $conf, $langs, $user, $mysoc;

-		$langs->load("cashdesk");

-

-		dolibarr_set_const($this->db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity);

-

-		// Default customer for Point of sale

-		if (!getDolGlobalInt('CASHDESK_ID_THIRDPARTY1')) {	// If a customer has already ben set into the TakePos setup page

-			$societe = new Societe($this->db);

-			$nametouse = $langs->trans("DefaultPOSThirdLabel");

-

-			$searchcompanyid = $societe->fetch(0, $nametouse);

-			if ($searchcompanyid == 0) {

-				$societe->name = $nametouse;

-				$societe->client = 1;

-				$societe->code_client = -1;

-				$societe->code_fournisseur = -1;

-				$societe->note_private = "Default customer automaticaly created by Point Of Sale module activation. Can be used as the default generic customer in the Point Of Sale setup. Can also be edited or removed if you don't need a generic customer.";

-

-				$searchcompanyid = $societe->create($user);

-			}

-			if ($searchcompanyid > 0) {

-				// We already have or we have create a thirdparty with id = $searchcompanyid, so we link use it into setup

-				dolibarr_set_const($this->db, "CASHDESK_ID_THIRDPARTY1", $searchcompanyid, 'chaine', 0, '', $conf->entity);

-			} else {

-				setEventMessages($societe->error, $societe->errors, 'errors');

-			}

-		}

-

-		//Create category if not exists

-		$categories = new Categorie($this->db);

-		$cate_arbo = $categories->get_full_arbo('product', 0, 1);

-		if (is_array($cate_arbo)) {

-			if (!count($cate_arbo)) {

-				$category = new Categorie($this->db);

-

-				$category->label = $langs->trans("DefaultPOSCatLabel");

-				$category->type = Categorie::TYPE_PRODUCT;

-

-				$result = $category->create($user);

-

-				if ($result > 0) {

-					/* TODO Create a generic product only if there is no product yet. If 0 product,  we create 1. If there is already product, it is better to show a message to ask to add product in the category */

-					/*

-					$product = new Product($this->db);

-					$product->status = 1;

-					$product->ref = "takepos";

-					$product->label = $langs->trans("DefaultPOSProductLabel");

-					$product->create($user);

-					$product->setCategories($result);

-					 */

-				} else {

-					setEventMessages($category->error, $category->errors, 'errors');

-				}

-			}

-		}

-

-		//Create cash account if not exists

-		if (!getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH1')) {

-			require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';

-			$cashaccount = new Account($this->db);

-			$searchaccountid = $cashaccount->fetch(0, "CASH-POS");

-			if ($searchaccountid == 0) {

-				$cashaccount->ref = "CASH-POS";

-				$cashaccount->label = $langs->trans("DefaultCashPOSLabel");

-				$cashaccount->courant = 2;

-				$cashaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;

-				$cashaccount->date_solde = dol_now();

-				$searchaccountid = $cashaccount->create($user);

-			}

-			if ($searchaccountid > 0) {

-				dolibarr_set_const($this->db, "CASHDESK_ID_BANKACCOUNT_CASH1", $searchaccountid, 'chaine', 0, '', $conf->entity);

-			} else {

-				setEventMessages($cashaccount->error, $cashaccount->errors, 'errors');

-			}

-		}

-

-		$result = $this->_load_tables('/install/mysql/', 'takepos');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Clean before activation

+		global $conf, $db;

+

+		dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity);

+

+		$this->_load_tables('/takepos/sql/');

+

+		$sql = array();

+

+		// Remove permissions and default values

@@ -353,2 +277,0 @@
-

-		$sql = array();

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modTax.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modTax.class.php
@@ -28 +28 @@
- *      \brief      Description and activation file for the module taxes

+ *      \brief      Fichier de description et activation du module Taxe

@@ -37,0 +38 @@
+

@@ -73 +74 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -89 +90 @@
-		$this->rights[$r][1] = 'Read social contibutions';

+		$this->rights[$r][1] = 'Lire les charges';

@@ -97 +98 @@
-		$this->rights[$r][1] = 'Create/modify social contributions';

+		$this->rights[$r][1] = 'Creer/modifier les charges';

@@ -105 +106 @@
-		$this->rights[$r][1] = 'Delete social contributions';

+		$this->rights[$r][1] = 'Supprimer les charges';

@@ -113 +114 @@
-		$this->rights[$r][1] = 'Export social contributions';

+		$this->rights[$r][1] = 'Exporter les charges';

@@ -149 +150 @@
-			't.amount'=>"Amount*", 't.date_ech'=>"DateDue*", 't.periode'=>"PeriodEndDate*"

+		    't.amount'=>"Amount*", 't.date_ech'=>"DateDue*", 't.periode'=>"PeriodEndDate*"

@@ -153 +154 @@
-			't.fk_type'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/sociales/class/cchargesociales.class.php', 'class'=>'Cchargesociales', 'method'=>'fetch', 'element'=>'Cchargesociales')

+		    't.fk_type'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/sociales/class/cchargesociales.class.php', 'class'=>'Cchargesociales', 'method'=>'fetch', 'element'=>'Cchargesociales')

@@ -156 +157 @@
-			't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01"

+		    't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01"

@@ -167 +168 @@
-			't.amount'=>"Amount*", 't.num_payment'=>'Numero'

+		    't.amount'=>"Amount*", 't.num_payment'=>'Numero'

@@ -171 +172 @@
-			't.fk_typepayment'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/paiement/class/cpaiement.class.php', 'class'=>'Cpaiement', 'method'=>'fetch', 'element'=>'Cpaiement')

+		    't.fk_typepayment'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/paiement/class/cpaiement.class.php', 'class'=>'Cpaiement', 'method'=>'fetch', 'element'=>'Cpaiement')

@@ -174 +175 @@
-			't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456'

+		    't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456'

@@ -184 +185 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modTicket.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modTicket.class.php
@@ -25 +25 @@
- *     \brief       Description and activation file for the module Ticket

+ *     \brief       Description and activation file for module Ticket

@@ -35,62 +35,61 @@
-	/**

-	 *     Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 *     @param DoliDB $db Database handler

-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

-		$langs->load("ticket");

-

-		$this->db = $db;

-

-		// Id for module (must be unique).

-		// Use a free id here

-		// (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 56000;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'ticket';

-

-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

-		// It is used to group modules in module setup page

-		$this->family = "crm";

-		// Module position in the family

-		$this->module_position = '60';

-		// Module label (no space allowed)

-		// used if translation string 'ModuleXXXName' not found

-		// (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description

-		// used if translation string 'ModuleXXXDesc' not found

-		// (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Incident/support ticket management";

-		// Possible values for version are: 'development', 'experimental' or version

-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled

-		// (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png

-		// use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png

-		// use this->picto='pictovalue@module'

-		$this->picto = 'ticket'; // mypicto@ticket

-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)

-		// for default path (eg: /ticket/core/xxxxx) (0=disable, 1=enable)

-		// for specific path of parts (eg: /ticket/core/modules/barcode)

-		// for specific css file (eg: /ticket/css/ticket.css.php)

-		$this->module_parts = array(

-			// Set this to 1 if module has its own trigger directory

-			'triggers' => 1,

-		);

-

-		// Data directories to create when module is enabled.

-		// Example: this->dirs = array("/ticket/temp");

-		$this->dirs = array();

-

-		// Config pages. Put here list of php pages

-		// stored into ticket/admin directory, used to setup module.

-		$this->config_page_url = array("ticket.php");

-

-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+    /**

+     *     Constructor. Define names, constants, directories, boxes, permissions

+     *

+     *     @param DoliDB $db Database handler

+     */

+    public function __construct($db)

+    {

+        global $langs, $conf;

+

+        $this->db = $db;

+

+        // Id for module (must be unique).

+        // Use a free id here

+        // (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 56000;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'ticket';

+

+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'

+        // It is used to group modules in module setup page

+        $this->family = "crm";

+        // Module position in the family

+        $this->module_position = '60';

+        // Module label (no space allowed)

+        // used if translation string 'ModuleXXXName' not found

+        // (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description

+        // used if translation string 'ModuleXXXDesc' not found

+        // (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Incident/support ticket management";

+        // Possible values for version are: 'development', 'experimental' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled

+        // (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png

+        // use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png

+        // use this->picto='pictovalue@module'

+        $this->picto = 'ticket'; // mypicto@ticket

+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)

+        // for default path (eg: /ticket/core/xxxxx) (0=disable, 1=enable)

+        // for specific path of parts (eg: /ticket/core/modules/barcode)

+        // for specific css file (eg: /ticket/css/ticket.css.php)

+        $this->module_parts = array(

+            // Set this to 1 if module has its own trigger directory

+            'triggers' => 1,

+        );

+

+        // Data directories to create when module is enabled.

+        // Example: this->dirs = array("/ticket/temp");

+        $this->dirs = array();

+

+        // Config pages. Put here list of php pages

+        // stored into ticket/admin directory, used to setup module.

+        $this->config_page_url = array("ticket.php");

+

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -100,303 +99,199 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->langfiles = array("ticket");

-

-		// Constants

-		// List of particular constants to add when module is enabled

-		// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

-		// Example:

-		$default_footer = $langs->trans('TicketMessageMailFooterText', getDolGlobalString('MAIN_INFO_SOCIETE_NOM'));

-		$this->const = array(

-			1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0),

-			2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0),

-			3 => array('TICKET_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/tickets', 'Ticket templates ODT/ODS directory for templates', 0),

-			4 => array('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'chaine', 0, 'Automatically mark ticket as read when created from backend', 0),

-			5 => array('TICKET_DELAY_BEFORE_FIRST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time before a first answer to a ticket (in hours). Display a warning in tickets list if not respected.', 0),

-			6 => array('TICKET_DELAY_SINCE_LAST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time between two answers on the same ticket (in hours). Display a warning in tickets list if not respected.', 0),

-			7 => array('TICKET_NOTIFY_AT_CLOSING', 'chaine', '0', 'Default notify contacts when closing a module', 0),

-			8 => array('TICKET_PRODUCT_CATEGORY', 'chaine', 0, 'The category of product that is being used for ticket accounting', 0),

-			9 => array('TICKET_NOTIFICATION_EMAIL_FROM', 'chaine', getDolGlobalString('MAIN_MAIL_EMAIL_FROM'), 'Email to use by default as sender for messages sent from Dolibarr', 0),

-			10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0),

-			11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_footer, 'Signature to use by default for messages sent from Dolibarr', 0),

-			12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0),

-			13 => array('MAIN_SECURITY_ENABLECAPTCHA_TICKET', 'chaine', getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'), 'Enable captcha code by default', 0),

-			14 => array('TICKET_SHOW_COMPANY_LOGO', 'chaine', getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO'), 'Enable logo header on ticket public page', 0),

-			15 => array('TICKET_SHOW_COMPANY_FOOTER', 'chaine', getDolGlobalInt('TICKET_SHOW_COMPANY_FOOTER'), 'Enable footer on ticket public page', 0)

-		);

-

-

-		$this->tabs = array(

-			'thirdparty:+ticket:Tickets:ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__',

-		);

-

-		// Dictionaries

-		if (!isset($conf->ticket->enabled)) {

-			$conf->ticket = new stdClass();

-			$conf->ticket->enabled = 0;

-		}

-		$this->dictionaries = array(

-			'langs' => 'ticket',

-			'tabname' => array(

-				"c_ticket_type",

-				"c_ticket_severity",

-				"c_ticket_category",

-				"c_ticket_resolution"

-			),

-			'tablib' => array(

-				"TicketDictType",

-				"TicketDictSeverity",

-				"TicketDictCategory",

-				"TicketDictResolution"

-			),

-			'tabsql' => array(

-				'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.entity FROM '.MAIN_DB_PREFIX.'c_ticket_type as f WHERE f.entity IN ('.getEntity('c_ticket_type').')',

-				'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.entity FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f WHERE f.entity IN ('.getEntity('c_ticket_severity').')',

-				'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.public, f.fk_parent, f.entity FROM '.MAIN_DB_PREFIX.'c_ticket_category as f WHERE f.entity IN ('.getEntity('c_ticket_category').')',

-				'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.entity FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f WHERE f.entity IN ('.getEntity('c_ticket_resolution').')'

-			),

-			'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"),

-			'tabfield' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"),

-			'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"),

-			'tabfieldinsert' => array("code,label,pos,use_default,entity", "code,label,pos,use_default,entity", "code,label,pos,use_default,public,fk_parent,entity", "code,label,pos,use_default,entity"),

-			'tabrowid' => array("rowid", "rowid", "rowid", "rowid"),

-			'tabcond' => array(isModEnabled("ticket"), isModEnabled("ticket"), isModEnabled("ticket"), isModEnabled("ticket") && getDolGlobalString('TICKET_ENABLE_RESOLUTION')),

-			'tabhelp' => array(

-				array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")),

-				array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")),

-				array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"), 'public'=>$langs->trans("Enter0or1").'<br>'.$langs->trans("TicketGroupIsPublicDesc"), 'fk_parent'=>$langs->trans("IfThisCategoryIsChildOfAnother")),

-				array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))

-			),

-		);

-

-		// Boxes

-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.

-		$this->boxes = array(

-			0=>array('file'=>'box_last_ticket.php', 'enabledbydefaulton'=>'Home'),

-			1=>array('file'=>'box_last_modified_ticket.php', 'enabledbydefaulton'=>'Home'),

-			2=>array('file'=>'box_ticket_by_severity.php', 'enabledbydefaulton'=>'ticketindex'),

-			3=>array('file'=>'box_graph_nb_ticket_last_x_days.php', 'enabledbydefaulton'=>'ticketindex'),

-			4=>array('file'=>'box_graph_nb_tickets_type.php', 'enabledbydefaulton'=>'ticketindex'),

-			5=>array('file'=>'box_new_vs_close_ticket.php', 'enabledbydefaulton'=>'ticketindex')

-		); // Boxes list

-

-		// Permissions

-		$this->rights = array(); // Permission array used by this module

-

-		$r = 0;

-		$this->rights[$r][0] = 56001; // id de la permission

-		$this->rights[$r][1] = "Read ticket"; // libelle de la permission

-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'read';

-

-		$r++;

-		$this->rights[$r][0] = 56002; // id de la permission

-		$this->rights[$r][1] = "Create les tickets"; // libelle de la permission

-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'write';

-

-		$r++;

-		$this->rights[$r][0] = 56003; // id de la permission

-		$this->rights[$r][1] = "Delete les tickets"; // libelle de la permission

-		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'delete';

-

-		$r++;

-		$this->rights[$r][0] = 56004; // id de la permission

-		$this->rights[$r][1] = "Manage tickets"; // libelle de la permission

-		//$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'manage';

-

-		$r++;

-		$this->rights[$r][0] = 56006; // id de la permission

-		$this->rights[$r][1] = "Export ticket"; // libelle de la permission

-		//$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'export';

-

-		/* Seems not used and in conflict with societe->client->voir (see all thirdparties)

-		$r++;

-		$this->rights[$r][0] = 56005; // id de la permission

-		$this->rights[$r][1] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)'; // libelle de la permission

-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'view';

-		$this->rights[$r][5] = 'all';

-		*/

-

-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

-

-		/*$this->menu[$r] = array('fk_menu' => 0, // Put 0 if this is a top menu

-			'type' => 'top', // This is a Top menu entry

-			'titre' => 'Ticket',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em092"'),

-			'mainmenu' => 'ticket',

-			'leftmenu' => '1', // Use 1 if you also want to add left menu entries using this descriptor.

-			'url' => '/ticket/index.php',

-			'langs' => 'ticket', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-			'position' => 88,

-			'enabled' => 'isModEnabled("ticket")',

-			'perms' => '$user->rights->ticket->read', // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules

-			'target' => '',

-			'user' => 2); // 0=Menu for internal users, 1=external users, 2=both

-		$r++;*/

-

-		$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket',

-			'type' => 'left',

-			'titre' => 'Ticket',

-			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em092"'),

-			'mainmenu' => 'ticket',

-			'leftmenu' => 'ticket',

-			'url' => '/ticket/index.php',

-			'langs' => 'ticket',

-			'position' => 101,

-			'enabled' => 'isModEnabled("ticket")',

-			'perms' => '$user->rights->ticket->read',

-			'target' => '',

-			'user' => 2);

-		$r++;

-

-		$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

-			'type' => 'left',

-			'titre' => 'NewTicket',

-			'mainmenu' => 'ticket',

-			'url' => '/ticket/card.php?action=create',

-			'langs' => 'ticket',

-			'position' => 102,

-			'enabled' => 'isModEnabled("ticket")',

-			'perms' => '$user->rights->ticket->write',

-			'target' => '',

-			'user' => 2);

-		$r++;

-

-		$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

-			'type' => 'left',

-			'titre' => 'List',

-			'mainmenu' => 'ticket',

-			'leftmenu' => 'ticketlist',

-			'url' => '/ticket/list.php?search_fk_status=non_closed',

-			'langs' => 'ticket',

-			'position' => 103,

-			'enabled' => 'isModEnabled("ticket")',

-			'perms' => '$user->rights->ticket->read',

-			'target' => '',

-			'user' => 2);

-		$r++;

-

-		$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

-			'type' => 'left',

-			'titre' => 'MenuTicketMyAssign',

-			'mainmenu' => 'ticket',

-			'leftmenu' => 'ticketmy',

-			'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed',

-			'langs' => 'ticket',

-			'position' => 105,

-			'enabled' => 'isModEnabled("ticket")',

-			'perms' => '$user->rights->ticket->read',

-			'target' => '',

-			'user' => 0);

-		$r++;

-

-		$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

-			'type' => 'left',

-			'titre' => 'Statistics',

-			'mainmenu' => 'ticket',

-			'url' => '/ticket/stats/index.php',

-			'langs' => 'ticket',

-			'position' => 107,

-			'enabled' => 'isModEnabled("ticket")',

-			'perms' => '$user->rights->ticket->read',

-			'target' => '',

-			'user' => 0);

-		$r++;

-

-		$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

-			'type' => 'left',

-			'titre' => 'Categories',

-			'mainmenu' => 'ticket',

-			'url' => '/categories/index.php?type=12',

-			'langs' => 'ticket',

-			'position' => 107,

-			'enabled' => '$conf->categorie->enabled',

-			'perms' => '$user->rights->ticket->read',

-			'target' => '',

-			'user' => 0);

-		$r++;

-

-		// Exports

-		//--------

-		$r = 1;

-

-		// Export list of tickets and attributes

-		$langs->load("ticket");

-		$this->export_code[$r]=$this->rights_class.'_'.$r;

-		$this->export_label[$r]='ExportDataset_ticket_1';	// Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->export_permission[$r] = array(array("ticket", "export"));

-		$this->export_icon[$r]='ticket';

-		$keyforclass = 'Ticket';

-		$keyforclassfile='/ticket/class/ticket.class.php';

-		$keyforelement='ticket';

-		include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';

-		$keyforselect='ticket';

-		$keyforaliasextra='extra';

-		$keyforelement='ticket';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$this->export_sql_start[$r]='SELECT DISTINCT ';

-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'ticket as t';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'ticket_extrafields as extra on (t.rowid = extra.fk_object)';

-		$this->export_sql_end[$r] .=' WHERE 1 = 1';

-		$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('ticket').')';

-		$r++;

-	}

-

-	/**

-	 *	Function called when module is enabled.

-	 *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *	It also creates data directories

-	 *

-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')

-	 *	@return     int             	1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf, $langs;

-

-		$result = $this->_load_tables('/install/mysql/', 'ticket');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Permissions

-		$this->remove($options);

-

-		//ODT template

-		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tickets/template_ticket.odt';

-		$dirodt = DOL_DATA_ROOT.'/doctemplates/tickets';

-		$dest = $dirodt.'/template_order.odt';

-

-		if (file_exists($src) && !file_exists($dest)) {

-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-			dol_mkdir($dirodt);

-			$result = dol_copy($src, $dest, 0, 0);

-			if ($result < 0) {

-				$langs->load("errors");

-				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

-				return 0;

-			}

-		}

-

-		$sql = array(

-			array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket',  'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1);", "ignoreerror" => 1),

-			array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket',  'internal', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1),

-			array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket',  'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);", "ignoreerror" => 1),

-			array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket',  'external', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1),

-			"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'TICKET_ADDON_PDF_ODT_PATH' AND type = 'ticket' AND entity = ".((int) $conf->entity),

-			"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('TICKET_ADDON_PDF_ODT_PATH','ticket',".((int) $conf->entity).")"

-		);

-

-		return $this->_init($sql, $options);

-	}

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->langfiles = array("ticket");

+

+        // Constants

+        // List of particular constants to add when module is enabled

+        // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

+        // Example:

+        $this->const = array(

+            1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0),

+            2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0)

+        );

+

+        $this->tabs = array(

+            'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__',

+            'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__',

+        );

+

+        // Dictionaries

+        if (!isset($conf->ticket->enabled)) {

+            $conf->ticket = new stdClass();

+            $conf->ticket->enabled = 0;

+        }

+        $this->dictionaries = array(

+            'langs' => 'ticket',

+        	'tabname' => array(MAIN_DB_PREFIX."c_ticket_type", MAIN_DB_PREFIX."c_ticket_severity", MAIN_DB_PREFIX."c_ticket_category", MAIN_DB_PREFIX."c_ticket_resolution"),

+        	'tablib' => array("TicketDictType", "TicketDictSeverity", "TicketDictCategory", "TicketDictResolution"),

+        	'tabsql' => array(

+        		'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f',

+        		'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f',

+        		'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f',

+        		'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f'

+        	),

+        	'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"),

+        	'tabfield' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),

+        	'tabfieldvalue' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),

+        	'tabfieldinsert' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),

+            'tabrowid' => array("rowid", "rowid", "rowid", "rowid"),

+        	'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled),

+        	'tabhelp' => array(array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))),

+        );

+

+        // Boxes

+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.

+        $this->boxes = array(); // Boxes list

+        $r = 0;

+        // Example:

+

+        $this->boxes[$r][1] = "box_last_ticket";

+        $r++;

+

+        $this->boxes[$r][1] = "box_last_modified_ticket";

+        $r++;

+

+        // Permissions

+        $this->rights = array(); // Permission array used by this module

+

+        $r = 0;

+        $this->rights[$r][0] = 56001; // id de la permission

+        $this->rights[$r][1] = "Read ticket"; // libelle de la permission

+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

+        $this->rights[$r][4] = 'read';

+

+        $r++;

+        $this->rights[$r][0] = 56002; // id de la permission

+        $this->rights[$r][1] = "Create les tickets"; // libelle de la permission

+        $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)

+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

+        $this->rights[$r][4] = 'write';

+

+        $r++;

+        $this->rights[$r][0] = 56003; // id de la permission

+        $this->rights[$r][1] = "Delete les tickets"; // libelle de la permission

+        $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)

+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

+        $this->rights[$r][4] = 'delete';

+

+        $r++;

+        $this->rights[$r][0] = 56004; // id de la permission

+        $this->rights[$r][1] = "Manage tickets"; // libelle de la permission

+        //$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)

+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

+        $this->rights[$r][4] = 'manage';

+

+        $r++;

+        $this->rights[$r][0] = 56005; // id de la permission

+        $this->rights[$r][1] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)'; // libelle de la permission

+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

+        $this->rights[$r][4] = 'view';

+        $this->rights[$r][5] = 'all';

+

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

+

+        $this->menu[$r] = array('fk_menu' => 0, // Put 0 if this is a top menu

+            'type' => 'top', // This is a Top menu entry

+            'titre' => 'Ticket',

+            'mainmenu' => 'ticket',

+            'leftmenu' => '1', // Use 1 if you also want to add left menu entries using this descriptor.

+            'url' => '/ticket/index.php',

+            'langs' => 'ticket', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+            'position' => 88,

+            'enabled' => '$conf->ticket->enabled', // Define condition to show or hide menu entry. Use '$conf->ticket->enabled' if entry must be visible if module is enabled.

+            'perms' => '$user->rights->ticket->read', // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules

+            'target' => '',

+            'user' => 2); // 0=Menu for internal users, 1=external users, 2=both

+        $r++;

+

+        $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket',

+            'type' => 'left',

+            'titre' => 'Ticket',

+            'mainmenu' => 'ticket',

+            'leftmenu' => 'ticket',

+            'url' => '/ticket/index.php',

+            'langs' => 'ticket',

+            'position' => 101,

+            'enabled' => '$conf->ticket->enabled',

+            'perms' => '$user->rights->ticket->read',

+            'target' => '',

+            'user' => 2);

+        $r++;

+

+        $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

+            'type' => 'left',

+            'titre' => 'NewTicket',

+            'mainmenu' => 'ticket',

+            'url' => '/ticket/card.php?action=create',

+            'langs' => 'ticket',

+            'position' => 102,

+            'enabled' => '$conf->ticket->enabled',

+            'perms' => '$user->rights->ticket->write',

+            'target' => '',

+            'user' => 2);

+        $r++;

+

+        $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

+            'type' => 'left',

+            'titre' => 'List',

+            'mainmenu' => 'ticket',

+            'leftmenu' => 'ticketlist',

+            'url' => '/ticket/list.php?search_fk_status=non_closed',

+            'langs' => 'ticket',

+            'position' => 103,

+            'enabled' => '$conf->ticket->enabled',

+            'perms' => '$user->rights->ticket->read',

+            'target' => '',

+            'user' => 2);

+        $r++;

+

+        $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

+            'type' => 'left',

+            'titre' => 'MenuTicketMyAssign',

+            'mainmenu' => 'ticket',

+            'leftmenu' => 'ticketmy',

+            'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed',

+            'langs' => 'ticket',

+            'position' => 105,

+            'enabled' => '$conf->ticket->enabled',

+            'perms' => '$user->rights->ticket->read',

+            'target' => '',

+            'user' => 0);

+        $r++;

+

+        $this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',

+            'type' => 'left',

+            'titre' => 'Statistics',

+            'mainmenu' => 'ticket',

+            'url' => '/ticket/stats/index.php',

+            'langs' => 'ticket',

+            'position' => 107,

+            'enabled' => '$conf->ticket->enabled',

+            'perms' => '$user->rights->ticket->read',

+            'target' => '',

+            'user' => 0);

+        $r++;

+    }

+

+    /**

+     *	Function called when module is enabled.

+     *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *	It also creates data directories

+     *

+     *	@param      string	$options    Options when enabling module ('', 'noboxes')

+     *	@return     int             	1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+

+        $sql = array(

+            array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket',  'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1);", "ignoreerror" => 1),

+            array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket',  'internal', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1),

+            array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket',  'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);", "ignoreerror" => 1),

+            array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket',  'external', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1),

+        );

+

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modUser.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modUser.class.php
@@ -21,6 +21,5 @@
- *  \defgroup   user  Module user management

- *  \brief      Module to manage users and usergroups

- *

- *  \file       htdocs/core/modules/modUser.class.php

- *  \ingroup    user

- *  \brief      Description and activation file for the module users

+ *	\defgroup   user  Module user management

+ *	\brief      Module pour gerer les utilisateurs

+ *	\file       htdocs/core/modules/modUser.class.php

+ *	\ingroup    user

+ *	\brief      Fichier de description et activation du module Utilisateur

@@ -35,0 +35 @@
+

@@ -52 +52 @@
-		$this->description = "Management of users and groups of users (mandatory)";

+		$this->description = "Gestion des utilisateurs (requis)";

@@ -71 +71 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -80,3 +80,2 @@
-			0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'),

-			1=>array('file'=>'box_birthdays.php', 'enabledbydefaulton'=>'Home'),

-			2=>array('file'=>'box_dolibarr_state_board.php', 'enabledbydefaulton'=>'Home')

+		    0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'),

+            1=>array('file'=>'box_birthdays.php', 'enabledbydefaulton'=>'Home')

@@ -93 +92 @@
-		$this->rights[$r][1] = 'Read information of other users, groups and permissions';

+		$this->rights[$r][1] = 'Consulter les autres utilisateurs';

@@ -101,4 +100,4 @@
-		$this->rights[$r][1] = 'Read permissions of other users';

-		$this->rights[$r][2] = 'r';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'user_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

+		$this->rights[$r][1] = 'Consulter les permissions des autres utilisateurs';

+		$this->rights[$r][2] = 'r';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'user_advance';

@@ -109 +108 @@
-		$this->rights[$r][1] = 'Create/modify internal and external users, groups and permissions';

+		$this->rights[$r][1] = 'Creer/modifier utilisateurs internes et externes';

@@ -117,4 +116,4 @@
-		$this->rights[$r][1] = 'Create/modify external users only';

-		$this->rights[$r][2] = 'w';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'user_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on

+		$this->rights[$r][1] = 'Creer/modifier utilisateurs externes seulement';

+		$this->rights[$r][2] = 'w';

+		$this->rights[$r][3] = 0;

+		$this->rights[$r][4] = 'user_advance';

@@ -125 +124 @@
-		$this->rights[$r][1] = 'Modify the password of other users';

+		$this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs';

@@ -133 +132 @@
-		$this->rights[$r][1] = 'Delete or disable other users';

+		$this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs';

@@ -141 +140 @@
-		$this->rights[$r][1] = 'Read its own permissions';

+		$this->rights[$r][1] = 'Consulter ses propres permissions';

@@ -149 +148 @@
-		$this->rights[$r][1] = 'Create/modify of its own user';

+		$this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur';

@@ -157 +156 @@
-		$this->rights[$r][1] = 'Modify its own password';

+		$this->rights[$r][1] = 'Modifier son propre mot de passe';

@@ -165 +164 @@
-		$this->rights[$r][1] = 'Modify its own permissions';

+		$this->rights[$r][1] = 'Modifier ses propres permissions';

@@ -173 +172 @@
-		$this->rights[$r][1] = 'Read groups';

+		$this->rights[$r][1] = 'Consulter les groupes';

@@ -181 +180 @@
-		$this->rights[$r][1] = 'Read permissions of groups';

+		$this->rights[$r][1] = 'Consulter les permissions des groupes';

@@ -189 +188 @@
-		$this->rights[$r][1] = 'Create/modify groups and permissions';

+		$this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';

@@ -197 +196 @@
-		$this->rights[$r][1] = 'Delete groups';

+		$this->rights[$r][1] = 'Supprimer ou desactiver les groupes';

@@ -205 +204 @@
-		$this->rights[$r][1] = 'Export all users';

+		$this->rights[$r][1] = 'Exporter les utilisateurs';

@@ -212,2 +211,2 @@
-		// Menus

-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.

+        // Menus

+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.

@@ -224,9 +223,9 @@
-			'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender",

-			'u.accountancy_code'=>"UserAccountancyCode",

-			'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town",

-			'u.office_phone'=>'Phone', 'u.user_mobile'=>"Mobile", 'u.office_fax'=>'Fax',

-			'u.email'=>"Email", 'u.note_public'=>"NotePublic", 'u.note_private'=>"NotePrivate", 'u.signature'=>'Signature',

-			'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours',

-			'u.dateemployment'=>'DateEmploymentStart', 'u.dateemploymentend'=>'DateEmploymentEnd', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey',

-			'u.birth'=>'DateOfBirth',

-			'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification",

+		    'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender",

+		    'u.accountancy_code'=>"UserAccountancyCode",

+		    'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town",

+		    'u.office_phone'=>'Phone', 'u.user_mobile'=>"Mobile", 'u.office_fax'=>'Fax',

+		    'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature',

+		    'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours',

+		    'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey',

+		    'u.birth'=>'BirthdayDate',

+		    'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification",

@@ -234,5 +233 @@
-			'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany",

-			'u.fk_member'=>"MemberId",

-			"a.firstname"=>"MemberFirstname",

-			"a.lastname"=>"MemberLastname",

-			'g.nom'=>"Group"

+			'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId"

@@ -242,16 +237,7 @@
-			'u.accountancy_code'=>'Text',

-			'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text",

-			'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text',

-			'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note_public'=>"Text", 'u.note_private'=>"Text", 'u.signature'=>"Text", 'u.datelastlogin'=>'Date',

-			'u.fk_user'=>"FormSelect:select_dolusers",

-			'u.birth'=>'Date',

-			'u.datepreviouslogin'=>'Date',

-			'u.fk_socpeople'=>'FormSelect:selectcontacts',

-			'u.fk_soc'=>"FormSelect:select_company",

-			'u.tjm'=>"Numeric", 'u.thm'=>"Numeric", 'u.fk_member'=>"Numeric",

-			'u.weeklyhours'=>"Numeric",

-			'u.dateemployment'=>"Date", 'u.dateemploymentend'=>"Date", 'u.salary'=>"Numeric",

-			'u.color'=>'Text', 'u.api_key'=>'Text',

-			'a.firstname'=>'Text',

-			'a.lastname'=>'Text',

-			'g.nom'=>"Text"

+		    'u.accountancy_code'=>'Text',

+		    'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text",

+		    'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text',

+			'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date',

+		    'u.fk_user'=>"List:user:login",

+		    'u.birth'=>'Date',

+		    'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname"

@@ -261,21 +247,16 @@
-			'u.accountancy_code'=>'user',

-			'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user",

-			'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user',

-			'u.email'=>'user', 'u.note_public'=>"user", 'u.note_private'=>"user", 'u.signature'=>'user',

-			'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user',

-			'u.dateemployment'=>'user', 'u.dateemploymentend'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user',

-			'u.birth'=>'user',

-			'u.datec'=>"user", 'u.tms'=>"user",

-			'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user',

-			'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member",

-			'a.firstname'=>"member", 'a.lastname'=>"member",

-			'g.nom'=>"Group"

-		);

-		$keyforselect = 'user';

-		$keyforelement = 'user';

-		$keyforaliasextra = 'extra';

-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		if (!isModEnabled('adherent')) {

-			unset($this->export_fields_array[$r]['u.fk_member']);

-			unset($this->export_entities_array[$r]['u.fk_member']);

-		}

+		    'u.accountancy_code'=>'user',

+		    'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user",

+		    'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user',

+		    'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user',

+		    'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user',

+		    'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user',

+		    'u.birth'=>'user',

+		    'u.datec'=>"user", 'u.tms'=>"user",

+		    'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user',

+		    'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member"

+		);

+        if (empty($conf->adherent->enabled))

+        {

+            unset($this->export_fields_array[$r]['u.fk_member']);

+            unset($this->export_entities_array[$r]['u.fk_member']);

+        }

@@ -284,4 +264,0 @@
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON u.rowid = extra.fk_object';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'usergroup_user as ug ON u.rowid = ug.fk_user';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'usergroup as g ON ug.fk_usergroup = g.rowid';

-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent as a ON u.fk_member = a.rowid';

@@ -301,2 +278,2 @@
-			'u.login'=>"Login*", 'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender",

-			'u.accountancy_code'=>"UserAccountancyCode",

+		    'u.login'=>"Login*", 'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender",

+		    'u.accountancy_code'=>"UserAccountancyCode",

@@ -305,7 +282,7 @@
-			'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax",

-			'u.email'=>"Email", 'u.note_public'=>"NotePublic", 'u.note_private'=>"NotePrivate", 'u.signature'=>'Signature',

-			'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours',

-			'u.dateemployment'=>'DateEmploymentStart', 'u.dateemploymentend'=>'DateEmploymentEnd', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey',

-			'u.birth'=>'DateOfBirth',

-			'u.datec'=>"DateCreation",

-			'u.statut'=>'Status'

+		    'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax",

+		    'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature',

+		    'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours',

+			'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey',

+		    'u.birth'=>'BirthdayDate',

+		    'u.datec'=>"DateCreation",

+		    'u.statut'=>'Status'

@@ -314 +291 @@
-		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.")";

+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";

@@ -316,6 +293,8 @@
-		if ($resql) {    // This can fail when class is used on old database (during migration for example)

-			while ($obj = $this->db->fetch_object($resql)) {

-				$fieldname = 'extra.'.$obj->name;

-				$fieldlabel = ucfirst($obj->label);

-				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

-			}

+		if ($resql)    // This can fail when class is used on old database (during migration for example)

+		{

+		    while ($obj = $this->db->fetch_object($resql))

+		    {

+		        $fieldname = 'extra.'.$obj->name;

+		        $fieldlabel = ucfirst($obj->label);

+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');

+		    }

@@ -327,2 +306,2 @@
-			'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'),

-			'u.salary'=>array('rule'=>'numeric')

+		    'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'),

+		    'u.salary'=>array('rule'=>'numeric')

@@ -334,2 +313,2 @@
-			'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

-			'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'

+            'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',

+            'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'

@@ -338 +317 @@
-			'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'man or woman',

+			'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'0 or 1',

@@ -340 +319 @@
-			'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.address'=>"61 jump street",

+			'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 'u.address'=>"61 jump street",

@@ -342,2 +321,2 @@
-			'u.email'=>"test@mycompany.com", 'u.salary'=>"10000", 'u.note_public'=>"This is an example of public note for record", 'u.note_private'=>"This is an example of private note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00",

-			'u.statut'=>"0 (closed) or 1 (active)",

+			'u.email'=>"test@mycompany.com", 'u.salary'=>"10000", 'u.note'=>"This is an example of note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00",

+		    'u.statut'=>"0 (closed) or 1 (active)",

@@ -349 +328 @@
-	/**

+    /**

@@ -354 +333 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -356,3 +335,3 @@
-	 */

-	public function init($options = '')

-	{

+     */

+    public function init($options = '')

+    {

@@ -367 +346 @@
-	}

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modVariants.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modVariants.class.php
@@ -1,0 +2 @@
+

@@ -26 +26,0 @@
- *  \brief      Description and activation file for the module product variants

@@ -75 +75 @@
-		// Example: this->dirs = array("/variants/temp");

+		// Example: this->dirs = array("/mymodule/temp");

@@ -78 +78 @@
-		// Config pages. Put here list of php page, stored into variants/admin directory, to use to setup module.

+		// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.

@@ -86 +86 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

@@ -95 +95 @@
-		//	'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'

+        //	'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'

@@ -99,3 +99,4 @@
-		if (!isset($conf->variants->enabled)) {

-			$conf->variants = new stdClass();

-			$conf->variants->enabled = 0;

+		if (!isset($conf->mymodule->enabled))

+		{

+			$conf->mymodule = new stdClass();

+			$conf->mymodule->enabled = 0;

@@ -111,14 +111,0 @@
-		$r = 0;

-

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Read attributes of variants'; // Permission label

-		$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)

-		$r++;

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Create/Update attributes of variants'; // Permission label

-		$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)

-		$r++;

-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

-		$this->rights[$r][1] = 'Delete attributes of variants'; // Permission label

-		$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)

-		$r++;

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modWebServices.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWebServices.class.php
@@ -23 +23 @@
- *       \brief      Description and activation file for the module webservices

+ *       \brief      File to describe webservices module

@@ -32 +32,2 @@
-	/**

+

+    /**

@@ -36,5 +37,5 @@
-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-		$this->numero = 2600;

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+        $this->numero = 2600;

@@ -42,11 +43,11 @@
-		$this->family = "interface";

-		$this->module_position = '25';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable the Dolibarr web services server";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'

-		$this->version = 'dolibarr_deprecated';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'technic';

+        $this->family = "interface";

+        $this->module_position = '25';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable the Dolibarr web services server";

+		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'technic';

@@ -54,2 +55,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -57,2 +58,2 @@
-		// Config pages

-		$this->config_page_url = array("index.php@webservices");

+        // Config pages

+        $this->config_page_url = array("index.php@webservices");

@@ -60,2 +61,2 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -65,2 +66,2 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->langfiles = array("other");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->langfiles = array("other");

@@ -68,2 +69,2 @@
-		// Constants

-		$this->const = array();

+        // Constants

+        $this->const = array();

@@ -71,2 +72,2 @@
-		// New pages on tabs

-		$this->tabs = array();

+        // New pages on tabs

+        $this->tabs = array();

@@ -74,2 +75,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -77,5 +78,5 @@
-		// Permissions

-		$this->rights = array();

-		$this->rights_class = 'webservices';

-		$r = 0;

-	}

+        // Permissions

+        $this->rights = array();

+        $this->rights_class = 'webservices';

+        $r = 0;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modWebServicesClient.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWebServicesClient.class.php
@@ -23 +23 @@
- *       \brief      Description and activation file for the module supplier webservices module

+ *       \brief      File to describe client for supplier webservices module

@@ -32 +32,2 @@
-	/**

+

+    /**

@@ -36,5 +37,5 @@
-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

-		$this->numero = 2660;

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

+        $this->numero = 2660;

@@ -42,5 +43,5 @@
-		$this->family = "interface";

-		$this->module_position = '25';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable the web service client to call external supplier web services";

+        $this->family = "interface";

+        $this->module_position = '26';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable the web service client to call external supplier web services";

@@ -48,5 +49,5 @@
-		$this->version = 'experimental_deprecated';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'technic';

+        $this->version = 'experimental';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'technic';

@@ -54,2 +55,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array();

+        // Data directories to create when module is enabled

+        $this->dirs = array();

@@ -57,2 +58,2 @@
-		// Config pages

-		//$this->config_page_url = array();

+        // Config pages

+        //$this->config_page_url = array();

@@ -60,2 +61,2 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -65,2 +66,2 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->langfiles = array("other");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->langfiles = array("other");

@@ -68,2 +69,2 @@
-		// Constants

-		$this->const = array();

+        // Constants

+        $this->const = array();

@@ -71,2 +72,2 @@
-		// New pages on tabs

-		$this->tabs = array();

+        // New pages on tabs

+        $this->tabs = array();

@@ -74,2 +75,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -77,5 +78,5 @@
-		// Permissions

-		$this->rights = array();

-		$this->rights_class = 'syncsupplierwebservices';

-		$r = 0;

-	}

+        // Permissions

+        $this->rights = array();

+        $this->rights_class = 'syncsupplierwebservices';

+        $r = 0;

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modWebsite.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWebsite.class.php
@@ -23 +23 @@
- *  \brief      Description and activation file for the module Website

+ *  \brief      Description and activation file for module Website

@@ -33 +33,2 @@
-	/**

+

+    /**

@@ -37,7 +38,7 @@
-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

-

-		$this->db = $db;

-		$this->numero = 10000;

+     */

+    public function __construct($db)

+    {

+    	global $langs, $conf;

+

+        $this->db = $db;

+        $this->numero = 10000;

@@ -47,5 +48,5 @@
-		$this->family = "portal";

-		$this->module_position = '50';

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		$this->description = "Enable to build and serve public web sites with CMS features";

+        $this->family = "portal";

+        $this->module_position = '50';

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        $this->description = "Enable to build and serve public web sites with CMS features";

@@ -53,5 +54,5 @@
-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		$this->picto = 'website';

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        $this->picto = 'website';

@@ -62,5 +63,5 @@
-		// Config pages

-		$this->config_page_url = array('website.php');

-

-		// Dependencies

-		$this->hidden = getDolGlobalString('MODULE_WEBSITE_DISABLED'); // A condition to disable module

+        // Config pages

+        $this->config_page_url = array('website.php');

+

+        // Dependencies

+		$this->hidden = !empty($conf->global->MODULE_WEBSITE_DISABLED); // A condition to disable module

@@ -68 +69 @@
-		$this->requiredby = array(); // List of modules id to disable if this one is disabled

+        $this->requiredby = array(); // List of modules id to disable if this one is disabled

@@ -70,11 +71,11 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->langfiles = array("website");

-

-		// Constants

-		$this->const = array();

-

-		// New pages on tabs

-		//$this->tabs[] = array();  					// To add a new tab identified by code tabname1

-

-		// Boxes

-		$this->boxes = array();

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->langfiles = array("website");

+

+        // Constants

+       	$this->const = array();

+

+        // New pages on tabs

+       	//$this->tabs[] = array();  					// To add a new tab identified by code tabname1

+

+        // Boxes

+        $this->boxes = array();

@@ -111,135 +112,91 @@
-		$this->rights[$r][0] = 10008;

-		$this->rights[$r][1] = 'Export website content';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'export';

-		$r++;

-

-		// Main menu entries

-		$r = 0;

-		$this->menu[$r] = array('fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

-								'type'=>'top', // This is a Left menu entry

-								'titre'=>'WebSites',

-								'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth em092"'),

-								'mainmenu'=>'website',

-								'url'=>'/website/index.php',

-								'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

-								'position'=>100,

-								'enabled'=>'$conf->website->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

-								'perms'=>'$user->rights->website->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

-								'target'=>'',

-								'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

-		$r++;

-

-		// Exports

-		$r = 1;

-

-		$this->export_code[$r] = $this->rights_class.'_'.$r;

-		$this->export_label[$r] = 'MyWebsitePages'; // Translation key (used only if key ExportDataset_xxx_z not found)

-		$this->export_permission[$r] = array(array("website", "export"));

-		$this->export_icon[$r] = 'globe';

-		$keyforclass = 'WebsitePage';

-		$keyforclassfile = '/website/class/websitepage.class.php';

-		$keyforelement = 'Website';

-		include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';

-		//$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra';

-		//include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';

-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'website_page as t, '.MAIN_DB_PREFIX.'website as p';

-		$this->export_sql_end[$r] .= ' WHERE t.fk_website = p.rowid';

-		$this->export_sql_end[$r] .= ' AND p.entity IN ('.getEntity('website').')';

-		$r++;

-	}

-

-

-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories

-	 *

-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int                 1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		global $conf, $langs;

-

-		$error = 0;

-

-		$result = $this->_load_tables('/install/mysql/', 'website');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Remove permissions and default values

-		$this->remove($options);

-

-		// Copy flags and octicons directory

-		$dirarray = array('common/flags'=>'flags', 'common/octicons/build/svg'=>'octicons');

-		foreach ($dirarray as $dirfrom => $dirtarget) {

-			$src = DOL_DOCUMENT_ROOT.'/theme/'.$dirfrom;

-			$dest = DOL_DATA_ROOT.'/medias/image/'.$dirtarget;

-

-			if (is_dir($src)) {

-				require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

-				dol_mkdir($dest);

-				$result = dolCopyDir($src, $dest, 0, 0);

-				if ($result < 0) {

-					$langs->load("errors");

-					$this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest);

-					$this->errors[] = $langs->trans('ErrorFailToCopyDir', $src, $dest);

-					$error++;

-				}

-			}

-		}

-

-		if ($error) {

-			return 0;

-		}

-

-		// Website templates

-		$srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';

-		$destroot = DOL_DATA_ROOT.'/doctemplates/websites';

-

-		dol_mkdir($destroot);

-

-		// Copy templates in zip format (old)

-		$docs = dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$');

-		foreach ($docs as $cursorfile) {

-			$src = $srcroot.'/'.$cursorfile['name'];

-			$dest = $destroot.'/'.$cursorfile['name'];

-

-			$result = dol_copy($src, $dest, 0, 1); // For full zip templates, we overwrite old existing files

-			if ($result < 0) {

-				$langs->load("errors");

-				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

-				$this->errors[] = $langs->trans('ErrorFailToCopyFile', $src, $dest);

-				$error++;

-			}

-		}

-

-		// Copy templates in dir format (recommended)

-		$docs = dol_dir_list($srcroot, 'directories', 0, 'website_.*$');

-

-		foreach ($docs as $cursorfile) {

-			$src = $srcroot.'/'.$cursorfile['name'];

-			$dest = $destroot.'/'.$cursorfile['name'];

-

-			// Compress it

-			global $errormsg;

-			$errormsg = '';

-			$result = dol_compress_dir($src, $dest.'.zip', 'zip');

-			if ($result < 0) {

-				$error++;

-				$this->error = ($errormsg ? $errormsg : $langs->trans('ErrorFailToCreateZip', $dest));

-				$this->errors[] = ($errormsg ? $errormsg : $langs->trans('ErrorFailToCreateZip', $dest));

-			}

-		}

-

-		if ($error) {

-			return 0;

-		}

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

+        // Main menu entries

+        $r = 0;

+        $this->menu[$r] = array('fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+						        'type'=>'top', // This is a Left menu entry

+						        'titre'=>'WebSites',

+                                'mainmenu'=>'website',

+						        'url'=>'/website/index.php',

+						        'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+						        'position'=>100,

+						        'enabled'=>'$conf->website->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+						        'perms'=>'$user->rights->website->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules

+						        'target'=>'',

+						        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

+        $r++;

+

+        // Exports

+        $r = 1;

+

+        $this->export_code[$r] = $this->rights_class.'_'.$r;

+        $this->export_label[$r] = 'MyWebsitePages'; // Translation key (used only if key ExportDataset_xxx_z not found)

+        $this->export_icon[$r] = 'globe';

+        $keyforclass = 'WebsitePage'; $keyforclassfile = '/website/class/websitepage.class.php'; $keyforelement = 'Website';

+        include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';

+        //$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra';

+        //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';

+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';

+        $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'website_page as t, '.MAIN_DB_PREFIX.'website as p';

+        $this->export_sql_end[$r] .= ' WHERE t.fk_website = p.rowid';

+        $this->export_sql_end[$r] .= ' AND p.entity IN ('.getEntity('website').')';

+        $r++;

+    }

+

+

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int                 1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+    	global $conf, $langs;

+

+    	// Remove permissions and default values

+    	$this->remove($options);

+

+    	// Copy flags and octicons directory

+    	$dirarray = array('common/flags'=>'flags', 'common/octicons/build/svg'=>'octicons');

+    	foreach ($dirarray as $dirfrom => $dirtarget)

+    	{

+	    	$src = DOL_DOCUMENT_ROOT.'/theme/'.$dirfrom;

+	    	$dest = DOL_DATA_ROOT.'/medias/image/'.$dirtarget;

+

+	    	if (is_dir($src))

+	    	{

+	    		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+	    		dol_mkdir($dest);

+	    		$result = dolCopyDir($src, $dest, 0, 0);

+	    		if ($result < 0)

+	    		{

+	    			$langs->load("errors");

+	    			$this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest);

+	    			return 0;

+	    		}

+	    	}

+    	}

+

+    	// Website templates

+    	$srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';

+    	$destroot = DOL_DATA_ROOT.'/doctemplates/websites';

+

+    	dol_mkdir($destroot);

+

+    	$docs = dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$');

+    	foreach ($docs as $cursorfile) {

+	    	$src = $srcroot.'/'.$cursorfile['name'];

+	    	$dest = $destroot.'/'.$cursorfile['name'];

+

+	    	$result = dol_copy($src, $dest, 0, 1); // For full zip templates, we overwrite old existing files

+	    	if ($result < 0) {

+	    		$langs->load("errors");

+	    		$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);

+	    	}

+    	}

+

+    	$sql = array();

+

+    	return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modWorkflow.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modWorkflow.class.php
@@ -24 +24 @@
- *      \brief      Description and activation file for the module Workflow

+ *      \brief      File to describe and activate module Workflow

@@ -34 +34,2 @@
-	/**

+

+    /**

@@ -38,4 +39,4 @@
-	 */

-	public function __construct($db)

-	{

-		$this->db = $db;

+     */

+    public function __construct($db)

+    {

+        $this->db = $db;

@@ -43,5 +44,5 @@
-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 6000;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'workflow';

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 6000;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'workflow';

@@ -49,13 +50,13 @@
-		$this->family = "technic";

-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

-		$this->description = "Inter-modules workflow management";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version

-		$this->version = 'dolibarr';

-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of png file (without png) used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'technic';

+        $this->family = "technic";

+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+        $this->description = "Workflow management";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version

+        $this->version = 'dolibarr';

+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of png file (without png) used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'technic';

@@ -63,2 +64,2 @@
-		// Data directories to create when module is enabled

-		$this->dirs = array("/workflow/temp");

+        // Data directories to create when module is enabled

+        $this->dirs = array("/workflow/temp");

@@ -66,2 +67,2 @@
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.

-		$this->config_page_url = array('workflow.php');

+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.

+        $this->config_page_url = array('workflow.php');

@@ -69,2 +70,2 @@
-		// Dependencies

-		$this->hidden = false; // A condition to hide module

+        // Dependencies

+        $this->hidden = false; // A condition to hide module

@@ -74,3 +75,3 @@
-		$this->phpmin = array(7, 0); // Minimum version of PHP required by module

-		$this->need_dolibarr_version = array(2, 8); // Minimum version of Dolibarr required by module

-		$this->langfiles = array("@workflow");

+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module

+        $this->need_dolibarr_version = array(2, 8); // Minimum version of Dolibarr required by module

+        $this->langfiles = array("@workflow");

@@ -78,21 +79,16 @@
-		// Constants

-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

-		// Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),

-		//                             2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)

-		// );

-		$this->const = array(

-			//0=>array('WORKFLOW_PROPAL_AUTOCREATE_ORDER', 'chaine', '1', 'WORKFLOW_PROPAL_AUTOCREATE_ORDER', 0, 'current', 0),

-			//0=>array('WORKFLOW_ORDER_AUTOCREATE_INVOICE', 'chaine', '1', 'WORKFLOW_ORDER_AUTOCREATE_INVOICE', 0, 'current', 0),

-			0=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 0, 'current', 0),

-			1=>array('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 0, 'current', 0),

-			2=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 0, 'current', 0),

-			3=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED', 0, 'current', 0),

-			4=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0),

-			5=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 0, 'current', 0),

-			6=>array('WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION', 0, 'current', 0),

-			7=>array('WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED', 0, 'current', 0),

-			8=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0),

-			10=>array('WORKFLOW_TICKET_LINK_CONTRACT', 'chaine', '0', 'Automatically link a ticket to available contracts', 0, 'current', 0),

-			11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0),

-			12=>array('WORKFLOW_TICKET_CREATE_INTERVENTION', 'chaine', '0', 'WORKFLOW_TICKET_CREATE_INTERVENTION', 0, 'current', 0)

-		);

+        // Constants

+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

+        // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),

+        //                             2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)

+        // );

+        $this->const = array(

+            //0=>array('WORKFLOW_PROPAL_AUTOCREATE_ORDER', 'chaine', '1', 'WORKFLOW_PROPAL_AUTOCREATE_ORDER', 0, 'current', 0),

+            //0=>array('WORKFLOW_ORDER_AUTOCREATE_INVOICE', 'chaine', '1', 'WORKFLOW_ORDER_AUTOCREATE_INVOICE', 0, 'current', 0),

+            0=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 0, 'current', 0),

+            1=>array('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 0, 'current', 0),

+            2=>array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 0, 'current', 0),

+            4=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0),

+            5=>array('WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 0, 'current', 0),

+            6=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0),

+            7=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0)

+        );

@@ -100,2 +96,2 @@
-		// Boxes

-		$this->boxes = array();

+        // Boxes

+        $this->boxes = array();

@@ -103,3 +99,3 @@
-		// Permissions

-		$this->rights = array();

-		$r = 0;

+        // Permissions

+        $this->rights = array();

+        $r = 0;

@@ -107,8 +103,8 @@
-		/*

-		$r++;

-		$this->rights[$r][0] = 6001; // id de la permission

-		$this->rights[$r][1] = "Lire les workflow"; // libelle de la permission

-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

-		$this->rights[$r][4] = 'read';

-		*/

+        /*

+        $r++;

+        $this->rights[$r][0] = 6001; // id de la permission

+        $this->rights[$r][1] = "Lire les workflow"; // libelle de la permission

+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)

+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut

+        $this->rights[$r][4] = 'read';

+        */

@@ -116,16 +112,16 @@
-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

-		/*

-		$this->menu[$r]=array('fk_menu'=>0,

-								'type'=>'top',

-								'titre'=>'Workflow',

-								'mainmenu'=>'workflow',

-								'url'=>'/workflow/index.php',

-								'langs'=>'@workflow',

-								'position'=>100,

-								'perms'=>'$user->rights->workflow->read',

-								'enabled'=>'$conf->workflow->enabled',

-								'target'=>'',

-								'user'=>0);

-		$r++;

+        // Main menu entries

+        $this->menus = array(); // List of menus to add

+        $r = 0;

+        /*

+        $this->menu[$r]=array('fk_menu'=>0,

+                                'type'=>'top',

+                                'titre'=>'Workflow',

+                                'mainmenu'=>'workflow',

+                                'url'=>'/workflow/index.php',

+                                'langs'=>'@workflow',

+                                'position'=>100,

+                                'perms'=>'$user->rights->workflow->read',

+                                'enabled'=>'$conf->workflow->enabled',

+                                'target'=>'',

+                                'user'=>0);

+        $r++;

@@ -133,14 +129,14 @@
-		$this->menu[$r]=array(  'fk_menu'=>'r=0',

-								'type'=>'left',

-								'titre'=>'Workflow',

-								'mainmenu'=>'workflow',

-								'url'=>'/workflow/index.php',

-								'langs'=>'@workflow',

-								'position'=>101,

-								'enabled'=>1,

-								'perms'=>'$user->rights->workflow->read',

-								'target'=>'',

-								'user'=>0);

-		$r++;

-		*/

-	}

+        $this->menu[$r]=array(  'fk_menu'=>'r=0',

+                                'type'=>'left',

+                                'titre'=>'Workflow',

+                                'mainmenu'=>'workflow',

+                                'url'=>'/workflow/index.php',

+                                'langs'=>'@workflow',

+                                'position'=>101,

+                                'enabled'=>1,

+                                'perms'=>'$user->rights->workflow->read',

+                                'target'=>'',

+                                'user'=>0);

+        $r++;

+        */

+    }

@@ -149 +145 @@
-	/**

+    /**

@@ -154 +150 @@
-	 *      @param      string	$options    Options when enabling module ('', 'noboxes')

+     *      @param      string	$options    Options when enabling module ('', 'noboxes')

@@ -156,3 +152,3 @@
-	 */

-	public function init($options = '')

-	{

+     */

+    public function init($options = '')

+    {

@@ -164,2 +160,2 @@
-		return $this->_init($sql, $options);

-	}

+        return $this->_init($sql, $options);

+    }

--- /tmp/dsg/dolibarr/htdocs/core/modules/github_19.0.3_modZapier.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/client_modZapier.class.php
@@ -16 +16 @@
- * along with this program. If not, see <https://www.gnu.org/licenses/>.

+ * along with this program. If not, see <http://www.gnu.org/licenses/>.

@@ -18 +17,0 @@
-

@@ -25 +24 @@
- *  \brief      Description and activation file for the module Zapier

+ *  \brief      Description and activation file for module Zapier

@@ -27,2 +26 @@
-

-require_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';

+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';

@@ -35,262 +33,326 @@
-	/**

-	 * Constructor. Define names, constants, directories, boxes, permissions

-	 *

-	 * @param DoliDB $db Database handler

-	 */

-	public function __construct($db)

-	{

-		global $langs, $conf;

-

-		$this->db = $db;

-		// Id for module (must be unique).

-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

-		$this->numero = 50330;

-		// Key text used to identify module (for permissions, menus, etc...)

-		$this->rights_class = 'zapier';

-		// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'

-		// It is used to group modules by family in module setup page

-		$this->family = "interface";

-		// Module position in the family on 2 digits ('01', '10', '20', ...)

-		$this->module_position = '26';

-		// Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)

-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));

-		// Module label (no space allowed), used if translation string 'ModuleZapierName' not found (Zapier is name of module).

-		$this->name = preg_replace('/^mod/i', '', get_class($this));

-		// Module description, used if translation string 'ModuleZapierDesc' not found (Zapier is name of module).

-		$this->description = "ZapierDescription";

-		// Used only if file README.md and README-LL.md not found.

-		$this->descriptionlong = "Zapier description (Long)";

-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'

-		$this->version = 'development';

-		//Url to the file with your last numberversion of this module

-		//$this->url_last_version = 'http://www.example.com/versionmodule.txt';

-		// Key used in llx_const table to save module status enabled/disabled (where ZAPIERFORDOLIBARR is value of property name of module in uppercase)

-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

-		// Name of image file used for this module.

-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

-		$this->picto = 'zapier';

-		// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)

-		$this->module_parts = array(

-			// Set this to 1 if module has its own trigger directory (core/triggers)

-			'triggers' => 1,

-			// Set this to 1 if module has its own login method file (core/login)

-			'login' => 0,

-			// Set this to 1 if module has its own substitution function file (core/substitutions)

-			'substitutions' => 0,

-			// Set this to 1 if module has its own menus handler directory (core/menus)

-			'menus' => 0,

-			// Set this to 1 if module overwrite template dir (core/tpl)

-			'tpl' => 0,

-			// Set this to 1 if module has its own barcode directory (core/modules/barcode)

-			'barcode' => 0,

-			// Set this to 1 if module has its own models directory (core/modules/xxx)

-			'models' => 0,

-			// Set this to 1 if module has its own theme directory (theme)

-			'theme' => 0,

-			// Set this to relative path of css file if module has its own css file

-			'css' => array(

-				//    '/zapier/css/zapier.css.php',

-			),

-			// Set this to relative path of js file if module must load a js on all pages

-			'js' => array(

-				//   '/zapier/js/zapier.js.php',

-			),

-			// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'

-			'hooks' => array(

-				//   'data' => array(

-				//       'hookcontext1',

-				//       'hookcontext2',

-				//   ),

-				//   'entity' => '0',

-			),

-			// Set this to 1 if feature of module are opened to external users

-			'moduleforexternal' => 0,

-		);

-		// Data directories to create when module is enabled.

-		// Example: this->dirs = array("/zapier/temp","/zapier/subdir");

-		$this->dirs = array("/zapier/temp");

-		// Config pages. Put here list of php page, stored into zapier/admin directory, to use to setup module.

-		$this->config_page_url = array(

-			"setup.php@zapier"

-		);

-		// Dependencies

-		// A condition to hide module

-		$this->hidden = false;

-		// List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))

-		$this->depends = array('modApi');

-		// List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)

-		$this->requiredby = array();

-		// List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

-		$this->conflictwith = array();

-		$this->langfiles = array("zapier");

-		// Minimum version of PHP required by module

-		//$this->phpmin = array(7, 0);

-		// Minimum version of Dolibarr required by module

-		$this->need_dolibarr_version = array(10, 0);

-		// Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		$this->warnings_activation = array();

-		// Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

-		$this->warnings_activation_ext = array();

-		// $this->automatic_activation = array(

-		//     'FR'=>'ZapierWasAutomaticallyActivatedBecauseOfYourCountryChoice',

-		// );

-		// If true, can't be disabled

-		// $this->always_enabled = true;

-		// Constants

-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

-		// Example: $this->const=array(

-		//    1 => array('ZAPIERFORDOLIBARR_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),

-		//    2 => array('ZAPIERFORDOLIBARR_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)

-		// );

-		$this->const = array(

-			// 1 => array('ZAPIERFORDOLIBARR_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)

-		);

-		// Some keys to add into the overwriting translation tables

-		/*$this->overwrite_translation = array(

-			'en_US:ParentCompany'=>'Parent company or reseller',

-			'fr_FR:ParentCompany'=>'Maison mère ou revendeur'

-		)*/

-		if (!isset($conf->zapier) || !isset($conf->zapier->enabled)) {

-			$conf->zapier = new stdClass();

-			$conf->zapier->enabled = 0;

-		}

-		// Array to add new pages in new tabs

-		$this->tabs = array();

-		// Example:

-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@zapier:$user->rights->zapier->read:/zapier/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

-		// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@zapier:$user->rights->othermodule->read:/zapier/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

-		// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

-		//

-		// Where objecttype can be

-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

-		// 'contact'          to add a tab in contact view

-		// 'contract'         to add a tab in contract view

-		// 'group'            to add a tab in group view

-		// 'intervention'     to add a tab in intervention view

-		// 'invoice'          to add a tab in customer invoice view

-		// 'invoice_supplier' to add a tab in supplier invoice view

-		// 'member'           to add a tab in fundation member view

-		// 'opensurveypoll'	  to add a tab in opensurvey poll view

-		// 'order'            to add a tab in sales order view

-		// 'order_supplier'   to add a tab in supplier order view

-		// 'payment'		  to add a tab in payment view

-		// 'payment_supplier' to add a tab in supplier payment view

-		// 'product'          to add a tab in product view

-		// 'propal'           to add a tab in propal view

-		// 'project'          to add a tab in project view

-		// 'stock'            to add a tab in stock view

-		// 'thirdparty'       to add a tab in third party view

-		// 'user'             to add a tab in user view

-

-		// Dictionaries

-		$this->dictionaries = array();

-

-		// Boxes/Widgets

-		// Add here list of php file(s) stored in zapier/core/boxes that contains class to show a widget.

-		$this->boxes = array(

-			//  0 => array(

-			//      'file' => 'zapierwidget1.php@zapier',

-			//      'note' => 'Widget provided by Zapier',

-			//      'enabledbydefaulton' => 'Home',

-			//  ),

-			//1=>array('file'=>'zapierwidget2.php@zapier','note'=>'Widget provided by Zapier'),

-			//2=>array('file'=>'zapierwidget3.php@zapier','note'=>'Widget provided by Zapier')

-		);

-		// Cronjobs (List of cron jobs entries to add when module is enabled)

-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

-		$this->cronjobs = array(

-			//  0 => array(

-			//      'label' => 'MyJob label',

-			//      'jobtype' => 'method',

-			//      'class' => '/zapier/class/myobject.class.php',

-			//      'objectname' => 'MyObject',

-			//      'method' => 'doScheduledJob',

-			//      'parameters' => '',

-			//      'comment' => 'Comment',

-			//      'frequency' => 2,

-			//      'unitfrequency' => 3600,

-			//      'status' => 0,

-			//      'test' => '$conf->zapier->enabled',

-			//      'priority' => 50,

-			//  ),

-		);

-		// Example: $this->cronjobs=array(

-		//    0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50),

-		//    1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50)

-		// );

-		// Permissions

-		// Permission array used by this module

-		$this->rights = array();

-

-		$r = 1;

-		// Permission id (must not be already used)

-		$this->rights[$r][0] = $this->numero + $r;

-		// Permission label

-		$this->rights[$r][1] = 'Read myobject of Zapier';

-		// Permission by default for new user (0/1)

-		$this->rights[$r][3] = 0;

-		// In php code, permission will be checked by test if ($user->rights->zapier->level1->level2)

-		$this->rights[$r][4] = 'read';

-		// In php code, permission will be checked by test if ($user->rights->zapier->level1->level2)

-		$this->rights[$r][5] = '';

-		$r++;

-		$this->rights[$r][0] = $this->numero + $r;

-		$this->rights[$r][1] = 'Create/Update myobject of Zapier';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'write';

-		$this->rights[$r][5] = '';

-		$r++;

-		$this->rights[$r][0] = $this->numero + $r;

-		$this->rights[$r][1] = 'Delete myobject of Zapier';

-		$this->rights[$r][3] = 0;

-		$this->rights[$r][4] = 'delete';

-		$this->rights[$r][5] = '';

-

-		// Main menu entries

-		$this->menu = array(); // List of menus to add

-		$r = 0;

-	}

-

-	/**

-	 *  Function called when module is enabled.

-	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

-	 *  It also creates data directories

-	 *

-	 *  @param      string  $options    Options when enabling module ('', 'noboxes')

-	 *  @return     int                 1 if OK, 0 if KO

-	 */

-	public function init($options = '')

-	{

-		$result = $this->_load_tables('/install/mysql/', 'zapier');

-		if ($result < 0) {

-			return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

-		}

-

-		// Create extrafields

-		//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

-		//$extrafields = new ExtraFields($this->db);

-		//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

-		//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

-		//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

-		//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

-		//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

-

-		$sql = array();

-

-		return $this->_init($sql, $options);

-	}

-

-	/**

-	 *  Function called when module is disabled.

-	 *  Remove from database constants, boxes and permissions from Dolibarr database.

-	 *  Data directories are not deleted

-	 *

-	 *  @param      string	$options    Options when enabling module ('', 'noboxes')

-	 *  @return     int                 1 if OK, 0 if KO

-	 */

-	public function remove($options = '')

-	{

-		$sql = array();

-		return $this->_remove($sql, $options);

-	}

+    /**

+     * Constructor. Define names, constants, directories, boxes, permissions

+     *

+     * @param DoliDB $db Database handler

+     */

+    public function __construct($db)

+    {

+        global $langs, $conf;

+

+        $this->db = $db;

+        // Id for module (must be unique).

+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).

+        $this->numero = 50330;

+        // Key text used to identify module (for permissions, menus, etc...)

+        $this->rights_class = 'zapier';

+        // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'

+        // It is used to group modules by family in module setup page

+        $this->family = "interface";

+        // Module position in the family on 2 digits ('01', '10', '20', ...)

+        $this->module_position = '22';

+        // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)

+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));

+        // Module label (no space allowed), used if translation string 'ModuleZapierName' not found (Zapier is name of module).

+        $this->name = preg_replace('/^mod/i', '', get_class($this));

+        // Module description, used if translation string 'ModuleZapierDesc' not found (Zapier is name of module).

+        $this->description = "ZapierDescription";

+        // Used only if file README.md and README-LL.md not found.

+        $this->descriptionlong = "Zapier description (Long)";

+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'

+        $this->version = 'development';

+        //Url to the file with your last numberversion of this module

+        //$this->url_last_version = 'http://www.example.com/versionmodule.txt';

+        // Key used in llx_const table to save module status enabled/disabled (where ZAPIERFORDOLIBARR is value of property name of module in uppercase)

+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

+        // Name of image file used for this module.

+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'

+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'

+        $this->picto = 'zapier';

+        // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)

+        $this->module_parts = array(

+            // Set this to 1 if module has its own trigger directory (core/triggers)

+            'triggers' => 1,

+            // Set this to 1 if module has its own login method file (core/login)

+            'login' => 0,

+            // Set this to 1 if module has its own substitution function file (core/substitutions)

+            'substitutions' => 0,

+            // Set this to 1 if module has its own menus handler directory (core/menus)

+            'menus' => 0,

+            // Set this to 1 if module overwrite template dir (core/tpl)

+            'tpl' => 0,

+            // Set this to 1 if module has its own barcode directory (core/modules/barcode)

+            'barcode' => 0,

+            // Set this to 1 if module has its own models directory (core/modules/xxx)

+            'models' => 0,

+            // Set this to 1 if module has its own theme directory (theme)

+            'theme' => 0,

+            // Set this to relative path of css file if module has its own css file

+            'css' => array(

+                //    '/zapier/css/zapier.css.php',

+            ),

+            // Set this to relative path of js file if module must load a js on all pages

+            'js' => array(

+                //   '/zapier/js/zapier.js.php',

+            ),

+            // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'

+            'hooks' => array(

+                //   'data' => array(

+                //       'hookcontext1',

+                //       'hookcontext2',

+                //   ),

+                //   'entity' => '0',

+            ),

+            // Set this to 1 if feature of module are opened to external users

+            'moduleforexternal' => 0,

+        );

+        // Data directories to create when module is enabled.

+        // Example: this->dirs = array("/zapier/temp","/zapier/subdir");

+        $this->dirs = array("/zapier/temp");

+        // Config pages. Put here list of php page, stored into zapier/admin directory, to use to setup module.

+        $this->config_page_url = array(

+        //    "setup.php@zapier"

+        );

+        // Dependencies

+        // A condition to hide module

+        $this->hidden = false;

+        // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)

+        $this->depends = array();

+        // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)

+        $this->requiredby = array();

+        // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

+        $this->conflictwith = array();

+        $this->langfiles = array("zapier");

+        // Minimum version of PHP required by module

+        //$this->phpmin = array(5, 5);

+        // Minimum version of Dolibarr required by module

+        $this->need_dolibarr_version = array(10, 0);

+        // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        $this->warnings_activation = array();

+        // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)

+        $this->warnings_activation_ext = array();

+        // $this->automatic_activation = array(

+        //     'FR'=>'ZapierWasAutomaticallyActivatedBecauseOfYourCountryChoice',

+        // );

+        // If true, can't be disabled

+        // $this->always_enabled = true;

+        // Constants

+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

+        // Example: $this->const=array(

+        //    1 => array('ZAPIERFORDOLIBARR_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),

+        //    2 => array('ZAPIERFORDOLIBARR_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)

+        // );

+        $this->const = array(

+            // 1 => array('ZAPIERFORDOLIBARR_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)

+        );

+        // Some keys to add into the overwriting translation tables

+        /*$this->overwrite_translation = array(

+            'en_US:ParentCompany'=>'Parent company or reseller',

+            'fr_FR:ParentCompany'=>'Maison mère ou revendeur'

+        )*/

+        if (!isset($conf->zapier) || !isset($conf->zapier->enabled)) {

+            $conf->zapier = new stdClass();

+            $conf->zapier->enabled = 0;

+        }

+        // Array to add new pages in new tabs

+        $this->tabs = array();

+        // Example:

+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@zapier:$user->rights->zapier->read:/zapier/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1

+        // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@zapier:$user->rights->othermodule->read:/zapier/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.

+        // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname

+        //

+        // Where objecttype can be

+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)

+        // 'contact'          to add a tab in contact view

+        // 'contract'         to add a tab in contract view

+        // 'group'            to add a tab in group view

+        // 'intervention'     to add a tab in intervention view

+        // 'invoice'          to add a tab in customer invoice view

+        // 'invoice_supplier' to add a tab in supplier invoice view

+        // 'member'           to add a tab in fundation member view

+        // 'opensurveypoll'	  to add a tab in opensurvey poll view

+        // 'order'            to add a tab in customer order view

+        // 'order_supplier'   to add a tab in supplier order view

+        // 'payment'		  to add a tab in payment view

+        // 'payment_supplier' to add a tab in supplier payment view

+        // 'product'          to add a tab in product view

+        // 'propal'           to add a tab in propal view

+        // 'project'          to add a tab in project view

+        // 'stock'            to add a tab in stock view

+        // 'thirdparty'       to add a tab in third party view

+        // 'user'             to add a tab in user view

+        // Dictionaries

+        $this->dictionaries = array();

+        /* Example:

+        $this->dictionaries=array(

+            'langs'=>'mylangfile@zapier',

+            // List of tables we want to see into dictonnary editor

+            'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),

+            // Label of tables

+            'tablib'=>array("Table1","Table2","Table3"),

+            // Request to select fields

+            'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),

+            // Sort order

+            'tabsqlsort'=>array("label ASC","label ASC","label ASC"),

+            // List of fields (result of select to show dictionary)

+            'tabfield'=>array("code,label","code,label","code,label"),

+            // List of fields (list of fields to edit a record)

+            'tabfieldvalue'=>array("code,label","code,label","code,label"),

+            // List of fields (list of fields for insert)

+            'tabfieldinsert'=>array("code,label","code,label","code,label"),

+            // Name of columns with primary key (try to always name it 'rowid')

+            'tabrowid'=>array("rowid","rowid","rowid"),

+            // Condition to show each dictionary

+            'tabcond'=>array($conf->zapier->enabled,$conf->zapier->enabled,$conf->zapier->enabled)

+        );

+        */

+        // Boxes/Widgets

+        // Add here list of php file(s) stored in zapier/core/boxes that contains class to show a widget.

+        $this->boxes = array(

+            //  0 => array(

+            //      'file' => 'zapierwidget1.php@zapier',

+            //      'note' => 'Widget provided by Zapier',

+            //      'enabledbydefaulton' => 'Home',

+            //  ),

+            //1=>array('file'=>'zapierwidget2.php@zapier','note'=>'Widget provided by Zapier'),

+            //2=>array('file'=>'zapierwidget3.php@zapier','note'=>'Widget provided by Zapier')

+        );

+        // Cronjobs (List of cron jobs entries to add when module is enabled)

+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week

+        $this->cronjobs = array(

+            //  0 => array(

+            //      'label' => 'MyJob label',

+            //      'jobtype' => 'method',

+            //      'class' => '/zapier/class/myobject.class.php',

+            //      'objectname' => 'MyObject',

+            //      'method' => 'doScheduledJob',

+            //      'parameters' => '',

+            //      'comment' => 'Comment',

+            //      'frequency' => 2,

+            //      'unitfrequency' => 3600,

+            //      'status' => 0,

+            //      'test' => '$conf->zapier->enabled',

+            //      'priority' => 50,

+            //  ),

+        );

+        // Example: $this->cronjobs=array(

+        //    0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50),

+        //    1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50)

+        // );

+        // Permissions

+        // Permission array used by this module

+        $this->rights = array();

+

+        $r = 0;

+        // Permission id (must not be already used)

+        $this->rights[$r][0] = $this->numero + $r;

+        // Permission label

+        $this->rights[$r][1] = 'Read myobject of Zapier';

+        // Permission by default for new user (0/1)

+        $this->rights[$r][3] = 1;

+        // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2)

+        $this->rights[$r][4] = 'read';

+        // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2)

+        $this->rights[$r][5] = '';

+        $r++;

+        $this->rights[$r][0] = $this->numero + $r;

+        $this->rights[$r][1] = 'Create/Update myobject of Zapier';

+        $this->rights[$r][3] = 1;

+        $this->rights[$r][4] = 'write';

+        $this->rights[$r][5] = '';

+        $r++;

+        $this->rights[$r][0] = $this->numero + $r;

+        $this->rights[$r][1] = 'Delete myobject of Zapier';

+        $this->rights[$r][3] = 1;

+        $this->rights[$r][4] = 'delete';

+        $this->rights[$r][5] = '';

+

+        // Main menu entries

+        $this->menu = array(); // List of menus to add

+        $r = 0;

+

+        // Add here entries to declare new menus

+        // $this->menu[$r++]=array(

+        //     'fk_menu' => '',                          // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+        //     'type' => 'top',                          // This is a Top menu entry

+        //     'titre' => 'Zapier',

+        //     'mainmenu' => 'zapier',

+        //     'leftmenu' => '',

+        //     'url' => '/zapier/zapierindex.php',

+        //     'langs' => 'zapier@zapier',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+        //     'position' => 1000+$r,

+        //     'enabled' => '$conf->zapier->enabled',  // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled.

+        //     'perms' => '1',			                // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules

+        //     'target' => '',

+        //     'user' => 2,				                // 0=Menu for internal users, 1=external users, 2=both

+        // );

+

+        /*

+        $this->menu[$r++]=array(

+            'fk_menu'=>'fk_mainmenu=zapier',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+            'type'=>'left',			                // This is a Left menu entry

+            'titre'=>'List MyObject',

+            'mainmenu'=>'zapier',

+            'leftmenu'=>'zapier_myobject_list',

+            'url'=>'/zapier/myobject_list.php',

+            'langs'=>'zapier@zapier',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+            'position'=>1000+$r,

+            'enabled'=>'$conf->zapier->enabled',  // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+            'perms'=>'1',			                // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules

+            'target'=>'',

+            'user'=>2,				                // 0=Menu for internal users, 1=external users, 2=both

+        );

+        $this->menu[$r++]=array(

+            'fk_menu'=>'fk_mainmenu=zapier,fk_leftmenu=zapier',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode

+            'type'=>'left',			                // This is a Left menu entry

+            'titre'=>'New MyObject',

+            'mainmenu'=>'zapier',

+            'leftmenu'=>'zapier_myobject_new',

+            'url'=>'/zapier/myobject_page.php?action=create',

+            'langs'=>'zapier@zapier',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

+            'position'=>1000+$r,

+            'enabled'=>'$conf->zapier->enabled',  // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.

+            'perms'=>'1',			                // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules

+            'target'=>'',

+            'user'=>2,                              // 0=Menu for internal users, 1=external users, 2=both

+        );

+        */

+    }

+

+    /**

+     *  Function called when module is enabled.

+     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.

+     *  It also creates data directories

+     *

+     *  @param      string  $options    Options when enabling module ('', 'noboxes')

+     *  @return     int                 1 if OK, 0 if KO

+     */

+    public function init($options = '')

+    {

+        $result = $this->_load_tables('/zapier/sql/');

+        if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')

+

+        // Create extrafields

+        //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

+        //$extrafields = new ExtraFields($this->db);

+        //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

+        //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

+        //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

+        //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

+        //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled');

+        $sql = array();

+        return $this->_init($sql, $options);

+    }

+

+    /**

+     *  Function called when module is disabled.

+     *  Remove from database constants, boxes and permissions from Dolibarr database.

+     *  Data directories are not deleted

+     *

+     *  @param      string	$options    Options when enabling module ('', 'noboxes')

+     *  @return     int                 1 if OK, 0 if KO

+     */

+    public function remove($options = '')

+    {

+        $sql = array();

+        return $this->_remove($sql, $options);

+    }