From 6ff33a74c4b1669c435fdf5a8b5ee7432c8993bf Mon Sep 17 00:00:00 2001
From: Yves Christian Kpakpo <yveschristian.kpakpo@maarch.org>
Date: Mon, 25 Feb 2013 04:19:00 +0000
Subject: [PATCH] Evol: notes list and form in ajax mode

---
 notes/trunk/class/class_modules_tools.php |   2 +-
 notes/trunk/frame_notes_folder.php        |  75 ----
 notes/trunk/img/modif_note_small.gif      | Bin 0 -> 572 bytes
 notes/trunk/js/function.js                |   0
 notes/trunk/js/functions.js               |  48 +++
 notes/trunk/lang/en.php                   |   2 +
 notes/trunk/lang/fr.php                   |   2 +
 notes/trunk/notes.php                     | 279 +++++++++++++
 notes/trunk/notes_ajax_content.php        | 458 ++++++++++++++++++++++
 notes/trunk/notes_doc.php                 |  33 --
 notes/trunk/notes_list.php                |  78 ++--
 11 files changed, 844 insertions(+), 133 deletions(-)
 delete mode 100644 notes/trunk/frame_notes_folder.php
 create mode 100644 notes/trunk/img/modif_note_small.gif
 delete mode 100644 notes/trunk/js/function.js
 create mode 100644 notes/trunk/js/functions.js
 create mode 100644 notes/trunk/notes.php
 create mode 100644 notes/trunk/notes_ajax_content.php
 delete mode 100644 notes/trunk/notes_doc.php

diff --git a/notes/trunk/class/class_modules_tools.php b/notes/trunk/class/class_modules_tools.php
index 1558f0f594b..1963241f7a4 100644
--- a/notes/trunk/class/class_modules_tools.php
+++ b/notes/trunk/class/class_modules_tools.php
@@ -205,7 +205,7 @@ class notes extends dbquery
                             . " where identifier = " . $id 
                             . " and coll_id ='"
                             . $coll_id . "' order by date_note desc");
