diff --git a/notes/trunk/class/class_modules_tools.php b/notes/trunk/class/class_modules_tools.php
index a7da75dd57690bf843c736ccabd8aa6186565cc9..d00aa29a740fa5b05de1708fd23008b559f6467f 100644
--- a/notes/trunk/class/class_modules_tools.php
+++ b/notes/trunk/class/class_modules_tools.php
@@ -1,4 +1,24 @@
 <?php
+
+/*
+*   Copyright 2013-2016 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework 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.
+*
+*   Maarch Framework 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 Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
 /**
 * modules tools Class for notes
 *
@@ -12,243 +32,10 @@
 *
 */
 
+require_once 'modules/notes/class/class_modules_tools_Abstract.php';
 
-
-// Loads the required class
-try {
-    require_once("core/class/class_db.php");
-    require_once("modules/notes/notes_tables.php");
-    require_once("modules/entities/entities_tables.php");
-    require_once ("modules/notes/class/class_modules_tools.php");
-    require_once "modules/entities/class/EntityControler.php";
-} catch (Exception $e){
-    functions::xecho($e->getMessage()).' // ';
-}
-
-class notes
+class notes extends notes_Abstract
 {
-
-    /**
-    * Db query object used to connnect to the database
-    */
-    private static $db;
-    
-    /**
-    * Entity object
-    */
-    public static $ent;
-    
-     /**
-    * Notes table
-    */
-    public static $notes_table ;
-
-    /**
-    * Notes_entities table
-    */
-    public static $notes_entities_table ;
-    
-    /**
-    * Entities table
-    */
-    public static $entities_table ;
-    
-    /**
-    * Build Maarch module tables into sessions vars with a xml configuration
-    * file
-    */
-    public function build_modules_tables()
-    {
-        if (file_exists(
-            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
-            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . "modules"
-            . DIRECTORY_SEPARATOR . "notes" . DIRECTORY_SEPARATOR . "xml"
-            . DIRECTORY_SEPARATOR . "config.xml"
-        )
-        ) {
-            $path = $_SESSION['config']['corepath'] . 'custom'
-                  . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
-                  . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR
-                  . "notes" . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
-                  . "config.xml";
-        } else {
-            $path = "modules" . DIRECTORY_SEPARATOR . "notes"
-                  . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
-                  . "config.xml";
-        }
-        $xmlconfig = simplexml_load_file($path);
-        foreach ($xmlconfig->TABLENAME as $tableName) {
-            $_SESSION['tablename']['not_notes'] = (string) $tableName->not_notes;
-            $_SESSION['tablename']['note_entities'] = (string) $tableName->note_entities;
-        }
-        $hist = $xmlconfig->HISTORY;
-        $_SESSION['history']['noteadd'] = (string) $hist->noteadd;
-        $_SESSION['history']['noteup'] = (string) $hist->noteup;
-        $_SESSION['history']['notedel'] = (string) $hist->notedel;
-    }
-    
-    /**
-     * 
-     * 
-     * 
-     */
-     public function insertEntities($id)
-     {
-         //echo "RES_ID : ".$id;
-     } 
-    
-    
-    /**
-     * Function to get which user can see a note
-     * @id note identifier
-     */
-    public function getNotesEntities($id)
-    {
-        $db = new Database();
-        $ent = new EntityControler();
-        
-        $query = "SELECT entity_id, entity_label FROM ".NOTE_ENTITIES_TABLE." , entities WHERE item_id LIKE entity_id and note_id = ?";
-        
-        try{
-            $stmt = $db->query($query, array($id));
-        } catch (Exception $e){}
-        
-
-        $entitiesList = array();
-        $entitiesChosen = array();
-        $entitiesList = $ent->getAllEntities();
-        
-
-        while($res = $stmt->fetchObject())
-        {
-            array_push($entitiesChosen, $ent->get($res->entity_id));
-        }
-        
-        //self::disconnect();
-        return $entitiesChosen;
-    }
-    
-    public function getNotes($noteId, $userId, $userPrimaryEntity)
-    {
-        $query = "SELECT id FROM notes WHERE id in ("
-                  . "SELECT note_id FROM ". NOTE_ENTITIES_TABLE. " WHERE (item_id in ("
-                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
-            . "or (id = ? and user_id = ?)";
-        $db = new Database();
-        $stmt = $db->query($query, array($userId, $noteId, $noteId, $userId));
-
-        if ($stmt->rowCount() > 0) {
-            return true;
-         } else {
-            // test if public
-            $query = "SELECT note_id FROM ". NOTE_ENTITIES_TABLE. " WHERE note_id = ?";
-            $stmt = $db->query($query, array($noteId));
-            if ($stmt->rowCount() == 0) {
-                return true;
-            } else {
-                return false;
-            }
-         }
-    }
-    
-    public function countUserNotes($id, $coll_id) {
-        $not_nbr = 0;
-        $db = new Database();
-
-        $stmt = $db->query("SELECT id, identifier, user_id, date_note, note_text FROM "
-                            . NOTES_TABLE 
-                            . " WHERE identifier = ? and coll_id = ? order by date_note desc", array($id, $coll_id));
-
-       while ($res = $stmt->fetchObject())
-       {
-           $query = "SELECT id FROM ". NOTE_ENTITIES_TABLE. " WHERE note_id = ?";
-                    
-           $stmt2 = $db->query($query, array($res->id));
-                        
-           if($stmt2->rowCount()==0)
-            $not_nbr++;
-           else
-           {
-             $stmt2 = $db->query( "SELECT id FROM notes WHERE id in ("
-                . "SELECT note_id FROM ". NOTE_ENTITIES_TABLE. " WHERE (item_id in ("
-                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
-                . "or (id = ? and user_id = ?)",
-                array($_SESSION['user']['UserId'], $res->id, $res->id, $_SESSION['user']['UserId']));
-            
-                if($stmt2->rowCount()<>0)
-                $not_nbr++;
-            }
-        }
-        
-        return $not_nbr;
-    } 
-    
-    public function getUserNotes($id, $coll_id) {
-        $userNotes = array();
-        $db = new Database();
-
-        $stmt = $db->query("SELECT id, identifier, user_id, date_note, note_text FROM "
-                            . NOTES_TABLE 
-                            . " WHERE identifier = ? and coll_id = ? order by date_note desc",
-                            array($id, $coll_id));
-
-       while ($res = $stmt->fetchObject())
-       {
-           $query = "SELECT id FROM ".NOTE_ENTITIES_TABLE." WHERE note_id = ?";
-                    
-           $stmt2 = $db->query($query, array($res->id));
-                        
-            if($stmt2->rowCount()==0) {
-                array_push($userNotes,
-                    array('id' => $res->id, //ID
-                          'label' => functions::show_string($res->note_text), //Label
-                          'author' => $res->user_id, //Author 
-                          'date' => $res->date_note //Date
-                        )
-                );
-           } else {
-             $stmt2 = $db->query( "SELECT id FROM notes WHERE id in ("
-                . "select note_id from ". NOTE_ENTITIES_TABLE. " where (item_id in ("
-                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
-                . "or (id = ? and user_id = ?)",
-                array($_SESSION['user']['UserId'], $res->id, $res->id, $_SESSION['user']['UserId']));
-            
-                if($stmt2->rowCount()<>0) {
-                    array_push($userNotes,
-                        array('id' => $res->id, //ID
-                              'label' => functions::show_string($res->note_text), //Label
-                              'author' => $res->user_id, //Author 
-                              'date' => $res->date_note //Date
-                            )
-                    );
-                }
-            }
-        }
-        
-        return $userNotes;
-    }
-	
-	public function isUserNote($noteId, $userId, $userPrimaryEntity)
-    {
-        $query = "SELECT id FROM notes WHERE id in ("
-                  . "SELECT note_id FROM note_entities WHERE (item_id in ("
-                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
-                  . "or (id = ? and user_id = ?)";
-        $db = new Database();
-        $stmt = $db->query($query, array($userId, $noteId, $noteId, $userId));
-        //$db->show();exit;
-        if ($stmt->rowCount() > 0) {
-            return true;
-         } else {
-            // test if public
-            $query = "SELECT note_id FROM note_entities WHERE note_id = ?";
-            $stmt = $db->query($query, array($noteId));
-            if ($stmt->rowCount() == 0) {
-                return true;
-            } else {
-                return false;
-            }
-         }
-    }
+  // custom
 }
 
