From b7d8e44ddd8832eeb9ec295c874d2b1087c1d8a7 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex@alex-MAARCH>
Date: Tue, 31 Jan 2017 11:52:55 +0100
Subject: [PATCH] FIX #5170 clean session stockChecBox

---
 apps/maarch_entreprise/actions/index_mlb.php     | 4 +++-
 apps/maarch_entreprise/actions/process.php       | 1 +
 apps/maarch_entreprise/actions/validate_mail.php | 1 +
 apps/maarch_entreprise/js/functions.js           | 3 +--
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php
index 4bd1356fc49..081779b8ce0 100644
--- a/apps/maarch_entreprise/actions/index_mlb.php
+++ b/apps/maarch_entreprise/actions/index_mlb.php
@@ -117,6 +117,7 @@ function get_form_txt($values, $pathManageAction,  $actionId, $table, $module, $
     
     //INITIALIZE
     $frmStr = '';
+    $_SESSION['stockCheckbox']= '';
     $_SESSION['req'] = "action";
     $resId = $values[0];
     $today = date('d-m-Y');
@@ -1845,9 +1846,10 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI
 
     if ($attach) {
         $idDoc = get_value_fields($formValues, 'res_id');
+        $idDocTab = explode(',', $idDoc);
         for($i=0;$i<count($_SESSION['stockCheckbox']);$i++){
             $queryLink = "INSERT INTO res_linked (res_parent, res_child, coll_id) VALUES(?, ?, ?)";
-            $arrayPDO = array($_SESSION['stockCheckbox'][$i], $resId, $_SESSION['collection_id_choice']);
+            $arrayPDO = array($idDocTab[$i], $resId, $_SESSION['collection_id_choice']);
             $db->query($queryLink, $arrayPDO);
         }
         $hist2 = new history();
diff --git a/apps/maarch_entreprise/actions/process.php b/apps/maarch_entreprise/actions/process.php
index 2bb4b5fdb6a..e3dfcafc45b 100644
--- a/apps/maarch_entreprise/actions/process.php
+++ b/apps/maarch_entreprise/actions/process.php
@@ -92,6 +92,7 @@ function get_form_txt($values, $path_manage_action,  $id_action, $table, $module
     
     //INITIALIZE
     $frm_str = '';
+    $_SESSION['stockCheckbox']= '';
     $_SESSION['req'] = "action";
     $res_id = $values[0];
     $doctypes = $type->getArrayTypes($coll_id);
diff --git a/apps/maarch_entreprise/actions/validate_mail.php b/apps/maarch_entreprise/actions/validate_mail.php
index 25571be5ff4..9e70b0e8c52 100644
--- a/apps/maarch_entreprise/actions/validate_mail.php
+++ b/apps/maarch_entreprise/actions/validate_mail.php
@@ -124,6 +124,7 @@ function get_form_txt($values, $path_manage_action,  $id_action, $table, $module
     
     //INITIALIZE
     $frm_str = '';
+    $_SESSION['stockCheckbox']= '';
     unset($_SESSION['m_admin']['contact']);
     $_SESSION['req'] = "action";
     $res_id = $values[0];
diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js
index e416fbb8234..5bd5046231b 100644
--- a/apps/maarch_entreprise/js/functions.js
+++ b/apps/maarch_entreprise/js/functions.js
@@ -2360,8 +2360,7 @@ function valid_report_by_period(url)
                 }
             }
         });
-    } else
-    alert ("DEBU");
+    }
 }
 
 /**
-- 
GitLab