-         
+        // $dbId->show(); 
        while ($res = $dbId->fetch_object())
        {
            $dbNotesEntities = new dbquery();
diff --git a/notes/trunk/frame_notes_folder.php b/notes/trunk/frame_notes_folder.php
deleted file mode 100644
index e0142b39222..00000000000
--- a/notes/trunk/frame_notes_folder.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/*
-*
-*    Copyright 2008,2012 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    Folder frame notes
-*
-* @file     frame_notes_folder.php
-* @author   Yves Christian Kpakpo <dev@maarch.org>
-* @date     $date$
-* @version  $Revision$
-* @ingroup  folder
-*/
-
-require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php";
-require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
-            ."class".DIRECTORY_SEPARATOR."class_lists.php";
-            
-$core_tools = new core_tools();
-$request    = new request();
-$list       = new lists();
-
-//
-$core_tools->load_lang();
-$core_tools->load_html();
-$core_tools->load_header('', true, false);
-
-$body = "";
-$extendUrl = "&size=full";
-if (!isset($_REQUEST['size']) || $_REQUEST['size'] <> "full") {
-	$body = 'id="iframe"';
-    $extendUrl = "";
-}
-
-if (!isset($_REQUEST['coll_id']) && !empty($_REQUEST['coll_id'])) {
-    $extendUrl = "&coll_id=".$_REQUEST['coll_id'];
-}
-
-?>
-<body <?php echo $body; ?>>
-<h2><?php echo _NOTES;?></h2>
-<?php
-$core_tools->load_js();
-
-//Load list
-if (isset($_SESSION['current_folder_id']) 
-	&& ! empty($_SESSION['current_folder_id'])
-) {
-    $target = $_SESSION['config']['businessappurl']
-        .'index.php?module=notes&page=notes_list&id='
-        .$_SESSION['current_folder_id'].$extendUrl;
-    
-    $listContent = $list->loadList($target);
-    echo $listContent;
-}
-?>
-</body>
-</html>
\ No newline at end of file
diff --git a/notes/trunk/img/modif_note_small.gif b/notes/trunk/img/modif_note_small.gif
new file mode 100644
index 0000000000000000000000000000000000000000..a2b8210e083364eab0e6016e0bc0d5aa693c9ed5
GIT binary patch
literal 572
zcmZ?wbhEHb6lD-)c*el+@87>afB*gZ^Y_Q^zh8d-{`}+jhi^Y#fBo_D^Y`bUzd!r<
z{rShQ&)$E0`r*ry4`1)U|9b!3mq%|u-gx`<{+kci-+sOE`qRx9@Ap4?zwhC@&3E4H
zz5a0B*_$&iJe_jx@#M3QC!Gb7PbQpw+<W>_&*?{9ryg~lc+hp?UdQo!4M&0Ke*Mw=
zGxndYIeM@5$i1q=cPkFxtvYnK{Lr1ULw8CK-kGrLWZ{83B?s;l?Y~{H|91YqTbX-q
zX6?C|x%+0u?i<$2&RQ)yt2+0%;_Ty!bB-y_KBh4HxWepXa<h)g%seVP^Qbfs%{VFr
zLPsQK91)v-SZvx6k!eTxryLTPa>${5!T<mN83r0C{$ycfX9!`?0XYN|Ck*T}8$z0z
zTUtZ-MH$<=TO|}ldM1j?DrpHZPi$4zl~GcX7ns>>>}Rj3pdiV<C`8}U*VoQKVoivZ
ztM^WC<*hdE`}Z4d)pI*~)NreX;{g}5t+pNq+-<j7UvkplYUz2&e5;|e&m$kxtr|fd
zFCDDcFmS2)1n$?_8p6S+?h#=8l|}Hss>hYZn+`fPvvIPmo3UtN!=gqL9u5f$4FLvg
E067iw<p2Nx

literal 0
HcmV?d00001

diff --git a/notes/trunk/js/function.js b/notes/trunk/js/function.js
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/notes/trunk/js/functions.js b/notes/trunk/js/functions.js
new file mode 100644
index 00000000000..ba205129ded
--- /dev/null
+++ b/notes/trunk/js/functions.js
@@ -0,0 +1,48 @@
+function showNotesForm(path, width, height) {
+    
+    if(typeof(width)==='undefined'){
+        var width = '800';
+    }
+    
+    if(typeof(height)==='undefined'){
+        var height = '480';
+    }  
+    
+    new Ajax.Request(path,
+    {
+        method:'post',
+        parameters: { url : path
+                    },  
+        onSuccess: function(answer) {
+            eval("response = "+answer.responseText);
+           
+            if(response.status == 0){
+             
+                var modal_content = response.content;
+                createModal(modal_content, 'form_notes', height, width); 
+            } else {
+                window.top.$('main_error').innerHTML = response.error;
+            }
+        }
+    });
+}
+
+function validNotesForm (path, form_id) {
+
+    new Ajax.Request(path,
+    {
+        asynchronous:false,
+        method:'post',
+        parameters: Form.serialize(form_id),
+        encoding: 'UTF-8',                       
+        onSuccess: function(answer){
+            eval("response = "+answer.responseText);
+            if(response.status == 0){
+                destroyModal('form_notes'); 
+                eval(response.exec_js);
+            } else {
+                alert(response.error);
+            }
+        }
+    });
+}
\ No newline at end of file
diff --git a/notes/trunk/lang/en.php b/notes/trunk/lang/en.php
index 498cf855391..1c00050c66a 100644
--- a/notes/trunk/lang/en.php
+++ b/notes/trunk/lang/en.php
@@ -39,6 +39,8 @@ if (!defined('_NOTES_COMMENT'))
     define('_NOTES_COMMENT', 'Notes');
 if (!defined('_OF'))
     define('_OF', 'of');
+if (!defined('_NOTE_DONT_EXIST'))
+    define('_NOTE_DONT_EXIST', 'This note dont exists');
 if (!defined('_THIS_NOTE_IS_VISIBLE_BY'))
     define('_THIS_NOTE_IS_VISIBLE_BY', 'This note is visible by');
 
diff --git a/notes/trunk/lang/fr.php b/notes/trunk/lang/fr.php
index 1d45fad2e8e..7a60bf483d0 100644
--- a/notes/trunk/lang/fr.php
+++ b/notes/trunk/lang/fr.php
@@ -39,5 +39,7 @@ if (!defined('_NOTES_COMMENT'))
     define('_NOTES_COMMENT', 'Notes');
 if (!defined('_OF'))
     define('_OF', 'de');
+if (!defined('_NOTE_DONT_EXIST'))
+    define('_NOTE_DONT_EXIST', 'Cette note n\'existe pas');
 if (!defined('_THIS_NOTE_IS_VISIBLE_BY'))
     define('_THIS_NOTE_IS_VISIBLE_BY', 'Restreindre cette note aux entit&eacute;s suivantes (si vide alors la note est publique)');
diff --git a/notes/trunk/notes.php b/notes/trunk/notes.php
new file mode 100644
index 00000000000..233477cc2ce
--- /dev/null
+++ b/notes/trunk/notes.php
@@ -0,0 +1,279 @@
+<?php
+/*
+*
+*    Copyright 2008,2012 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    Notes
+*
+* @file     notes.php
+* @author   Yves Christian Kpakpo <dev@maarch.org>
+* @date     $date$
+* @version  $Revision$
+* @ingroup  notes
+*/
+
+require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php";
+require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
+            ."class".DIRECTORY_SEPARATOR."class_lists.php";
+require_once "modules".DIRECTORY_SEPARATOR."notes".DIRECTORY_SEPARATOR."notes_tables.php";
+
+$core_tools = new core_tools();
+$request    = new request();
+$list       = new lists();   
+
+$identifier = '';
+$origin = '';
+$parameters = '';
+
+//Collection ID
+if(isset($_REQUEST['coll_id']) && !empty($_REQUEST['coll_id'])) $parameters = "&coll_id=".$_REQUEST['coll_id'];
+
+//Identifier
+if (isset($_REQUEST['identifier']) && !empty($_REQUEST['identifier'])) $identifier = $_REQUEST['identifier'];
+
+//Origin
+if (isset($_REQUEST['origin']) && !empty($_REQUEST['origin'])) $origin = $_REQUEST['origin'];
+ 
+//Extra parameters
+if (isset($_REQUEST['size']) && !empty($_REQUEST['size'])) $parameters .= '&size='.$_REQUEST['size'];
+if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) $parameters .= '&order='.$_REQUEST['order'];
+if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) $parameters .= '&order_field='.$_REQUEST['order_field'];
+if (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) $parameters .= '&what='.$_REQUEST['what'];
+if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $parameters .= '&start='.$_REQUEST['start'];
+
+ if (isset($_REQUEST['load'])) {
+    $core_tools->load_html();
+    $core_tools->load_header('', true, false);
+    ?>
+    <body id="iframe">
+    <div id="container">
+    <h2><?php echo _NOTES;?></h2>
+    <?php
+    $core_tools->load_js();
+
+    //Load list
+    if (!empty($identifier) && !empty($origin)) {
+    
+        $target = $_SESSION['config']['businessappurl']
+            .'index.php?module=notes&page=notes&identifier='
+            .$identifier.'&origin='.$origin.$parameters;
+        
+        $listContent = $list->loadList($target);
+        echo $listContent;
+    } else {
+        echo '<span class="error">'._ERROR_IN_PARAMETERS.'</span>';
+    }
+    ?>
+    </div>
+    </body>
+    </html>
+    <?php
+} else {
+    //If size is full change some parameters
+    if (isset($_REQUEST['size']) 
+        && ($_REQUEST['size'] == "full")
+    ) {
+        $sizeSmall = "15";
+        $sizeFull = "30";
+        $css = "listing spec";
+        $cutString = 100;
+    } else {
+        $sizeSmall = "10";
+        $sizeFull = "10";
+        $css = "listingsmall";
+        $cutString = 20;
+    }
+    
+    //Table or view
+        $select[NOTES_TABLE] = array(); //Notes
+        $select[USERS_TABLE] = array(); //Users
+        
+    //Fields
+        array_push($select[NOTES_TABLE], "id", "identifier", "date_note", "user_id", "note_text", "note_text as note_short", "coll_id");    //Notes
+        array_push($select[USERS_TABLE], "user_id", "firstname", "lastname");           //Users
+        
+    //Where clause
+        $where_tab = array();
+        //
+        $where_tab[] = " identifier = " . $identifier . " ";
+        //From filters
+        $filterClause = $list->getFilters(); 
+        if (!empty($filterClause)) $where_tab[] = $filterClause;//Filter clause
+        //Build where
+        $where = implode(' and ', $where_tab);
+    
+    //Order
+        $order = $order_field = '';
+        $order = $list->getOrder();
+        $order_field = $list->getOrderField();
+        if (!empty($order_field) && !empty($order)) 
+            $orderstr = "order by ".$order_field." ".$order;
+        else  {
+            $list->setOrder();
+            $list->setOrderField('date_note');
+            $orderstr = "order by date_note desc";
+        }
+    
+    //Request
+        $tab=$request->select(
+            $select, $where, $orderstr,
+            $_SESSION['config']['databasetype'], "500", true, NOTES_TABLE, USERS_TABLE,
+            "user_id"
+        );
+        // $request->show();
+        
+    //Result Array
+        for ($i=0;$i<count($tab);$i++)
+        {
+            for ($j=0;$j<count($tab[$i]);$j++)
+            {
+                foreach(array_keys($tab[$i][$j]) as $value)
+                {
+                    if($tab[$i][$j][$value]=="id")
+                    {
+                        $tab[$i][$j]["id"]=$tab[$i][$j]['value'];
+                        $tab[$i][$j]["label"]='ID';
+                        $tab[$i][$j]["size"]="1";
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=true;
+                        $tab[$i][$j]["order"]='id';
+                    }
+                    if($tab[$i][$j][$value]=="date_note")
+                    {
+                        $tab[$i][$j]["value"]=$request->dateformat($tab[$i][$j]["value"]);
+                        $tab[$i][$j]["label"]=_DATE;
+                        $tab[$i][$j]["size"]="5";
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=true;
+                        $tab[$i][$j]["order"]='date_note';
+                    }
+                    if($tab[$i][$j][$value]=="user_id")
+                    {
+                        $tab[$i][$j]["label"]=_USER_ID;
+                        $tab[$i][$j]["size"]="5";
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=false;
+                        $tab[$i][$j]["order"]='user_id';
+                    }
+                    if($tab[$i][$j][$value]=="firstname")
+                    {
+                        $firstname =  $request->show_string($tab[$i][$j]["value"]);
+                    }
+                    if($tab[$i][$j][$value]=="lastname")
+                    {
+                        $tab[$i][$j]["value"] = $request->show_string($tab[$i][$j]["value"]). ' ' .$firstname ;
+                        $tab[$i][$j]["label"]=_USER;
+                        $tab[$i][$j]["size"]="20";
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=true;
+                        $tab[$i][$j]["order"]='lastname';
+                    }
+                    if($tab[$i][$j][$value]=="note_short")
+                    {
+                        $tab[$i][$j]["value"] = $request->cut_string( $request->show_string($tab[$i][$j]["value"]), $cutString);
+                        $tab[$i][$j]["label"]=_NOTES;
+                        $tab[$i][$j]["size"]=$sizeFull;
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=true;
+                        $tab[$i][$j]["order"]='note_short';
+                    }
+                    if($tab[$i][$j][$value]=="note_text")
+                    {
+                        $tab[$i][$j]["value"] = $request->show_string($tab[$i][$j]["value"]);
+                        $tab[$i][$j]["label"]=_NOTES;
+                        $tab[$i][$j]["size"]=$sizeFull;
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=false;
+                        $tab[$i][$j]["order"]='note_text';
+                    }
+                }
+            }
+        }
+        
+        //List
+        $listKey = 'id';                                                                    //Clé de la liste
+        $paramsTab = array();                                                               //Initialiser le tableau de paramètres
+        $paramsTab['bool_sortColumn'] = true;                                               //Affichage Tri
+        $paramsTab['pageTitle'] ='';                                                        //Titre de la page
+        $paramsTab['bool_bigPageTitle'] = false;                                            //Affichage du titre en grand
+        $paramsTab['urlParameters'] = 'identifier='.$identifier
+                ."&origin=".$origin.'&display=true'.$parameters;                            //Parametres d'url supplementaires
+        $paramsTab['filters'] = array('user');                                              //Filtres    
+        $paramsTab['listHeight'] = '540px';                                                 //Hauteur de la liste
+        // $paramsTab['bool_showSmallToolbar'] = true;                                         //Mini barre d'outils
+        $paramsTab['linesToShow'] = 15;                                                     //Nombre de ligne a afficher
+        $paramsTab['listCss'] = $css;                                                       //CSS
+        $paramsTab['tools'] = array();                                                      //Icones dans la barre d'outils
+          
+        $add = array(
+                "script"        =>  "showNotesForm('".$_SESSION['config']['businessappurl']  
+                                        . "index.php?display=true&module=notes&page=notes_ajax_content"
+                                        . "&mode=add&identifier=".$identifier."&origin=".$origin
+                                        . $parameters."')",
+                "icon"          =>  $_SESSION['config']['businessappurl']."static.php?filename=tool_note.gif&module=notes",
+                "tooltip"       =>  _ADD_NOTE,
+                "alwaysVisible" =>  true
+                );
+        array_push($paramsTab['tools'],$add);   
+        
+        //Action icons array
+        $paramsTab['actionIcons'] = array();
+        $preview = array(
+                    "type"          =>  "preview",
+                    "class"         =>  "preview",
+                    "icon"          =>  $_SESSION['config']['businessappurl']."static.php?filename=showFrameAdminList.png",
+                    "tooltip"       =>  _NOTES,
+                    "content"      =>  "{'identifierDetailFrame' : '@@id@@', '"._DATE." ' : '@@date_note@@', '"._USER." ' : '@@lastname@@', '"._NOTES." ' : '@@note_text@@'}"
+                );
+        array_push($paramsTab['actionIcons'], $preview);        
+        
+        $read = array(
+            "script"        => "showNotesForm('".$_SESSION['config']['businessappurl']
+                                    ."index.php?display=true&module=notes&page=notes_ajax_content"
+                                    ."&mode=up&id=@@id@@&identifier=".$identifier."&origin=".$origin
+                                    . $parameters."');",
+            "class"         =>  "read",
+            "icon"          =>  $_SESSION['config']['businessappurl']."static.php?module=notes&filename=modif_note_small.gif",
+            // "label"         =>  _UPDATE.'/'._DELETE,
+            "tooltip"       =>  _UPDATE.'/'._DELETION,
+            "disabledRules" => "@@user_id@@ != '".$_SESSION['user']['UserId']."'"
+            );
+        array_push($paramsTab['actionIcons'], $read);     
+         
+        //Output
+        $status = 0;
+        $content = $list->showList($tab, $paramsTab, $listKey);
+        // $debug = $list->debug();
+
+    echo "{status : " . $status . ", content : '" . addslashes($debug.$content) . "', error : '" . addslashes($error) . "'}";
+}
+
diff --git a/notes/trunk/notes_ajax_content.php b/notes/trunk/notes_ajax_content.php
new file mode 100644
index 00000000000..b2b151c53ff
--- /dev/null
+++ b/notes/trunk/notes_ajax_content.php
@@ -0,0 +1,458 @@
+<?php
+/*
+*
+*    Copyright 2012 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    Script to return ajax result
+*
+* @file     notes_ajax_content.php
+* @author   Yves Christian Kpakpo <dev@maarch.org>
+* @date     $date$
+* @version  $Revision$
+* @ingroup  notes
+*/
+
+require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php";
+require_once "modules".DIRECTORY_SEPARATOR."entities"
+        .DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."EntityControler.php";
+require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
+        ."class".DIRECTORY_SEPARATOR."class_lists.php";
+require_once 'modules/notes/notes_tables.php';
+require_once "modules" . DIRECTORY_SEPARATOR . "notes" . DIRECTORY_SEPARATOR
+    . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php";
+    
+$core_tools = new core_tools();
+$request    = new request();
+$sec        = new security();
+$ent        = new EntityControler();
+$notesTools = new notes();
+$list       = new lists();
+
+$core_tools->load_lang();
+$request->connect();
+
+$status = 0;
+$error = $content = $js = $parameters = '';
+
+$labels_array = array();
+
+if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) {
+    $mode = $_REQUEST['mode'];
+} else {
+    $error = _ERROR_IN_NOTES_FORM_GENERATION;
+    $status = 1;
+}
+
+//Identifier of the element wich is noted
+$identifier = '';
+if (isset($_REQUEST['identifier']) && ! empty($_REQUEST['identifier'])) {
+    $identifier = trim($_REQUEST['identifier']);
+}
+
+//Collection
+if (isset($_REQUEST['coll_id']) && ! empty($_REQUEST['coll_id'])) {
+    $collId = trim($_REQUEST['coll_id']);
+    $parameters .= '&coll_id='.$_REQUEST['coll_id'];
+    $view = $sec->retrieve_view_from_coll_id($collId);
+    $table = $sec->retrieve_table_from_coll($collId);
+}
+
+//Keep some origin parameters
+if (isset($_REQUEST['size']) && !empty($_REQUEST['size'])) $parameters .= '&size='.$_REQUEST['size'];
+if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
+    $parameters .= '&order='.$_REQUEST['order'];
+    if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) $parameters .= '&order_field='.$_REQUEST['order_field'];
+}
+if (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) $parameters .= '&what='.$_REQUEST['what'];
+if (isset($_REQUEST['template']) && !empty($_REQUEST['template'])) $parameters .= '&template='.$_REQUEST['template'];
+if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $parameters .= '&start='.$_REQUEST['start'];
+
+//Keep the origin to reload the origin list
+$list_origin = $origin = '';
+if (isset($_REQUEST['origin']) && !empty($_REQUEST['origin'])) {
+    //
+    $origin = $_REQUEST['origin'];
+
+    if ($_REQUEST['origin'] == "document") {
+        //From document
+        $list_origin = "loadList('".$_SESSION['config']['businessappurl']
+                ."index.php?display=true&module=notes&page=notes&identifier="
+                .$identifier."&origin=document".$parameters."', 'divList', true);";
+    } elseif ($_REQUEST['origin'] == "folder") {
+        
+        //From folders
+        $collId = 'folders';
+        $table = $_SESSION['tablename']['fold_folders'];
+        $list_origin = "loadList('".$_SESSION['config']['businessappurl']
+                    ."index.php?display=true&module=notes&page=notes&identifier="
+                    .$identifier."&origin=folder".$parameters."', 'divList', true);";
+    }
+}
+
+//Path to actual script
+$path_to_script = $_SESSION['config']['businessappurl']
+            ."index.php?display=true&module=notes&page=notes_ajax_content&identifier="
+            .$identifier."&origin=".$origin.$parameters;
+
+switch ($mode) {
+    case 'add':
+        if (empty($identifier)) {
+            $error = $request->wash_html(_IDENTIFIER.' '._IS_EMPTY.'!','NONE');
+            $status = 1;
+        } else {
+            $entitiesList = array();
+            $entitiesList = $ent->getAllEntities();
+            $content .= '<div class="block">';
+            $content .= '<form name="formNotes" id="formNotes" method="post" action="#">';
+            $content .= '<input type="hidden" value="'.$identifier.'" name="identifier" id="identifier">';
+            $content .= '<h2>'._ADD_NOTE.'</h2>';
+            $content .= '<textarea style="width:500px" cols="70" rows="10"  name="notes"  id="notes" ></textarea>';
+            $content .= '<h3 class="sstit">'._THIS_NOTE_IS_VISIBLE_BY.'</h3>';
+            $content .= '<table align="center" width="100%" id="template_entities">';
+            $content .= '<tr><td width="20%" align="center">';
+            $content .= '<select name="entitieslist[]" id="entitieslist" size="7" style="width: 206px" ';
+            $content .= 'ondblclick=\'moveclick($(entitieslist), $(entities_chosen));\' multiple="multiple">';
+            for ($i=0;$i<count($entitiesList);$i++) {
+                $state_entity = false;
+                if ($state_entity == false) {
+                    $content .= '<option value="'
+                        .$entitiesList[$i]->entity_id.'" alt="'
+                        .$entitiesList[$i]->short_label.'" title="'
+                        .$entitiesList[$i]->short_label.'">'
+                        .$entitiesList[$i]->short_label.'</option>';
+                }
+            }
+            $content .= '</select><br/> </td>';
+            $content .= '<td width="20%" align="center">';
+            $content .= '<input type="button" class="button" value="'._ADD.' &gt;&gt;" onclick=\'Move($(entitieslist), $(entities_chosen));\' />';
+            $content .= '<br /><br />';
+            $content .= '<input type="button" class="button" value="&lt;&lt; '._REMOVE.'" onclick=\'Move($(entities_chosen), $(entitieslist));\' />';
+            $content .= '</td>';
+            $content .= '<td width="30%" align="center">';
+            $content .= '<select name="entities_chosen[]" id="entities_chosen" size="7" style="width: 206px" ';
+            $content .= 'ondblclick=\'moveclick($(entities_chosen), $(entitieslist));\' multiple="multiple">';
+            for ($i=0;$i<count($entitiesList);$i++) {
+               $state_entity = false;
+               if ($state_entity == true) {
+                    $content .= '<option value="'
+                        .$entitiesList[$i]->entity_id.'" alt="'
+                        .$entitiesList[$i]->short_label.'" title="'
+                        .$entitiesList[$i]->short_label.'" selected="selected">'
+                        .$entitiesList[$i]->short_label.'</option>';
+               }
+            }
+            $content .= '</select></td>';
+            $content .= '</tr></table>';
+            // Buttons
+            $content .='<hr />';
+            $content .='<div align="center">';
+            $content .=' <input type="button" name="valid" value="&nbsp;'._ADD_NOTE
+                        .'&nbsp;" id="valid" class="button" onclick="'
+                        .'selectall($(\'entities_chosen\'));validNotesForm(\''
+                        .$path_to_script.'&mode=added\', \'formNotes\');" />&nbsp;';
+            $content .='<input type="button" name="cancel" id="cancel" class="button" value="'
+                        ._CANCEL.'" onclick="destroyModal(\'form_notes\');"/>';
+            $content .='</div">';
+            $content .= '</form>';
+            $content .= '</div>';
+        }
+    break;
+    case 'added':
+        if (strlen(trim($_REQUEST['notes'])) > 0) {
+            //Identifier?
+            if (empty($identifier)) {
+                $error = $request->wash_html(_IDENTIFIER.' '._IS_EMPTY.'!','NONE');
+                $status = 1;
+            } else {
+                
+                //Add notes
+                $notes = $request->protect_string_db($_REQUEST['notes']);
+                $date = $request->current_datetime();
+                $userId = $request->protect_string_db($_SESSION['user']['UserId']);
+                $collId = $request->protect_string_db($collId);
+                $table = $request->protect_string_db($table);
+
+                $request->query(
+                    "INSERT INTO " . NOTES_TABLE . "(identifier, note_text, date_note, "
+                    . "user_id, coll_id, tablename) VALUES ("
+                    . $identifier . ", '" . $notes. "', " . $date . ", '"
+                    . $userId . "', '".$collId . "', '".$table . "')"
+                );
+                
+                //Last insert ID from sequence
+                $id = $request->last_insert_id('notes_seq');
+                
+                //Entities selected
+                if (!empty($id) && isset($_REQUEST['entities_chosen']) && !empty($_REQUEST['entities_chosen']))
+                {
+                    for ($i=0; $i<count($_REQUEST['entities_chosen']); $i++) 
+                    {  
+                        $request->query(
+                            "INSERT INTO " . NOTE_ENTITIES_TABLE . "(note_id, item_id) VALUES"
+                            . " (".$id . ", '"
+                            . $request->protect_string_db($_REQUEST['entities_chosen'][$i])."')"
+                        );
+                    }
+                }
+                
+                //History
+                if ($_SESSION['history']['noteadd']) {
+                    $hist = new history();
+                    if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "folder") {
+                        $hist->add(
+                            $table, $identifier, "UP", 'folderup', _ADDITION_NOTE . _ON_FOLDER_NUM
+                            . $identifier . ' (' . $id . ') : "' . $request->cut_string($notes, 254) .'"',
+                            $_SESSION['config']['databasetype'], 'notes'
+                        );
+                    } else if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "document") {
+                        $hist->add(
+                            $view, $identifier, "UP", 'resup',  _ADDITION_NOTE . _ON_DOC_NUM
+                            . $identifier . ' (' . $id . ') ',
+                            $_SESSION['config']['databasetype'], 'notes'
+                        );
+                    }
+
+                    $hist->add(
+                        NOTES_TABLE, $id, "ADD", 'noteadd', _NOTES_ADDED . ' (' . $id . ')',
+                        $_SESSION['config']['databasetype'], 'notes'
+                    );
+                }
+                
+                //Reload and show message
+                $js =  $list_origin."window.top.$('main_info').innerHTML = '"._NOTES_ADDED."';"; 
+            }
+        } else {
+            $error = $request->wash_html(_NOTES.' '._IS_EMPTY.'!','NONE');
+            $status = 1;
+        }
+    break;
+    case 'up':
+        if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
+            
+            $id = $_REQUEST['id'];
+            //Check if ID exists
+            $where = "";
+            if (!empty($collId)) {
+                $where .= " and coll_id = '" . $collId . "'";
+            }
+            if (!empty($table)) {
+                $where .= " and tablename = '" . $table . "'";
+            }
+            $request->query(
+                "select n.identifier, n.date_note, n.user_id, n.note_text, u.lastname, "
+                . "u.firstname from " . NOTES_TABLE . " n inner join ". USERS_TABLE
+                . " u on n.user_id  = u.user_id where n.id = " . $id . " " . $where
+                // . " and user_id = '".$request->protect_string_db($_SESSION['user']['UserId'])."' " . $where
+            );
+            // $request->show();
+            
+            if($request->nb_result() > 0) {
+                
+                $line = $request->fetch_object();
+                
+                $user = $request->show_string($line->lastname . " " . $line->firstname);
+                $notes = $request->show_string($line->note_text);
+                $userId = $line->user_id;
+                $date = $line->date_note;
+                $identifier = $line->identifier;
+    
+                $notesEntities = array();
+                $entitiesList = array();
+                $notesEntities = $notesTools->getNotesEntities($id);
+                $entitiesList = $ent->getAllEntities();
+                //Form
+                $content .= '<div class="block">';
+                $content .= '<form name="formNotes" id="formNotes" method="post" action="#">';
+                $content .= '<input type="hidden" value="'.$identifier.'" name="identifier" id="identifier">';
+                $content .= '<input type="hidden" value="'.$id.'" name="id" id="id">';
+                $content .= '<h2 class="sstit">'._NOTES . " " . _OF . " " . $user . " (" . $date . ")".'</h2>';
+                $content .= '<textarea style="width:500px" cols="70" rows="10"  name="notes"  id="notes">'.$notes.'</textarea>';
+                $content .= '<h3 class="sstit">'._THIS_NOTE_IS_VISIBLE_BY.'</h3>';
+                $content .= '<table align="center" width="100%" id="template_entities">';
+                $content .= '<tr><td width="20%" align="center">';
+                $content .= '<select name="entitieslist[]" id="entitieslist" size="7" style="width: 206px" ';
+                $content .= 'ondblclick=\'moveclick($(entitieslist), $(entities_chosen));\' multiple="multiple">';
+                for ($i=0;$i<count($entitiesList);$i++) {
+                    if (!in_array($entitiesList[$i], $notesEntities)) {
+                        $content .= '<option value="'
+                            .$entitiesList[$i]->entity_id.'" alt="'
+                            .$entitiesList[$i]->short_label.'" title="'
+                            .$entitiesList[$i]->short_label.'">'
+                            .$entitiesList[$i]->short_label.'</option>';
+                    }
+                }
+                $content .= '</select><br/> </td>';
+                $content .= '<td width="20%" align="center">';
+                $content .= '<input type="button" class="button" value="'._ADD.' &gt;&gt;" onclick=\'Move($(entitieslist), $(entities_chosen));\' />';
+                $content .= '<br /><br />';
+                $content .= '<input type="button" class="button" value="&lt;&lt; '._REMOVE.'" onclick=\'Move($(entities_chosen), $(entitieslist));\' />';
+                $content .= '</td>';
+                $content .= '<td width="30%" align="center">';
+                $content .= '<select name="entities_chosen[]" id="entities_chosen" size="7" style="width: 206px" ';
+                $content .= 'ondblclick=\'moveclick($(entities_chosen), $(entitieslist));\' multiple="multiple">';
+                for ($i=0;$i<count($notesEntities);$i++) {
+                    $content .= '<option value="'
+                        .$notesEntities[$i]->entity_id.'" alt="'
+                        .$notesEntities[$i]->short_label.'" title="'
+                        .$notesEntities[$i]->short_label.'" selected="selected">'
+                        .$notesEntities[$i]->short_label.'</option>';
+                }
+                $content .= '</select></td>';
+                $content .= '</tr></table>';
+                // Buttons
+                $content .='<hr />';
+                $content .='<div align="center">';
+                $content .=' <input type="button" name="valid" value="&nbsp;'._MODIFY
+                         .'&nbsp;" id="valid" class="button" onclick="'
+                         .'selectall($(\'entities_chosen\'));validNotesForm(\''
+                         .$path_to_script.'&mode=updated\', \'formNotes\');" />&nbsp;';
+                $content .=' <input type="button" name="valid" value="&nbsp;'._DELETE
+                         .'&nbsp;" id="valid" class="button" onclick="if(confirm(\''._REALLY_DELETE.': '
+                         .$request->cut_string($notes, 20).' ?\')) validNotesForm(\''
+                         .$path_to_script.'&mode=del\', \'formNotes\');" />&nbsp;';
+                $content .='<input type="button" name="cancel" id="cancel" class="button" value="'
+                    ._CANCEL.'" onclick="destroyModal(\'form_notes\');"/>';
+                $content .='</div">';
+                $content .= '</form>';
+                $content .= '</div>';
+            } else {
+                $error = $request->wash_html($id.': '._NOTE_DONT_EXIST.'!','NONE');
+                $status = 1;
+            }
+        
+        } else {
+            $error = $request->wash_html(_ID.' '._IS_EMPTY.'!','NONE');
+            $status = 1;
+        }
+    break;
+    case 'updated':
+        if (strlen(trim($_REQUEST['notes'])) > 0) {
+            //ID?
+            if (empty($_REQUEST['id'])) {
+                $error = $request->wash_html(_ID.' '._IS_EMPTY.'!','NONE');
+                $status = 1;
+            } else {
+                $id = $_REQUEST['id'];
+                //Identifier?
+                if (empty($identifier)) {
+                    $error = $request->wash_html(_IDENTIFIER.' '._IS_EMPTY.'!','NONE');
+                    $status = 1;
+                } else {
+                    
+                    //Update note
+                    $notes = $request->protect_string_db($_REQUEST['notes']);
+                    $date = $request->current_datetime();
+
+                    $request->query(
+                        "UPDATE ".NOTES_TABLE." SET note_text = '". addslashes($notes)
+                        . "', date_note = " . $date . " WHERE id = "
+                        . $id
+                    );
+                    
+                    //Entities selected
+                    $request->query(
+                            "DELETE FROM " . NOTE_ENTITIES_TABLE . " where note_id = " . $id
+                        );
+                    if (isset($_REQUEST['entities_chosen']) && !empty($_REQUEST['entities_chosen'])) {
+                    
+                        for ($i=0; $i<count($_REQUEST['entities_chosen']); $i++) 
+                        {  
+                            $request->query(
+                                "INSERT INTO " . NOTE_ENTITIES_TABLE . "(note_id, item_id) VALUES"
+                                . " (".$id . ", '"
+                                . $request->protect_string_db($_REQUEST['entities_chosen'][$i])."')"
+                            );
+                        }
+                    }
+                    
+                    //History
+                    if ($_SESSION['history']['noteup']) {
+                        $hist = new history();
+                        if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "folder") {
+                            $hist->add(
+                                $table, $identifier, "UP", 'folderup', _NOTE_UPDATED . _ON_FOLDER_NUM
+                                . $identifier . ' (' . $id . ') : "' . $request->cut_string($notes, 254) .'"',
+                                $_SESSION['config']['databasetype'], 'notes'
+                            );
+                        } else if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "document") {
+                            $hist->add(
+                                $view, $identifier, "UP", 'resup',  _NOTE_UPDATED . _ON_DOC_NUM
+                                . $identifier . ' (' . $id . ') ',
+                                $_SESSION['config']['databasetype'], 'notes'
+                            );
+                        }
+
+                        $hist->add(
+                            NOTES_TABLE, $id, "UP", 'noteup', _NOTE_UPDATED . ' (' . $id . ')',
+                            $_SESSION['config']['databasetype'], 'notes'
+                        );
+                    }
+                    
+                    //Reload and show message
+                    $js =  $list_origin."window.top.$('main_info').innerHTML = '"._NOTE_UPDATED."';"; 
+                }
+            }
+        } else {
+            $error = $request->wash_html(_NOTES.' '._IS_EMPTY.'!','NONE');
+            $status = 1;
+        }
+    break;
+    case 'del':
+        //ID?
+        if (empty($_REQUEST['id'])) {
+            $error = $request->wash_html(_ID.' '._IS_EMPTY.'!','NONE');
+            $status = 1;
+        } else {
+            $id = $_REQUEST['id'];
+            
+            $request->query("delete from " . NOTE_ENTITIES_TABLE . " where note_id = " . $id);
+            $request->query("delete from " . NOTES_TABLE . " where id = " . $id);
+
+            if ($_SESSION['history']['notedel']) {
+                $hist = new history();
+                $hist->add(
+                    NOTES_TABLE, $id, "DEL", 'notedel', _NOTES_DELETED . ' (' . $id . ')',
+                    $_SESSION['config']['databasetype'], 'notes'
+                );
+                if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "folder") {
+                    $hist->add(
+                        $table, $identifier, "DEL", 'folderup', _NOTES_DELETED . _ON_FOLDER_NUM
+                        . $identifier . ' (' . $id . ')',
+                        $_SESSION['config']['databasetype'], 'notes'
+                    );
+                } else if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "document") {
+                    $hist->add(
+                        $view, $identifier, "DEL", 'notedel',  _NOTES_DELETED . _ON_DOC_NUM
+                        . $identifier . ' (' . $id . ')',
+                        $_SESSION['config']['databasetype'], 'notes'
+                    );
+                }
+            }
+            
+            //Reload and show message
+            $js =  $list_origin."window.top.$('main_info').innerHTML = '"._NOTES_DELETED."';"; 
+        }
+    break;
+}
+
+echo "{status : " . $status . ", content : '" . addslashes($debug.$content) . "', error : '" . addslashes($error) . "', exec_js : '".addslashes($js)."'}";
+exit ();
+?>
+
diff --git a/notes/trunk/notes_doc.php b/notes/trunk/notes_doc.php
deleted file mode 100644
index 20be4613075..00000000000
--- a/notes/trunk/notes_doc.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
-* File : notes_doc.php
-*
-* Shows the notes of a document
-*
-* @package Maarch LetterBox 2.3
-* @version 1.0
-* @since 06/2006
-* @license GPL
-* @author  Claire Figueras  <dev@maarch.org>
-*/
-$core = new core_tools();
-//here we loading the lang vars
-$core->load_lang();
-$core->test_service('manage_notes_doc', 'notes');
-?>
-
-<img src="<?php
-echo $_SESSION['config']['businessappurl'];
-?>static.php?filename=modif_note.png&module=notes" border="0" alt="" />
-<a href="javascript://" onclick="ouvreFenetre('<?php
-echo $_SESSION['config']['businessappurl'];
-?>index.php?display=true&module=notes&page=note_add&identifier=<?php
-echo $_SESSION['doc_id'];
-
-?>&coll_id=<?php
-echo $_SESSION['collection_id_choice'];
-?>', 550, 350)"><?php  echo _ADD_NOTE;?></a>
-<iframe name="list_notes_doc" id="list_notes_doc" src="<?php
-echo $_SESSION['config']['businessappurl'];
-?>index.php?display=true&module=notes&page=frame_notes_doc" frameborder="0" width="100%" height="440px"></iframe>
-
diff --git a/notes/trunk/notes_list.php b/notes/trunk/notes_list.php
index 340ede48d61..8578696582a 100644
--- a/notes/trunk/notes_list.php
+++ b/notes/trunk/notes_list.php
@@ -38,9 +38,9 @@ $core_tools = new core_tools();
 $request    = new request();
 $list       = new lists();
 