diff --git a/notes/trunk/class/class_modules_tools_Abstract.php b/notes/trunk/class/class_modules_tools_Abstract.php
new file mode 100755
index 0000000000000000000000000000000000000000..df06d9a9ed42bccd39af9ce7a13d530af4d3e2d7
--- /dev/null
+++ b/notes/trunk/class/class_modules_tools_Abstract.php
@@ -0,0 +1,273 @@
+<?php
+
+/*
+*   Copyright 2013-2016 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework 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.
+*
+*   Maarch Framework 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 Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+* modules tools Class for notes
+*
+*  Contains all the functions to load modules tables for notes
+*
+* @package  maarch
+* @version 3.0
+* @since 10/2005
+* @license GPL v3
+* @author  Claire Figueras  <dev@maarch.org>
+*
+*/
+
+
+// Loads the required class
+try {
+    require_once("core/class/class_db.php");
+    require_once("modules/notes/notes_tables.php");
+    require_once("modules/entities/entities_tables.php");
+    require_once ("modules/notes/class/class_modules_tools.php");
+    require_once "modules/entities/class/EntityControler.php";
+} catch (Exception $e){
+    functions::xecho($e->getMessage()).' // ';
+}
+
+abstract class notes_Abstract
+{
+
+    /**
+    * Db query object used to connnect to the database
+    */
+    private static $db;
+    
+    /**
+    * Entity object
+    */
+    public static $ent;
+    
+     /**
+    * Notes table
+    */
+    public static $notes_table ;
+
+    /**
+    * Notes_entities table
+    */
+    public static $notes_entities_table ;
+    
+    /**
+    * Entities table
+    */
+    public static $entities_table ;
+    
+    /**
+    * Build Maarch module tables into sessions vars with a xml configuration
+    * file
+    */
+    public function build_modules_tables()
+    {
+        if (file_exists(
+            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . "modules"
+            . DIRECTORY_SEPARATOR . "notes" . DIRECTORY_SEPARATOR . "xml"
+            . DIRECTORY_SEPARATOR . "config.xml"
+        )
+        ) {
+            $path = $_SESSION['config']['corepath'] . 'custom'
+                  . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                  . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR
+                  . "notes" . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
+                  . "config.xml";
+        } else {
+            $path = "modules" . DIRECTORY_SEPARATOR . "notes"
+                  . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
+                  . "config.xml";
+        }
+        $xmlconfig = simplexml_load_file($path);
+        foreach ($xmlconfig->TABLENAME as $tableName) {
+            $_SESSION['tablename']['not_notes'] = (string) $tableName->not_notes;
+            $_SESSION['tablename']['note_entities'] = (string) $tableName->note_entities;
+        }
+        $hist = $xmlconfig->HISTORY;
+        $_SESSION['history']['noteadd'] = (string) $hist->noteadd;
+        $_SESSION['history']['noteup'] = (string) $hist->noteup;
+        $_SESSION['history']['notedel'] = (string) $hist->notedel;
+    }
+    
+    /**
+     * 
+     * 
+     * 
+     */
+     public function insertEntities($id)
+     {
+         //echo "RES_ID : ".$id;
+     } 
+    
+    
+    /**
+     * Function to get which user can see a note
+     * @id note identifier
+     */
+    public function getNotesEntities($id)
+    {
+        $db = new Database();
+        $ent = new EntityControler();
+        
+        $query = "SELECT entity_id, entity_label FROM ".NOTE_ENTITIES_TABLE." , entities WHERE item_id LIKE entity_id and note_id = ?";
+        
+        try{
+            $stmt = $db->query($query, array($id));
+        } catch (Exception $e){}
+        
+
+        $entitiesList = array();
+        $entitiesChosen = array();
+        $entitiesList = $ent->getAllEntities();
+        
+
+        while($res = $stmt->fetchObject())
+        {
+            array_push($entitiesChosen, $ent->get($res->entity_id));
+        }
+        
+        //self::disconnect();
+        return $entitiesChosen;
+    }
+    
+    public function getNotes($noteId, $userId, $userPrimaryEntity)
+    {
+        $query = "SELECT id FROM notes WHERE id in ("
+                  . "SELECT note_id FROM ". NOTE_ENTITIES_TABLE. " WHERE (item_id in ("
+                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
+            . "or (id = ? and user_id = ?)";
+        $db = new Database();
+        $stmt = $db->query($query, array($userId, $noteId, $noteId, $userId));
+
+        if ($stmt->rowCount() > 0) {
+            return true;
+         } else {
+            // test if public
+            $query = "SELECT note_id FROM ". NOTE_ENTITIES_TABLE. " WHERE note_id = ?";
+            $stmt = $db->query($query, array($noteId));
+            if ($stmt->rowCount() == 0) {
+                return true;
+            } else {
+                return false;
+            }
+         }
+    }
+    
+    public function countUserNotes($id, $coll_id) {
+        $not_nbr = 0;
+        $db = new Database();
+
+        $stmt = $db->query("SELECT id, identifier, user_id, date_note, note_text FROM "
+                            . NOTES_TABLE 
+                            . " WHERE identifier = ? and coll_id = ? order by date_note desc", array($id, $coll_id));
+
+       while ($res = $stmt->fetchObject())
+       {
+           $query = "SELECT id FROM ". NOTE_ENTITIES_TABLE. " WHERE note_id = ?";
+                    
+           $stmt2 = $db->query($query, array($res->id));
+                        
+           if($stmt2->rowCount()==0)
+            $not_nbr++;
+           else
+           {
+             $stmt2 = $db->query( "SELECT id FROM notes WHERE id in ("
+                . "SELECT note_id FROM ". NOTE_ENTITIES_TABLE. " WHERE (item_id in ("
+                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
+                . "or (id = ? and user_id = ?)",
+                array($_SESSION['user']['UserId'], $res->id, $res->id, $_SESSION['user']['UserId']));
+            
+                if($stmt2->rowCount()<>0)
+                $not_nbr++;
+            }
+        }
+        
+        return $not_nbr;
+    } 
+    
+    public function getUserNotes($id, $coll_id) {
+        $userNotes = array();
+        $db = new Database();
+
+        $stmt = $db->query("SELECT id, identifier, user_id, date_note, note_text FROM "
+                            . NOTES_TABLE 
+                            . " WHERE identifier = ? and coll_id = ? order by date_note desc",
+                            array($id, $coll_id));
+
+       while ($res = $stmt->fetchObject())
+       {
+           $query = "SELECT id FROM ".NOTE_ENTITIES_TABLE." WHERE note_id = ?";
+                    
+           $stmt2 = $db->query($query, array($res->id));
+                        
+            if($stmt2->rowCount()==0) {
+                array_push($userNotes,
+                    array('id' => $res->id, //ID
+                          'label' => functions::show_string($res->note_text), //Label
+                          'author' => $res->user_id, //Author 
+                          'date' => $res->date_note //Date
+                        )
+                );
+           } else {
+             $stmt2 = $db->query( "SELECT id FROM notes WHERE id in ("
+                . "select note_id from ". NOTE_ENTITIES_TABLE. " where (item_id in ("
+                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
+                . "or (id = ? and user_id = ?)",
+                array($_SESSION['user']['UserId'], $res->id, $res->id, $_SESSION['user']['UserId']));
+            
+                if($stmt2->rowCount()<>0) {
+                    array_push($userNotes,
+                        array('id' => $res->id, //ID
+                              'label' => functions::show_string($res->note_text), //Label
+                              'author' => $res->user_id, //Author 
+                              'date' => $res->date_note //Date
+                            )
+                    );
+                }
+            }
+        }
+        
+        return $userNotes;
+    }
+	
+	public function isUserNote($noteId, $userId, $userPrimaryEntity)
+    {
+        $query = "SELECT id FROM notes WHERE id in ("
+                  . "SELECT note_id FROM note_entities WHERE (item_id in ("
+                      ."SELECT entity_id FROM users_entities WHERE user_id = ?) and note_id = ?))"
+                  . "or (id = ? and user_id = ?)";
+        $db = new Database();
+        $stmt = $db->query($query, array($userId, $noteId, $noteId, $userId));
+        //$db->show();exit;
+        if ($stmt->rowCount() > 0) {
+            return true;
+         } else {
+            // test if public
+            $query = "SELECT note_id FROM note_entities WHERE note_id = ?";
+            $stmt = $db->query($query, array($noteId));
+            if ($stmt->rowCount() == 0) {
+                return true;
+            } else {
+                return false;
+            }
+         }
+    }
+}
+
diff --git a/notes/trunk/class/notes_controler.php b/notes/trunk/class/notes_controler.php
index 93c60dffd97a0b816eef6f85466340d5ccfec4bc..e0539c49e5f596baa6a953025559deb80bc63d9d 100644
--- a/notes/trunk/class/notes_controler.php
+++ b/notes/trunk/class/notes_controler.php
@@ -1,6 +1,6 @@
 <?php
 /*
-*   Copyright 2013 Maarch
+*   Copyright 2013-2016 Maarch
 *
 *   This file is part of Maarch Framework.
 *
@@ -29,80 +29,14 @@
 * @ingroup notes
 */
 
