From 959bb05ec88ccfbdc76e06b0d7d6ce2b7187d1e8 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 28 Sep 2017 16:32:15 +0100
Subject: [PATCH] =?UTF-8?q?FIX=20#5959=20conserver=20retour=20chariot=20lo?=
 =?UTF-8?q?rsqu'on=20=C3=A9crit=20une=20note=20en=20redirigeant?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 modules/entities/js/functions.js | 13 ++++++-------
 modules/entities/redirect.php    |  6 +++---
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/modules/entities/js/functions.js b/modules/entities/js/functions.js
index 0fa3b035c82..62311f607fc 100755
--- a/modules/entities/js/functions.js
+++ b/modules/entities/js/functions.js
@@ -176,7 +176,6 @@ function change_diff_list(
     category,
     specific_role
 ) {
-        console.log('test change_diff_list');
 
     if(category === undefined){
         category = '';
@@ -200,10 +199,8 @@ function change_diff_list(
             },
             onSuccess: function(answer){
                 eval("response = "+answer.responseText);
-                //alert(answer.responseText);
                 if(response.status == 0 )
                 {
-                    //alert(window.opener.document);
                     var diff_list_tr = window.opener.$(list_tr);
                     var diff_list_div = window.opener.$(list_div);
                     var diff_list_div_from_action = window.opener.$(list_div_from_action);
@@ -252,8 +249,6 @@ function isIdToken(value)
 }
 
 function validate_difflist_type() {
-        console.log('test validate_difflist_type');
-
   var main_error = $('main_error'); 
   main_error.innerHTML = '';
   
@@ -303,7 +298,6 @@ function validate_difflist_type() {
   
 }
 
-
 function saveListDiff(mode, table, collId, resId, userId, concatList, onlyCC) {
     new Ajax.Request(
         'index.php?display=true&module=entities&page=save_list_diff',
@@ -333,4 +327,9 @@ function saveListDiff(mode, table, collId, resId, userId, concatList, onlyCC) {
             }
         }
     );
-}
\ No newline at end of file
+}
+
+function setNoteRedirect(){
+    $j('#note_content_to_dep').val($j('#notes').val().replace(/\n/g, "___"));
+    $j('#note_content_to_user').val($j('#notes').val().replace(/\n/g, "___"));
+}
diff --git a/modules/entities/redirect.php b/modules/entities/redirect.php
index e092e9331a6..7ed46251602 100755
--- a/modules/entities/redirect.php
+++ b/modules/entities/redirect.php
@@ -137,7 +137,7 @@ require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php'
             }
         $frm_str .= '</select><br />';
 
-        $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="document.getElementById(\'note_content_to_dep\').value=document.getElementById(\'notes\').value;document.getElementById(\'note_content_to_user\').value=document.getElementById(\'notes\').value;"></textarea>';
+        $frm_str .= '<textarea style="width:98%;height:60px;resize:none;" name="notes"  id="notes" onblur="setNoteRedirect()"></textarea>';
         //var_dump($allEntitiesTree);
         $frm_str .= '<hr />';
         $frm_str .='<div id="form2" style="border:none;">';
@@ -363,7 +363,7 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
                 $content_note = $formValues['note_content_to_user'];
                 $content_note = str_replace(";", ".", $content_note);
                 $content_note = str_replace("--", "-", $content_note);
-                $content_note = $content_note;
+                $content_note = str_replace("___", "\n", $content_note);
 
                 $stmt = $db->query(
                     "INSERT INTO notes (identifier, tablename, user_id, "
@@ -391,7 +391,7 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
                 $content_note = $formValues['note_content_to_dep'];
                 $content_note = str_replace(";", ".", $content_note);
                 $content_note = str_replace("--", "-", $content_note);
-                $content_note = $content_note;
+                $content_note = str_replace("___", "\n", $content_note);
                 
                 $stmt = $db->query(
                     "INSERT INTO notes (identifier, tablename, user_id, "
-- 
GitLab