diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index ece19fe222c7aec977bd27baed9bd25747c73d46..275154cd80e704820a4e218f5080138de4dec061 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2004-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin		<regis.houssin@capnetworks.com>
+/* Copyright (C) 2004-2013  Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin       <regis.houssin@capnetworks.com>
+ * Copyright (C) 2014       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,31 +26,88 @@
 
 
 /**
- *		Parent class of boxes
+ * Class ModeleBoxes
+ *
+ * Boxes parent class
  */
 class ModeleBoxes    // Can't be abtract as it is instantiated to build "empty" boxes
 {
-	var $db;
-	var $error='';
-	var $max=5;
-	var $enabled=1;
-
-	var $rowid;
-	var $id;
-	var $position;
-	var $box_order;
-	var $fk_user;
-	var $sourcefile;
-	var $class;
-	var $box_id;
-	var $note;
+	/**
+	 * @var DoliDB Database handler
+	 */
+	public $db;
+
+	/**
+	 * @var string Error message
+	 */
+	public $error = '';
+
+	/**
+	 * @var int Maximum lines
+	 */
+	public $max = 5;
+
+	/**
+	 * @var int Status
+	 */
+	public $enabled=1;
+
+	/**
+	 * @var int Box definition database ID
+	 */
+	public $rowid;
 
+	/**
+	 * @var int ID
+	 * @deprecated Same as box_id?
+	 */
+	public $id;
 
 	/**
-	 *	Constructor
+	 * @var int Position?
+	 */
+	public $position;
+
+	/**
+	 * @var string Display order
+	 */
+	public $box_order;
+
+	/**
+	 * @var int User ID
+	 */
+	public $fk_user;
+
+	/**
+	 * @var string Source file
+	 */
+	public $sourcefile;
+
+	/**
+	 * @var string Class name
+	 */
+	public $class;
+
+	/**
+	 * @var string ID
+	 */
+	public $box_id;
+
+	/**
+	 * @var string Alphanumeric ID
+	 */
+	public $boxcode;
+
+	/**
+	 * @var string Note
+	 */
+	public $note;
+
+	/**
+	 * Constructor
 	 *
-	 *	@param	DoliDB	$db			Database handler
-     *  @param	string	$param		More parameters
+	 * @param   DoliDB  $db     Database handler
+     * @param   string  $param  More parameters
 	 */
 	function __construct($db,$param='')
 	{
@@ -57,9 +115,9 @@ class ModeleBoxes    // Can't be abtract as it is instantiated to build "empty"
 	}
 
 	/**
-	 *  Return last error message
+	 * Return last error message
 	 *
-	 *  @return	string				Error message
+	 * @return  string  Error message
 	 */
 	function error()
 	{
@@ -68,10 +126,11 @@ class ModeleBoxes    // Can't be abtract as it is instantiated to build "empty"
 
 
 	/**
-	 *  Load a box line from its rowid
+	 * Load a box line from its rowid
 	 *
-	 *  @param	int		$rowid		Row id to load
-	 *  @return	int					<0 if KO, >0 if OK
+	 * @param   int $rowid  Row id to load
+	 *
+	 * @return  int         <0 if KO, >0 if OK
 	 */
 	function fetch($rowid)
 	{
@@ -110,11 +169,12 @@ class ModeleBoxes    // Can't be abtract as it is instantiated to build "empty"
 
 
 	/**
-	 *	Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
+	 *Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
+	 *
+	 * @param   array   $head       Array with properties of box title
+	 * @param   array   $contents   Array with properties of box lines
 	 *
-	 *	@param	array	$head       Array with properties of box title
-	 *	@param  array	$contents   Array with properties of box lines
-	 *	@return	void
+	 * @return  void
 	 */
 	function showBox($head, $contents)
 	{
diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php
index 675e1cf07944bd684a113d18a603f0b8856b5742..3ba7cbf52ca998cae897c995c61312156a034c8d 100644
--- a/htdocs/core/class/commonobjectline.class.php
+++ b/htdocs/core/class/commonobjectline.class.php
@@ -26,7 +26,7 @@
  *  Parent class for class inheritance lines of business objects
  *  This class is useless for the moment so no inherit are done on it
  */
-abstract class CommonObjectLine
+abstract class CommonObjectLine extends CommonObject
 {
     /**
      * Call trigger based on this instance
diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php
index 01d79cdcabe829f54d14ecc376ffcd46ef039af9..cb30a20251326d51996b03858cd2a7bad5762ff5 100644
--- a/htdocs/core/lib/fichinter.lib.php
+++ b/htdocs/core/lib/fichinter.lib.php
@@ -126,6 +126,11 @@ function fichinter_admin_prepare_head()
     $head[$h][2] = 'attributes';
     $h++;
 
+	$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFields");
+    $head[$h][2] = 'attributesdet';
+    $h++;
+
 
 
 	complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 1215f8e85e28aedb9be2d118654255265315b9cd..e4d1f834b4afb512ad197d058cc0a3859086c15f 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1,10 +1,11 @@
 <?php
-/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
- * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
- * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
- * Copyright (C) 2005-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
+/* Copyright (C) 2003-2007  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004       Sebastien Di Cintio     <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004       Benoit Mortier          <benoit.mortier@opensides.be>
+ * Copyright (C) 2004       Eric Seigne             <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2013  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2014       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,48 +22,184 @@
  */
 
 /**
- *  \file           htdocs/core/modules/DolibarrModules.class.php
- *  \brief          File of parent class of module descriptor class files
+ * \file           htdocs/core/modules/DolibarrModules.class.php
+ * \brief          File of parent class of module descriptor class files
  */
 
 
 /**
- *  Parent class of module descriptor class files
+ * Class DolibarrModules
+ *
+ * Parent class for module descriptor class files
  */
 abstract class DolibarrModules
 {
-    //! Database handler
-    var $db;
-    //! Relative path to module style sheet
-    var $style_sheet = ''; // deprecated
-    //! Path to create when module activated
-    var $dirs = array();
-    //! Tableau des boites
-    var $boxes;
-    //! Tableau des constantes
-    var $const;
-    //! Tableau des droits
-    var $rights;
-    //! Tableau des menus
-    var $menu=array();
-    //! Module parts array
-    var $module_parts=array();
-    //! Tableau des documents ???
-    var $docs;
-
-    var $dbversion = "-";
-
-
     /**
-     *  Method to enable a module. Insert into database all constants, boxes of module
-     *
-     *  @param      array	$array_sql  	Array of SQL requests to execute when enabling module
-     *  @param      string	$options    	String with options when disabling module ('newboxdefonly|noboxes')
-     *  @return     int              		1 if OK, 0 if KO
+     * @var DoliDb Database handler
      */
+    public $db;
+
+	/**
+	 * @var string Relative path to module style sheet
+	 * @deprecated
+	 */
+	public $style_sheet = '';
+
+	/**
+	 * @var array Paths to create when module is activated
+	 */
+	public $dirs = array();
+
+	/**
+	 * @var array Module boxes
+	 */
+	public $boxes = array();
+
+	/**
+	 * @var array Module constants
+	 */
+	public $const = 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'),
+	 *      // Set here all workflow context managed by module
+	 *	    'workflow' => array(
+	 *          'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array(
+	 *              'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
+	 *              'picto'=>'yourpicto@mymodule'
+	 *          )
+	 *      )
+	 *  )
+	 */
+	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 int Module unique ID
+	 */
+	public $numero;
+
+	/**
+	 * @var string Module name
+	 */
+	public $name;
+
+	/**
+	 * @var string Module version
+	 */
+	public $version;
+
+	/**
+	 * @var string Module description
+	 */
+	public $description;
+
+	/**
+	 * @var string[] Module language files
+	 */
+	public $langfiles;
+
+	/**
+	 * @var string Module export code
+	 */
+	public $export_code;
+
+	/**
+	 * @var string Module export label
+	 */
+	public $export_label;
+
+	/**
+	 * @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 bool Module is enabled globally (Multicompany support)
+	 */
+	public $core_enabled;
+
+	/**
+	 * Enables a module.
+	 * Inserts all informations into database
+	 *
+	 * @param   string[]    $array_sql  SQL requests to be executed when enabling module
+	 * @param   string      $options    String with options when disabling module ('newboxdefonly|noboxes')
+	 *
+	 * @return  int                     1 if OK, 0 if KO
+	 */
     function _init($array_sql, $options='')
     {
-        global $conf, $langs;
+        global $conf;
         $err=0;
 
         $this->db->begin();
@@ -98,18 +235,13 @@ abstract class DolibarrModules
             if (! $err)
             {
                 $val=$array_sql[$i];
-                $sql='';
+	            $sql=$val;
                 $ignoreerror=0;
                 if (is_array($val))
                 {
                     $sql=$val['sql'];
                     $ignoreerror=$val['ignoreerror'];
                 }
-                else
-                {
-                    $sql=$val;
-                }
-
                 // Add current entity id
                 $sql=str_replace('__ENTITY__', $conf->entity, $sql);
 
@@ -144,15 +276,15 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Fonction de desactivation. Supprime de la base les constantes et boites du module
+     * Disable function. Deletes the module constant and boxes from the database.
      *
-     *  @param      array	$array_sql      Array of SQL requests to execute when disable module
-     *  @param      string	$options		String with options when disabling module ('newboxdefonly|noboxes')
-     *  @return     int      		       	1 if OK, 0 if KO
+     * @param   string[]    $array_sql  SQL requests to be executed when module is disabled
+     * @param   string      $options	Options when disabling module ('newboxdefonly|noboxes')
+     *
+     * @return  int                     1 if OK, 0 if KO
      */
     function _remove($array_sql, $options='')
     {
-        global $langs;
         $err=0;
 
         $this->db->begin();
@@ -212,10 +344,9 @@ abstract class DolibarrModules
 
 
     /**
-     *  Retourne le nom traduit du module si la traduction existe dans admin.lang,
-     *  sinon le nom defini par defaut dans le module.
+     * Gives the translated module name if translation exists in admin.lang or the default module name.
      *
-     *  @return     string      Nom du module traduit
+     * @return  string  Translated module name
      */
     function getName()
     {
@@ -224,22 +355,21 @@ abstract class DolibarrModules
 
         if ($langs->trans("Module".$this->numero."Name") != ("Module".$this->numero."Name"))
         {
-            // Si traduction du nom du module existe
+            // If module name translation exists
             return $langs->trans("Module".$this->numero."Name");
         }
         else
         {
-            // If translation of module with its numero does not exists, we take its name
+            // If module name translation using it's unique id does not exists, we take its name
             return $this->name;
         }
     }
 
 
     /**
-     *  Retourne la description traduite du module si la traduction existe dans admin.lang,
-     *  sinon la description definie par defaut dans le module
+     * Gives the translated module description if translation exists in admin.lang or the default module description
      *
-     *  @return     string      Nom du module traduit
+     * @return  string  Translated module description
      */
     function getDesc()
     {
@@ -248,24 +378,23 @@ abstract class DolibarrModules
 
         if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc"))
         {
-            // Si traduction de la description du module existe
+	        // If module description translation exists
             return $langs->trans("Module".$this->numero."Desc");
         }
         else
         {
-            // Si traduction de la description du module n'existe pas, on prend definition en dur dans module
+	        // If module description translation using it's unique id does not exists, we take its description
             return $this->description;
         }
     }
 
 
     /**
-     *  Return module version.
-     *  Pour les modules a l'etat 'experimental', retourne la traduction de 'experimental'
-     *  Pour les modules 'dolibarr', retourne la version de Dolibarr
-     *  Pour les autres modules, retourne la version du module
+     * Gives module version
+     * For 'experimental' modules, gives 'experimental' translation
+     * For 'dolibarr' modules, gives Dolibarr version
      *
-     *  @return     string      Version du module
+     * @return  string  Module version
      */
     function getVersion()
     {
@@ -281,9 +410,9 @@ abstract class DolibarrModules
 
 
     /**
-     *  Return if a module is a core or external module
+     * Tells if module is core or external
      *
-     *  @return     string      'core', 'external' or 'unknown'
+     * @return  string  'core', 'external' or 'unknown'
      */
     function isCoreOrExternalModule()
     {
@@ -295,9 +424,9 @@ abstract class DolibarrModules
 
 
     /**
-     *  Return list of lang files related to module
+     * Gives module related language files list
      *
-     *  @return     array       Array of lang files
+     * @return  string[]    Language files list
      */
     function getLangFilesArray()
     {
@@ -305,10 +434,11 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Return translated label of a export dataset
+     * Gives translated label of an export dataset
      *
-     *	@param	int		$r		Index of dataset
-     *  @return string      	Label of databaset
+     * @param   int     $r  Dataset index
+     *
+     * @return string       Translated databaset label
      */
     function getExportDatasetLabel($r)
     {
@@ -329,10 +459,11 @@ abstract class DolibarrModules
 
 
     /**
-     *  Return translated label of an import dataset
+     * Gives translated label of an import dataset
+     *
+     * @param   int     $r  Dataset index
      *
-     *  @param	int		$r		Index of dataset
-     *  @return	string    		Label of databaset
+     * @return  string      Translated dataset label
      */
     function getImportDatasetLabel($r)
     {
@@ -354,9 +485,9 @@ abstract class DolibarrModules
 
 
     /**
-     *      Insert constant to activate module
+     * Insert constants for module activation
      *
-     *      @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function _active()
     {
@@ -389,10 +520,10 @@ abstract class DolibarrModules
 
 
     /**
-     *      Remove activation line
+     * Module deactivation
      *
-     *      @return     int     Nb of errors (0 if OK)
-     **/
+     * @return  int Error count (0 if OK)
+     */
     function _unactive()
     {
         global $conf;
@@ -414,24 +545,24 @@ abstract class DolibarrModules
 
 
     /**
-     *  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
+     * 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
+     * @param   string  $reldir Relative directory where to scan files
+     * @return  int             <=0 if KO, >0 if OK
      */
     function _load_tables($reldir)
     {
-        global $db,$conf;
+        global $conf;
 
         $error=0;
 		$dirfound=0;
 
 		if (empty($reldir)) return 1;
 
-        include_once DOL_DOCUMENT_ROOT .'/core/lib/admin.lib.php';
+        include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 
         $ok = 1;
         foreach($conf->file->dol_document_root as $dirroot)
@@ -508,14 +639,15 @@ abstract class DolibarrModules
 
 
     /**
-     *  Insert boxes into llx_boxes_def
+     * Adds boxes
+     *
+     * @param   string  $option Options when disabling module ('newboxdefonly'=insert only boxes definition)
      *
-     *	@param		string	$option		String with options when disabling module ('newboxdefonly'=insert only boxes definition)
-     *  @return     int     			Nb of errors (0 if OK)
+     * @return  int             Error count (0 if OK)
      */
     function insert_boxes($option='')
     {
-		require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
+		require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
 
     	global $conf;
 
@@ -605,9 +737,9 @@ abstract class DolibarrModules
 
 
     /**
-     *  Delete boxes
+     * Removes boxes
      *
-     *  @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function delete_boxes()
     {
@@ -657,9 +789,9 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Remove links to new module page present in llx_const
+     * Removes tabs
      *
-     *  @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function delete_tabs()
     {
@@ -682,9 +814,9 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Add links of new pages from modules in llx_const
+     * Adds tabs
      *
-     *  @return     int     Number of errors (0 if ok)
+     * @return int  Error count (0 if ok)
      */
     function insert_tabs()
     {
@@ -717,13 +849,7 @@ abstract class DolibarrModules
                     $sql.= ")";
 
                     dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
-                    $resql=$this->db->query($sql);
-                    /* Allow duplicate key
-                     if (! $resql)
-                     {
-                        $err++;
-                        }
-                        */
+                    $this->db->query($sql);
                 }
                 $i++;
             }
@@ -732,9 +858,9 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Insert constants defined into $this->const array into table llx_const
+     * Adds constants
      *
-     *  @return     int     Number of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function insert_const()
     {
@@ -799,9 +925,9 @@ abstract class DolibarrModules
     }
 
     /**
-     * Remove constants with tags deleteonunactive
+     * Removes constants tagged 'deleteonunactive'
      *
-     * @return     int     <0 if KO, 0 if OK
+     * @return  int <0 if KO, 0 if OK
      */
     function delete_const()
     {
@@ -832,11 +958,12 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Insert permissions definitions related to the module into llx_rights_def
+     * 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		$reinitadminperms   If 1, we also grant them to all admin users
-     *  @param	int		$force_entity		Force current entity
-     *  @return int                 		Number of error (0 if OK)
+     * @return  int                     Error count (0 if OK)
      */
     function insert_permissions($reinitadminperms=0, $force_entity=null)
     {
@@ -928,7 +1055,7 @@ abstract class DolibarrModules
                     if ($reinitadminperms)
                     {
                     	if (! class_exists('User')) {
-                    		require DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
+							require 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);
@@ -972,9 +1099,9 @@ abstract class DolibarrModules
 
 
     /**
-     * Delete permissions
+     * Removes access rights
      *
-     * @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function delete_permissions()
     {
@@ -997,15 +1124,15 @@ abstract class DolibarrModules
 
 
     /**
-     *  Insert menus entries found into $this->menu into llx_menu*
+     * Adds menu entries
      *
-     *  @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function insert_menus()
     {
     	global $user;
 
-        require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
+        require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php';
 
         $err=0;
 
@@ -1101,9 +1228,9 @@ abstract class DolibarrModules
 
 
     /**
-     *  Remove menus entries
+     * Removes menu entries
      *
-     *  @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function delete_menus()
     {
@@ -1127,9 +1254,9 @@ abstract class DolibarrModules
     }
 
     /**
-     *  Create directories required by module
+     * Creates directories
      *
-     *  @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function create_dirs()
     {
@@ -1185,11 +1312,12 @@ abstract class DolibarrModules
 
 
     /**
-     *  Insert directories in llx_const
+     * Adds directories definitions
+     *
+     * @param   string  $name   Name
+     * @param   string  $dir    Directory
      *
-     *  @param	string	$name		Name
-     *  @param	string	$dir		Directory
-     *  @return	int     			Nb of errors (0 if OK)
+     * @return  int             Error count (0 if OK)
      */
     function insert_dirs($name,$dir)
     {
@@ -1214,7 +1342,7 @@ abstract class DolibarrModules
                 $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);
-                $resql=$this->db->query($sql);
+                $this->db->query($sql);
             }
         }
         else
@@ -1228,9 +1356,9 @@ abstract class DolibarrModules
 
 
     /**
-     *  Remove directory entries
+     * Removes directories
      *
-     *  @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function delete_dirs()
     {
@@ -1253,23 +1381,9 @@ abstract class DolibarrModules
     }
 
     /**
-     * Insert activation of generic parts from modules in llx_const
-	 * Input entry use $this->module_parts = array(
-	 *                        	'triggers' => 0,                                 // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
-	 *							'login' => 0,                                    // Set this to 1 if module has its own login method directory (/mymodule/core/login)
-	 *							'substitutions' => 0,                            // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
-	 *							'menus' => 0,                                    // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
-	 *							'theme' => 0,                                    // Set this to 1 if module has its own theme directory (/mymodule/theme)
-	 *                        	'tpl' => 0,                                      // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
-	 *							'barcode' => 0,                                  // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
-	 *							'models' => 0,                                   // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
-	 *							'css' => '/mymodule/css/mymodule.css.php',       // Set this to relative path of css file if module has its own css file
-	 *							'js' => '/mymodule/js/mymodule.js',              // Set this to relative path of js file if module must load a js on all pages
-	 *							'hooks' => array('hookcontext1','hookcontext2')  // Set here all hooks context managed by module
-	 *							'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule') // Set here all workflow context managed by module
-	 * )
+     * Adds generic parts
      *
-     * @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function insert_module_parts()
     {
@@ -1338,9 +1452,9 @@ abstract class DolibarrModules
     }
 
     /**
-     * Remove activation of generic parts of modules from llx_const
+     * Removes generic parts
      *
-     * @return     int     Nb of errors (0 if OK)
+     * @return  int Error count (0 if OK)
      */
     function delete_module_parts()
     {
@@ -1368,7 +1482,6 @@ abstract class DolibarrModules
     			}
     		}
     	}
-
     	return $err;
     }
 
diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php
new file mode 100644
index 0000000000000000000000000000000000000000..7f8b51936314c25a9b23246c05e03c15e44fb95d
--- /dev/null
+++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php
@@ -0,0 +1,159 @@
+<?php
+/* Copyright (C) 2001-2002	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2003		Jean-Louis Bergamo		<jlb@j1b.org>
+ * Copyright (C) 2004-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2013		Florian Henry			<florian.henry@open-concept.pro>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/fichinter/admin/fichinter_extrafields.php
+ *		\ingroup    fichinter
+ *		\brief      Page to setup extra fields of ficheinter
+ */
+
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
+$langs->load("companies");
+$langs->load("admin");
+$langs->load("members");
+$langs->load('interventions');
+
+$extrafields = new ExtraFields($db);
+$form = new Form($db);
+
+// List of supported format
+$tmptype2label=ExtraFields::$type2label;
+$type2label=array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
+
+$action=GETPOST('action', 'alpha');
+$attrname=GETPOST('attrname', 'alpha');
+$elementtype='fichinterdet';  //Must be the $element of the class that manage extrafield
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
+
+
+
+/*
+ * View
+ */
+
+
+llxHeader();
+
+$textobject=$langs->transnoentitiesnoconv("Interventions");
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup');
+
+
+$head=fichinter_admin_prepare_head();
+
+dol_fiche_head($head, 'attributesdet', $langs->trans("Interventions"), 0, 'intervention');
+
+
+print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
+print '<br>';
+
+// Load attribute_label
+$extrafields->fetch_name_optionals_label($elementtype);
+
+print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
+
+print '<tr class="liste_titre">';
+print '<td align="center">'.$langs->trans("Position").'</td>';
+print '<td>'.$langs->trans("Label").'</td>';
+print '<td>'.$langs->trans("AttributeCode").'</td>';
+print '<td>'.$langs->trans("Type").'</td>';
+print '<td align="right">'.$langs->trans("Size").'</td>';
+print '<td align="center">'.$langs->trans("Unique").'</td>';
+print '<td align="center">'.$langs->trans("Required").'</td>';
+print '<td width="80">&nbsp;</td>';
+print "</tr>\n";
+
+$var=True;
+foreach($extrafields->attribute_type as $key => $value)
+{
+    $var=!$var;
+    print "<tr ".$bc[$var].">";
+    print "<td>".$extrafields->attribute_pos[$key]."</td>\n";
+    print "<td>".$extrafields->attribute_label[$key]."</td>\n";
+    print "<td>".$key."</td>\n";
+    print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
+    print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
+    print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
+    print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
+    print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
+    print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
+    print "</tr>";
+    //      $i++;
+}
+
+print "</table>";
+
+dol_fiche_end();
+
+
+// Buttons
+if ($action != 'create' && $action != 'edit')
+{
+    print '<div class="tabsAction">';
+    print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
+    print "</div>";
+}
+
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Creation d'un champ optionnel
+ /*                                                                            */
+/* ************************************************************************** */
+
+if ($action == 'create')
+{
+    print "<br>";
+    print_titre($langs->trans('NewAttribute'));
+
+    require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
+}
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Edition d'un champ optionnel                                               */
+/*                                                                            */
+/* ************************************************************************** */
+if ($action == 'edit' && ! empty($attrname))
+{
+    print "<br>";
+    print_titre($langs->trans("FieldEdition", $attrname));
+
+    require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
+}
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index cb4f178b840686487f661668fc57d31fa322d89f..80375648e26104203596565654be955b1751de5f 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -167,6 +167,17 @@ class Fichinter extends CommonObject
 				$resql=$this->db->query($sql);
 				if (! $resql) $error++;
 			}
+			
+			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+            {
+            	
+            	$result=$this->insertExtraFields();
+            	if ($result < 0)
+            	{
+            		$error++;
+            	}
+            }	
+			
 			// Add linked object
 			if (! $error && $this->origin && $this->origin_id)
 			{
@@ -855,7 +866,7 @@ class Fichinter extends CommonObject
 	 *	@param      int		$duration            	Intervention duration
 	 *	@return    	int             				>0 if ok, <0 if ko
 	 */
-	function addline($user,$fichinterid, $desc, $date_intervention, $duration)
+	function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_option=0)
 	{
 		dol_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration");
 
@@ -871,14 +882,20 @@ class Fichinter extends CommonObject
 			$line->datei        = $date_intervention;
 			$line->duration     = $duration;
 
+			if (is_array($array_option) && count($array_option)>0) {
+				$line->array_options=$array_option;
+			}
+
 			$result=$line->insert($user);
-			if ($result > 0)
+			
+			if ($result >= 0)
 			{
+				
 				$this->db->commit();
 				return 1;
 			}
 			else
-			{
+			{	
 				$this->error=$this->db->error();
 				$this->db->rollback();
 				return -1;
@@ -987,7 +1004,10 @@ class FichinterLigne extends CommonObjectLine
 	var $duration;        // Duree de l'intervention
 	var $rang = 0;
 
-
+	public $element='fichinterdet';
+	public $table_element='fichinterdet';
+	public $fk_element='fk_fichinter';
+	
 	/**
 	 *	Constructor
 	 *
@@ -1017,6 +1037,7 @@ class FichinterLigne extends CommonObjectLine
 		{
 			$objp = $this->db->fetch_object($result);
 			$this->rowid          	= $objp->rowid;
+			$this->id 				= $objp->rowid;
 			$this->fk_fichinter   	= $objp->fk_fichinter;
 			$this->datei			= $this->db->jdate($objp->datei);
 			$this->desc           	= $objp->description;
@@ -1082,7 +1103,21 @@ class FichinterLigne extends CommonObjectLine
 		$resql=$this->db->query($sql);
 		if ($resql)
 		{
+			$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');	
+				
+			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+            {
+            	$this->id=$this->rowid;
+            	$result=$this->insertExtraFields();
+            	if ($result < 0)
+            	{
+            		$error++;
+            	}
+            }	
+				
+			
 			$result=$this->update_total();
+			
 			if ($result > 0)
 			{
 				$this->rang=$rangToUse;
@@ -1140,6 +1175,17 @@ class FichinterLigne extends CommonObjectLine
 		$resql=$this->db->query($sql);
 		if ($resql)
 		{
+			
+			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+        	{
+        		$this->id=$this->rowid;
+        		$result=$this->insertExtraFields();
+        		if ($result < 0)
+        		{
+        			$error++;
+        		}
+        	}
+			
 			$result=$this->update_total();
 			if ($result > 0)
 			{
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 437002aa23c9b91a92baacfc14b34aa4472cc324..36bf1690b3c096a7f22d491f71f1ec452dca7426 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -196,6 +196,13 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
 				$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
 			}
 
+			// Extrafields
+			$extrafields = new ExtraFields($db);
+			$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+			$array_option = $extrafields->getOptionalsFromPost($extralabels);
+	
+	        $object->array_options = $array_option;
+
 			$id = $object->create($user);
 
 			if ($id > 0)
@@ -266,12 +273,20 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
 							    $duration = 0;
 							}
 
+							$predef = '';
+							// Extrafields
+							$extrafieldsline = new ExtraFields($db);
+							$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
+							$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
+					
+
 		                    $result = $object->addline(
 								$user,
 		                        $id,
 		                        $desc,
 					            $date_intervention,
-                 				$duration
+                 				$duration,
+                 				$array_option
 		                    );
 
 							if ($result < 0)
@@ -298,6 +313,13 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
 	    }
 	    else
 	    {
+	    	// Extrafields
+			$extrafields = new ExtraFields($db);
+			$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+			$array_option = $extrafields->getOptionalsFromPost($extralabels);
+	
+	        $object->array_options = $array_option;
+			
 			$result = $object->create($user);
 	        if ($result > 0)
 	        {
@@ -433,12 +455,19 @@ else if ($action == "addline" && $user->rights->ficheinter->creer)
 		$date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int'));
 		$duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int'));
 
+		
+		// Extrafields
+		$extrafieldsline = new ExtraFields($db);
+		$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
+		$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+
         $result=$object->addline(
 			$user,
             $id,
             $desc,
             $date_intervention,
-            $duration
+            $duration,
+            $array_option
         );
 
 		// Define output language
@@ -524,6 +553,13 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST(
     $objectline->datei		= $date_inter;
     $objectline->desc		= $desc;
     $objectline->duration	= $duration;
+	
+	// Extrafields
+	$extrafieldsline = new ExtraFields($db);
+	$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
+	$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+	$objectline->array_options = $array_option;
+
 	$result = $objectline->update($user);
     if ($result < 0)
     {
@@ -1433,6 +1469,18 @@ else if ($id > 0 || ! empty($ref))
 					}
 
 					print '</tr>';
+					
+					$line = new FichinterLigne($db);
+					$line->fetch($objp->rowid);
+					
+					$extrafieldsline = new ExtraFields($db);
+					$extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
+					
+					$line->fetch_optionals($line->rowid, $extralabelslines);
+					 
+					print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5));
+			
+					
 				}
 
 				// Line in update mode
@@ -1461,6 +1509,17 @@ else if ($id > 0 || ! empty($ref))
 					print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
 					print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
 					print '</tr>' . "\n";
+					
+					$line = new FichinterLigne($db);
+					$line->fetch($objp->rowid);
+					
+					$extrafieldsline = new ExtraFields($db);
+					$extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
+					$line->fetch_optionals($line->rowid, $extralabelslines);
+					
+					print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
+			
+					
 				}
 
 				$i++;
@@ -1511,7 +1570,16 @@ else if ($id > 0 || ! empty($ref))
 
 				print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
 				print '</tr>';
-
+				
+				//Line extrafield
+				
+				$lineadd = new FichinterLigne($db);
+				
+				$extrafieldsline = new ExtraFields($db);
+				$extralabelslines=$extrafieldsline->fetch_name_optionals_label($lineadd->table_element);
+		
+				print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
+		
 				if (! $num) print '</table>';
 			}
 
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index b3a35bbfa6e75bccb19f69206c0e720f3494840b..e018cabfe4798b1bc41020cd8110f290ec5e7662 100644
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -992,3 +992,15 @@ ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_element (fk_element);
 ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_task (fk_task);
 ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_date (task_date);
 ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_datehour);
+
+
+-- add extrafield on ficheinter lines
+CREATE TABLE IF NOT EXISTS `llx_fichinterdet_extrafields` (
+  `rowid` int(11) NOT NULL AUTO_INCREMENT,
+  `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `fk_object` int(11) NOT NULL,
+  `import_key` varchar(14) DEFAULT NULL,
+  PRIMARY KEY (`rowid`),
+  KEY `idx_ficheinter_extrafields` (`fk_object`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+