From 3d9eddbdcd4fe34d2ea250fcdab3ccfabbf69797 Mon Sep 17 00:00:00 2001
From: Nestor <npegane@hotmail.com>
Date: Tue, 26 Jun 2018 16:00:10 +0200
Subject: [PATCH] FIX #7747 dissociate document is possible

---
 modules/cases/execute_attachement.php | 17 +++++++++++++++++
 modules/cases/js/functions.js         |  2 +-
 modules/cases/show_case_tab.php       |  9 ++++++++-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/modules/cases/execute_attachement.php b/modules/cases/execute_attachement.php
index 697ef889edc..b0669c90fce 100755
--- a/modules/cases/execute_attachement.php
+++ b/modules/cases/execute_attachement.php
@@ -112,6 +112,23 @@ if (($core_tools->test_service('join_res_case', 'cases', false) == 1) || ($core_
                     case_id.value = '<?php functions::xecho($return_description['case_id'] ); ?>';
                     case_label.value = '<?php echo addslashes($return_description['case_label']); ?>';
                     case_description.value = '<?php echo addslashes($return_description['case_description']); ?>';
+                    lang_unlink_case = '<?php echo addslashes(_UNLINK_CASE);?>';
+                    url_script = '<?php echo $_SESSION['config']['businessappurl']?>'+'index.php?display=true&module=cases&page=unlink_case';
+                    case_id = '<?php echo $return_description['case_id']; ?>';
+                    res_id = '<?php echo $actual_res_id; ?>';
+                    strOnClick = 'if(confirm(\"'+lang_unlink_case+'?\")){unlink_case(\''+url_script+'\','+case_id+','+res_id+');}';
+                    
+                    var btn_unlink_case = $j(' <input/>').attr({
+                        type    : "button",
+                        id      : "btn_unlink_case",
+                        onclick : strOnClick,
+                        class   : 'button',
+                        value   : lang_unlink_case
+                    });
+
+                    btn_search_case = window.opener.$j('#search_case');
+                    btn_search_case.after(btn_unlink_case);
+                    btn_search_case.after('<span> </span>');
                     
                 }
                 //self.close();
diff --git a/modules/cases/js/functions.js b/modules/cases/js/functions.js
index a5070111698..4e6ab313df6 100755
--- a/modules/cases/js/functions.js
+++ b/modules/cases/js/functions.js
@@ -9,7 +9,7 @@ function unlink_case(path_manage_script,case_id,res_id){
 		onSuccess: function(answer){
 			eval('response='+answer.responseText);
 			if(response){
-				window.location.href='index.php?page=details&dir=indexing_searching&id='+res_id;
+				window.top.location.href='index.php?page=details&dir=indexing_searching&id='+res_id;
 			}else{
 				alert('Something went wrong...');
 			}
diff --git a/modules/cases/show_case_tab.php b/modules/cases/show_case_tab.php
index 6f0bfd33e5c..a18369822bf 100755
--- a/modules/cases/show_case_tab.php
+++ b/modules/cases/show_case_tab.php
@@ -73,7 +73,14 @@ if ($core_tools->test_service('join_res_case_in_process', 'cases', false) == 1)
             . 'index.php?display=true&module=cases&page=search_adv_for_cases'
             . '&searched_item=res_id_in_process&searched_value=' . $_SESSION['doc_id']
             . '\',\'\', \'scrollbars=yes,menubar=no,toolbar=no,resizable=yes,'
-            . 'status=no,width=1020,height=710\');"/></td>';
+            . 'status=no,width=1020,height=710\');"/>';
+
+            if($case_properties['case_id'] <> ''){
+                $frm_str .= ' <input type="button" class="button" name="btn_unlink_case" '
+                . 'id="btn_unlink_case" value="'._UNLINK_CASE.'"'
+                . 'onclick="if(confirm(\''.addslashes(_UNLINK_CASE).'?\')){unlink_case(\''.$_SESSION['config']['businessappurl'].'index.php?display=true&module=cases&page=unlink_case\','.$case_properties['case_id'].','. $res_id .');}"/>';
+            }
+            $frm_str .= '</td>';
 }
 $frm_str .= '</tr>';
 $frm_str .= '</table>';
-- 
GitLab