+require_once 'modules/notes/class/notes_controler_Abstract.php';
+
 /**
 * @brief  Controler of the note Object
 *
 * @ingroup notes
 */
-class notes_controler
+class notes_controler extends notes_controler_Abstract
 {
-    #####################################
-    ## add note on a resource
-    #####################################
-    public function addNote($resId, $collId, $noteContent)
-    {
-        $status = 'ok';
-        $error = '';
-        //control parameters
-        if (isset($resId) && empty($resId)) {
-            $status = 'ko';
-            $error = 'resId empty ';
-        }
-        if (isset($collId) && empty($collId)) {
-            $status = 'ko';
-            $error = 'collId empty ';
-        }
-        if (isset($noteContent) && empty($noteContent)) {
-            $status = 'ko';
-            $error .= 'noteContent empty ';
-        }
-        //process
-        if ($status == 'ok') {
-            require_once 'core/class/class_security.php';
-            require_once 'modules/notes/notes_tables.php';
-            $security = new security();
-            $view = $security->retrieve_view_from_coll_id($collId);
-            $table = $security->retrieve_table_from_coll($collId);
-            $db = new Database();
-            $query = "SELECT res_id FROM " . $view . " WHERE res_id = ?";
-            $stmt = $db->query($query, array($resId));
-            if ($stmt->rowCount() == 0) {
-                $status = 'ko';
-                $error .= 'resId not exists';
-            } else {
-                $query =
-                    "INSERT INTO " . NOTES_TABLE . "(identifier, note_text, "
-                    . "date_note, user_id, coll_id, tablename) values"
-                    . " (?, ?, CURRENT_TIMESTAMP, ?, ?, ?)";
-                    
-                    $stmt = $db->query($query, array($resId, $noteContent, $_SESSION['user']['UserId'], $collId, $table));
-
-                    $hist = new history();
-                    $stmt = $db->query(
-                        "SELECT id FROM " . NOTES_TABLE . " WHERE "
-                        . "identifier = ? and user_id = ? and coll_id = ? order by id desc",
-                        array($resId, $_SESSION['user']['UserId'], $collId)
-                    );
-                    $res = $stmt->fetchObject();
-                    $id = $res->id;
-                    $hist->add(
-                        $view, $resId, 'UP', 'resup', _ADDITION_NOTE
-                        . _ON_DOC_NUM . $resId . ' (' . $id . ') ' . _FROM_WS,
-                        $_SESSION['config']['databasetype'], 'notes'
-                    );
-                    $hist->add(
-                        NOTES_TABLE, $id, 'ADD', 'noteadd', _NOTES_ADDED
-                        . ' (' . $id . ') ' . _FROM_WS,
-                        $_SESSION['config']['databasetype'], 'notes'
-                    );
-
-            }
-        }
-        $returnArray = array(
-            'status' => $status,
-            'value' => $id,
-            'error' => $error,
-        );
-        return $returnArray;
-    }
+    // custom
 }