-if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
+if(isset($_REQUEST['identifier']) && $_REQUEST['identifier'] <> "") {
 
-    $id = $_REQUEST['id'];
+    $identifier = $_REQUEST['identifier'];
     
     if(isset($_REQUEST['coll_id']) && !empty($_REQUEST['coll_id'])) {
          $extendUrl = "&coll_id=".$_REQUEST['coll_id'];
@@ -49,13 +49,13 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
     //If size is full change some parameters
     if ($_REQUEST['size'] == "full") {
         $sizeSmall = "15";
-        $sizeFull = "40";
+        $sizeFull = "30";
         $css = "listing spec";
         $cutString = 100;
         $extendUrl = "&size=full";
     } else {
         $sizeSmall = "10";
-        $sizeFull = "30";
+        $sizeFull = "10";
         $css = "listingsmall";
         $cutString = 20;
         $extendUrl = "";
@@ -66,13 +66,13 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
         $select[USERS_TABLE] = array(); //Users
         
     //Fields
-        array_push($select[NOTES_TABLE], "id", "identifier", "date_note", "note_text", "user_id", "coll_id");    //Notes
+        array_push($select[NOTES_TABLE], "id", "identifier", "date_note", "user_id", "note_text", "note_text as note_short", "coll_id");    //Notes
         array_push($select[USERS_TABLE], "user_id", "firstname", "lastname");           //Users
         
     //Where clause
         $where_tab = array();
         //
-        $where_tab[] = " identifier = " . $id . " ";
+        $where_tab[] = " identifier = " . $identifier . " ";
         //From filters
         $filterClause = $list->getFilters(); 
         if (!empty($filterClause)) $where_tab[] = $filterClause;//Filter clause
@@ -110,7 +110,7 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
                     {
                         $tab[$i][$j]["id"]=$tab[$i][$j]['value'];
                         $tab[$i][$j]["label"]='ID';
-                        $tab[$i][$j]["size"]="5";
+                        $tab[$i][$j]["size"]="1";
                         $tab[$i][$j]["label_align"]="left";
                         $tab[$i][$j]["align"]="left";
                         $tab[$i][$j]["valign"]="bottom";
@@ -121,13 +121,23 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
                     {
                         $tab[$i][$j]["value"]=$request->dateformat($tab[$i][$j]["value"]);
                         $tab[$i][$j]["label"]=_DATE;
-                        $tab[$i][$j]["size"]=$sizeSmall;
+                        $tab[$i][$j]["size"]="5";
                         $tab[$i][$j]["label_align"]="left";
                         $tab[$i][$j]["align"]="left";
                         $tab[$i][$j]["valign"]="bottom";
                         $tab[$i][$j]["show"]=true;
                         $tab[$i][$j]["order"]='date_note';
                     }
+                    if($tab[$i][$j][$value]=="user_id")
+                    {
+                        $tab[$i][$j]["label"]=_USER_ID;
+                        $tab[$i][$j]["size"]="5";
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=false;
+                        $tab[$i][$j]["order"]='user_id';
+                    }
                     if($tab[$i][$j][$value]=="firstname")
                     {
                         $firstname =  $request->show_string($tab[$i][$j]["value"]);
@@ -143,7 +153,7 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
                         $tab[$i][$j]["show"]=true;
                         $tab[$i][$j]["order"]='lastname';
                     }
-                    if($tab[$i][$j][$value]=="note_text")
+                    if($tab[$i][$j][$value]=="note_short")
                     {
                         $tab[$i][$j]["value"] = $request->cut_string( $request->show_string($tab[$i][$j]["value"]), $cutString);
                         $tab[$i][$j]["label"]=_NOTES;
@@ -152,6 +162,17 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
                         $tab[$i][$j]["align"]="left";
                         $tab[$i][$j]["valign"]="bottom";
                         $tab[$i][$j]["show"]=true;
+                        $tab[$i][$j]["order"]='note_short';
+                    }
+                    if($tab[$i][$j][$value]=="note_text")
+                    {
+                        $tab[$i][$j]["value"] = $request->show_string($tab[$i][$j]["value"]);
+                        $tab[$i][$j]["label"]=_NOTES;
+                        $tab[$i][$j]["size"]=$sizeFull;
+                        $tab[$i][$j]["label_align"]="left";
+                        $tab[$i][$j]["align"]="left";
+                        $tab[$i][$j]["valign"]="bottom";
+                        $tab[$i][$j]["show"]=false;
                         $tab[$i][$j]["order"]='note_text';
                     }
                 }
@@ -164,36 +185,46 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
         $paramsTab['bool_sortColumn'] = true;                                               //Affichage Tri
         $paramsTab['pageTitle'] ='';                                                        //Titre de la page
         $paramsTab['bool_bigPageTitle'] = false;                                            //Affichage du titre en grand
-        $paramsTab['urlParameters'] = 'id='.$_REQUEST['id'].'&display=true'.$extendUrl;     //Parametres d'url supplementaires
-         // $paramsTab['filters'] = array('user');                                             //Filtres    
+        $paramsTab['urlParameters'] = 'identifier='.$identifier.'&display=true'.$extendUrl; //Parametres d'url supplementaires
+        $paramsTab['filters'] = array('user');                                              //Filtres    
         $paramsTab['listHeight'] = '540px';                                                 //Hauteur de la liste
         // $paramsTab['bool_showSmallToolbar'] = true;                                         //Mini barre d'outils
         $paramsTab['linesToShow'] = 15;                                                     //Nombre de ligne a afficher
         $paramsTab['listCss'] = $css;                                                       //CSS
-        
         $paramsTab['tools'] = array();                                                      //Icones dans la barre d'outils
+          
         $add = array(
-                "script"        =>  "ouvreFenetre('".$_SESSION['config']['businessappurl']
-                                    ."index.php?display=true&module=notes&page=note_add"
-                                    ."&identifier=".$id."&table=folders"
-                                    . $extendUrl."', 800, 480);",
+                "script"        =>  "showNotesForm('".$_SESSION['config']['businessappurl']  
+                                        . "index.php?display=true&module=notes&page=notes_ajax_content"
+                                        . "&mode=add&identifier=".$identifier."&origin=folder"
+                                        . $extendUrl."')",
                 "icon"          =>  $_SESSION['config']['businessappurl']."static.php?filename=tool_note.gif&module=notes",
-                "tooltip"       =>  _ADD_NOTE
+                "tooltip"       =>  _ADD_NOTE,
+                "alwaysVisible" =>  true
                 );
-    
         array_push($paramsTab['tools'],$add);   
         
         //Action icons array
         $paramsTab['actionIcons'] = array();
+        $preview = array(
+                    "type"          =>  "preview",
+                    "class"         =>  "preview",
+                    "icon"          =>  $_SESSION['config']['businessappurl']."static.php?filename=showFrameAdminList.png",
+                    "tooltip"       =>  _NOTES,
+                    "content"      =>  "{'identifierDetailFrame' : '@@id@@', '"._DATE." ' : '@@date_note@@', '"._USER." ' : '@@lastname@@', '"._NOTES." ' : '@@note_text@@'}"
+                );
+        array_push($paramsTab['actionIcons'], $preview);        
+        
         $read = array(
-            "script"        => "ouvreFenetre('".$_SESSION['config']['businessappurl']
-                                    ."index.php?display=true&module=notes&page=note_details"
-                                    ."&id=@@id@@&identifier=".$id."&table=folders"
-                                    . $extendUrl."', 800, 480);",
+            "script"        => "showNotesForm('".$_SESSION['config']['businessappurl']
+                                    ."index.php?display=true&module=notes&page=notes_ajax_content"
+                                    ."&mode=up&id=@@id@@&identifier=".$identifier."&origin=folder"
+                                    . $extendUrl."');",
             "class"         =>  "read",
             "icon"          =>  $_SESSION['config']['businessappurl']."static.php?filename=picto_view.gif",
             "label"         =>  _READ,
-            "tooltip"       =>  _READ
+            "tooltip"       =>  _READ,
+            "disabledRules" => "@@user_id@@ != '".$_SESSION['user']['UserId']."'"
             );
         array_push($paramsTab['actionIcons'], $read);     
          
@@ -204,5 +235,4 @@ if(isset($_REQUEST['id']) && $_REQUEST['id'] <> "") {
 }
 
 echo "{status : " . $status . ", content : '" . addslashes($debug.$content) . "', error : '" . addslashes($error) . "'}";
- 
 ?>
\ No newline at end of file
-- 
GitLab