diff --git a/notes/trunk/class/notes_controler_Abstract.php b/notes/trunk/class/notes_controler_Abstract.php
new file mode 100755
index 0000000000000000000000000000000000000000..e82e74d4dc49f4c4d1b77ed110f7e80643ddf53f
--- /dev/null
+++ b/notes/trunk/class/notes_controler_Abstract.php
@@ -0,0 +1,108 @@
+<?php
+/*
+*   Copyright 2013-2016 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework 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.
+*
+*   Maarch Framework 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 Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+* @brief  Contains the controler of the note Object
+*
+*
+* @file
+* @author Laurent Giovannoni <dev@maarch.org>
+* @date $date$
+* @version $Revision$
+* @ingroup notes
+*/
+
+/**
+* @brief  Controler of the note Object
+*
+* @ingroup notes
+*/
+abstract class notes_controler_Abstract
+{
+    #####################################
+    ## add note on a resource
+    #####################################
+    public function addNote($resId, $collId, $noteContent)
+    {
+        $status = 'ok';
+        $error = '';
+        //control parameters
+        if (isset($resId) && empty($resId)) {
+            $status = 'ko';
+            $error = 'resId empty ';
+        }
+        if (isset($collId) && empty($collId)) {
+            $status = 'ko';
+            $error = 'collId empty ';
+        }
+        if (isset($noteContent) && empty($noteContent)) {
+            $status = 'ko';
+            $error .= 'noteContent empty ';
+        }
+        //process
+        if ($status == 'ok') {
+            require_once 'core/class/class_security.php';
+            require_once 'modules/notes/notes_tables.php';
+            $security = new security();
+            $view = $security->retrieve_view_from_coll_id($collId);
+            $table = $security->retrieve_table_from_coll($collId);
+            $db = new Database();
+            $query = "SELECT res_id FROM " . $view . " WHERE res_id = ?";
+            $stmt = $db->query($query, array($resId));
+            if ($stmt->rowCount() == 0) {
+                $status = 'ko';
+                $error .= 'resId not exists';
+            } else {
+                $query =
+                    "INSERT INTO " . NOTES_TABLE . "(identifier, note_text, "
+                    . "date_note, user_id, coll_id, tablename) values"
+                    . " (?, ?, CURRENT_TIMESTAMP, ?, ?, ?)";
+                    
+                    $stmt = $db->query($query, array($resId, $noteContent, $_SESSION['user']['UserId'], $collId, $table));
+
+                    $hist = new history();
+                    $stmt = $db->query(
+                        "SELECT id FROM " . NOTES_TABLE . " WHERE "
+                        . "identifier = ? and user_id = ? and coll_id = ? order by id desc",
+                        array($resId, $_SESSION['user']['UserId'], $collId)
+                    );
+                    $res = $stmt->fetchObject();
+                    $id = $res->id;
+                    $hist->add(
+                        $view, $resId, 'UP', 'resup', _ADDITION_NOTE
+                        . _ON_DOC_NUM . $resId . ' (' . $id . ') ' . _FROM_WS,
+                        $_SESSION['config']['databasetype'], 'notes'
+                    );
+                    $hist->add(
+                        NOTES_TABLE, $id, 'ADD', 'noteadd', _NOTES_ADDED
+                        . ' (' . $id . ') ' . _FROM_WS,
+                        $_SESSION['config']['databasetype'], 'notes'
+                    );
+
+            }
+        }
+        $returnArray = array(
+            'status' => $status,
+            'value' => $id,
+            'error' => $error,
+        );
+        return $returnArray;
+    }
+}