From a34dab0dde48d7d644cced9cd1a9a08c014975e8 Mon Sep 17 00:00:00 2001
From: Damien Burel <damien.burel@maarch.org>
Date: Fri, 19 May 2017 15:08:32 +0200
Subject: [PATCH] [REFACTORING] Clean up visa

---
 modules/visa/js/functions.js | 668 +----------------------------------
 modules/visa/visa_mail.php   | 402 +--------------------
 2 files changed, 3 insertions(+), 1067 deletions(-)

diff --git a/modules/visa/js/functions.js b/modules/visa/js/functions.js
index 184e6e6633b..f8367932382 100644
--- a/modules/visa/js/functions.js
+++ b/modules/visa/js/functions.js
@@ -1,4 +1,3 @@
-var docLockInterval;
 function addVisaUser(users) {
     if (!users) {
         nb_visa = $j(".droptarget").length;
@@ -79,7 +78,7 @@ function resetPosVisa () {
         $j("#" + this.id).find(".visaUserPos").text(i);
         i++;
     });
-    i--
+    i--;
     $j("#visa_" + i).find(".visaUserSign").css("visibility","visible");
 }
 function updateVisaWorkflow(resId) {
@@ -292,680 +291,15 @@ function initDragNDropVisa() {
         });
 }
 
-function manageFrame(button) {
-
-	var firstDiv = $("visa_listDoc");
-	var secondDiv = $("visa_left");
-	var thirdDiv = $("visa_right");
-
-	var right = "fa fa-arrow-circle-o-right fa-2x";
-	var left = "fa fa-arrow-circle-o-left fa-2x";
-
-	if (button.id == "firstFrame") {
-
-		if (firstDiv.style.display != "none") {
-			firstDiv.style.display = "none";
-			button.className = right;
-		} else {
-			firstDiv.style.display = "";
-			button.className = left;
-		}
-	} else if (button.id == "secondFrame") {
-
-		if (secondDiv.style.display != "none") {
-			$("thirdFrame").style.display = "none";
-			secondDiv.style.display = "none";
-			button.className = right;
-		} else {
-			$("thirdFrame").style.display = "";
-			secondDiv.style.display = "";
-			button.className = left;
-		}
-	} else if (button.id == "thirdFrame") {
-
-		if (thirdDiv.style.display != "none") {
-			$("secondFrame").style.display = "none";
-			thirdDiv.style.display = "none";
-			button.className = left;
-		} else {
-			$("secondFrame").style.display = "";
-			thirdDiv.style.display = "";
-			button.className = right;
-		}
-	}
-
-	if (firstDiv.style.display != "none" && secondDiv.style.display != "none" && thirdDiv.style.display != "none") {
-		firstDiv.style.width = "15%";
-		$("firstFrame").style.marginLeft = "13.8%";
-		secondDiv.style.width = "41%";
-		$("secondFrame").style.marginLeft = "40.9%";
-		thirdDiv.style.width = "41%";
-		$("thirdFrame").style.marginLeft = "0.6%";
-	} else if (firstDiv.style.display != "none" && (secondDiv.style.display == "none" || thirdDiv.style.display == "none")) {
-		firstDiv.style.width = "15%";
-		$("firstFrame").style.marginLeft = "13.8%";
-		if (secondDiv.style.display == "none") {
-			thirdDiv.style.width = "82%";
-			$("secondFrame").style.marginLeft = "0.2%";
-		}
-		else {
-			secondDiv.style.width = "82%";
-			$("thirdFrame").style.marginLeft = "83%";
-		}
-	} else if (firstDiv.style.display == "none" && secondDiv.style.display != "none" && thirdDiv.style.display != "none") {
-		$("firstFrame").style.marginLeft = "-0.5%";
-		secondDiv.style.width = "48%";
-		$("secondFrame").style.marginLeft = "47%";
-		thirdDiv.style.width = "48%";
-		$("thirdFrame").style.marginLeft = "0.6%"
-	} else if (firstDiv.style.display == "none" && (secondDiv.style.display == "none" || thirdDiv.style.display == "none")) {
-		$("firstFrame").style.marginLeft = "-0.5%";
-		if (secondDiv.style.display == "none") {
-			thirdDiv.style.width = "98%";
-			$("secondFrame").style.marginLeft = "0.2%";
-		}
-		else {
-			secondDiv.style.width = "98%";
-			$("thirdFrame").style.marginLeft = "97.5%";
-		}
-	}
-}
-
 function setTitle(input) {
 	input.title = input.value;
 }
 
-function	triggerFlashMsg($divName, $msg) {
-    var div = $($divName);
-
-    div.innerHTML = $msg;
-    div.style.display = 'table-cell';
-    Element.hide.delay(5, $divName);
-}
-
-/* Fonctions ajoutées par DIS */
-
-//Fonction permettant de lancer les 2 modules Tabricator côte à côte pour les différentes pages d'action (formation circuit de visa, visa ..)
-function launchTabri(){
-	var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-	var tabricatorLeft = new Tabricator('tabricatorLeft', 'DT');
-}
-
-
-
-function loadNewId(path_update, newId, collId, idToDisplay) {
-    new Ajax.Request(path_update,
-            {
-                method: 'post',
-                parameters: {
-                    res_id: newId,
-                    coll_id: collId,
-                    action: parent.$('action_id').value
-                },
-                asynchronous: false,
-                onSuccess: function (answer) {
-                    eval("response = " + answer.responseText);
-                    //console.log(response);
-                    if (response.status == 0) { //document verouillé
-                        alert(response.error);
-                    } else {
-                        /* Modification dans la liste de gauche */
-                        var zone_old = 'list_doc_' + parent.$('cur_resId').value;
-                        var zone_new = 'list_doc_' + newId;
-                        //console.log(zone_new);
-                        clearInterval(docLockInterval);
-                        //unlock old doc
-                        new Ajax.Request('index.php?display=true&dir=actions&page=docLocker', {method: 'post', parameters: {'AJAX_CALL': true, 'unlock': true, 'res_id': parent.$('cur_resId').value}, onSuccess: function (answer) {/*var cur_url=window.location.href;*/
-                                if (cur_url.indexOf('&directLinkToAction') != -1)
-                                    cur_url = cur_url.replace('&directLinkToAction', '');
-                                window.location.href = cur_url;
-                            }});
-                        //lock the new doc
-                        docLockInterval = setInterval("new Ajax.Request('index.php?display=true&dir=actions&page=docLocker',{ method:'post', parameters: {'AJAX_CALL': true, 'lock': true, 'res_id': " + newId + " } });", 50000);
-                        if ($(zone_new)) {
-                            $(zone_new).className = 'selectedId';
-                        }
-                        if ($(zone_old)) {
-                            $(zone_old).className = 'unselectedId';
-                        }
-
-                        parent.$('cur_resId').value = newId;
-
-                        if (idToDisplay == 'chrono_number') {
-                            parent.$('numIdDocPage').innerHTML = parent.$('chrn_id_' + newId).innerHTML;
-                        } else {
-                            parent.$('numIdDocPage').innerHTML = newId;
-                        }
-                        //console.log('display: '+idToDisplay);
-                    }
-                    if (response.status == 1) { //page de visa
-                        parent.$('tabricatorLeft').innerHTML = response.left_html;
-                        parent.$('tabricatorRight').innerHTML = response.right_html;
-                        parent.$("send_action").setAttribute('onclick', response.valid_button);
-                        
-                        updateFunctionModifRep(response.id_rep, 1, response.is_vers_rep);
-
-                        //console.log("Initialisation onglets de la partie droite");
-                        var tabricatorLeft = new Tabricator('tabricatorLeft', 'DT');
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-                        
-                        eval(response.exec_js);
-
-                    }
-
-                    if (response.status == 2) { //page préparation circuit
-                        parent.$('tabricatorRight').innerHTML = response.right_html;
-                        parent.$("send_action").setAttribute('onclick', response.valid_button);
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-                        //console.log("MAJ OK");
-                    }
-
-                    if (response.status == 3) { //page envoi mail
-                        parent.$('tabricatorRight').innerHTML = response.right_html;
-                        parent.$("send_action").setAttribute('onclick', response.valid_button);
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-
-                        showEmailForm('index.php?display=true&module=sendmail&page=sendmail_ajax_content&mode=add&identifier=' + newId + '&origin=document&coll_id=' + collId + '&size=medium', '820px', '545px', 'sendmail_iframe');
-                    }
-
-                    if (response.status == 4) { //page impression dossier
-                        parent.$('tabricatorRight').innerHTML = response.right_html;
-                        parent.$("send_action").setAttribute('onclick', response.valid_button);
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-                        //console.log("MAJ OK");
-                    }
-                },
-                onFailure: function () {
-                    //console.log("Probleme de Mise à jour !");
-                }
-            });
-
-}
-
-function loadNewId2(path_update, newId, collId, idToDisplay) {
-    new Ajax.Request(path_update,
-            {
-                method: 'post',
-                parameters: {
-                    res_id: newId,
-                    coll_id: collId,
-                    action: $('action_id').value
-                },
-                asynchronous: false,
-                onSuccess: function (answer) {
-                    eval("response = " + answer.responseText);
-                    //console.log(response);
-                    if (response.status == 0) { //document verouillé
-                        alert(response.error);
-                    } else {
-                  
-                        /* Modification dans la liste de gauche */
-                        var zone_old = 'list_doc_' + $('cur_resId').value;
-                        var zone_new = 'list_doc_' + newId;
-                        //console.log(zone_new);
-                        clearInterval(docLockInterval);
-                        //unlock old doc
-                        new Ajax.Request('index.php?display=true&dir=actions&page=docLocker', {method: 'post', parameters: {'AJAX_CALL': true, 'unlock': true, 'res_id': $('cur_resId').value}, onSuccess: function (answer) {/*var cur_url=window.location.href;*/
-                                if (cur_url.indexOf('&directLinkToAction') != -1)
-                                    cur_url = cur_url.replace('&directLinkToAction', '');
-                                window.location.href = cur_url;
-                            }});
-                        //lock the new doc
-                        docLockInterval = setInterval("new Ajax.Request('index.php?display=true&dir=actions&page=docLocker',{ method:'post', parameters: {'AJAX_CALL': true, 'lock': true, 'res_id': " + newId + " } });", 50000);
-
-                        if($(zone_new)){
-                            $(zone_new).className = 'selectedId';
-                        }
-                        if($(zone_old)){
-                            $(zone_old).className = 'unselectedId';
-                        }
-                        $('cur_resId').value = newId;
-
-                        if (idToDisplay == 'chrono_number') {
-                            $('numIdDocPage').innerHTML = $('chrn_id_' + newId).innerHTML;
-                        } else {
-                            $('numIdDocPage').innerHTML = newId;
-                        }
-                        //console.log('display: '+idToDisplay);
-                    }
-                    if (response.status == 1) { //page de visa
-                        $('tabricatorLeft').innerHTML = response.left_html;
-                        $('tabricatorRight').innerHTML = response.right_html;
-                        $("send_action").setAttribute('onclick', response.valid_button);
-
-                        updateFunctionModifRep(response.id_rep, 1, response.is_vers_rep);
-
-                        console.log("Initialisation onglets de la partie droite");
-                        var tabricatorLeft = new Tabricator('tabricatorLeft', 'DT');
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-
-                    }
-
-                    if (response.status == 2) { //page préparation circuit
-                        $('tabricatorRight').innerHTML = response.right_html;
-                        $("send_action").setAttribute('onclick', response.valid_button);
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-                        //console.log("MAJ OK");
-                    }
-
-                    if (response.status == 3) { //page envoi mail
-                        $('tabricatorRight').innerHTML = response.right_html;
-                        $("send_action").setAttribute('onclick', response.valid_button);
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-
-                        showEmailForm('index.php?display=true&module=sendmail&page=sendmail_ajax_content&mode=add&identifier=' + newId + '&origin=document&coll_id=' + collId + '&size=medium', '820px', '545px', 'sendmail_iframe');
-                    }
-
-                    if (response.status == 4) { //page impression dossier
-                        $('tabricatorRight').innerHTML = response.right_html;
-                        $("send_action").setAttribute('onclick', response.valid_button);
-                        var tabricatorRight = new Tabricator('tabricatorRight', 'DT');
-                        //console.log("MAJ OK");
-                    }
-                },
-                onFailure: function () {
-                    //console.log("Probleme de Mise à jour !");
-                }
-            });
-
-}
-
-function previousDoc(path_update,collId){
-	var current = parent.$('cur_resId').value;
-	$('list_doc_'+current).previousSibling.click();
-}
-
-function nextDoc(path_update,collId){
-	var current = parent.$('cur_resId').value;
-	$('list_doc_'+current).nextSibling.click();
-        
-}
-
-function updateFunctionModifRep(idReponse, num_rep, is_version){
-	if(idReponse == 0){
-		if (parent.document.getElementById("update_rep_link")) {
-			parent.document.getElementById("update_rep_link").style.display = 'none';
-		}
-		if (parent.document.getElementById("sign_link")) {
-			parent.document.getElementById("sign_link").style.display = 'none';
-		}
-
-	}else{
-		new Ajax.Request("index.php?display=true&page=checkSignFile&module=visa&res_id="+idReponse,
-		{
-			method:'post',
-			onSuccess: function(answer){
-				eval("response = "+answer.responseText);
-				if (response.status == 1){
-					if (parent.document.getElementById("sign_link")){
-						parent.document.getElementById("sign_link").style.display = '';
-						parent.document.getElementById("sign_link").setAttribute('onclick','document.getElementById("list_attach").src="index.php?display=true&module=attachments&page=del_attachment&relation=1&id='+idReponse+'&fromDetail="');	
-						parent.document.getElementById("sign_link").style.color = 'green';
-						parent.document.getElementById("sign_link_img").src = 'static.php?filename=sign_valid.png';
-						parent.document.getElementById("sign_link_img").title= 'Enlever la signature';
-						parent.document.getElementById("sign_link_img").style.cursor = 'not-allowed';
-						parent.document.getElementById("sign_link").setAttribute('disabled','disabled');
-
-					}
-					if (parent.document.getElementById("sign_link_certif")){
-						parent.document.getElementById("sign_link_certif").setAttribute('onclick','');	
-						parent.document.getElementById("sign_link_certif").style.color = 'green';
-					}
-					
-					if (parent.document.getElementById("update_rep_link")) {
-						parent.document.getElementById("update_rep_link").style.display = 'none';
-					}
-				}
-				else if (response.status == 0){
-					if (parent.document.getElementById("sign_link")){
-						parent.document.getElementById("sign_link").style.display = '';
-						parent.document.getElementById("sign_link").setAttribute('onclick','signFile('+idReponse+','+is_version+',2);');	
-						parent.document.getElementById("sign_link").style.color = '';
-						parent.document.getElementById("sign_link_img").src = 'static.php?filename=sign.png';
-						parent.document.getElementById("sign_link_img").title= 'Signer ces projets de réponse (sans certificat)';
-						parent.document.getElementById("sign_link_img").style.cursor = 'pointer';
-						parent.document.getElementById("sign_link").removeAttribute('disabled');
-					}
-					if (parent.document.getElementById("sign_link_certif")){
-						parent.document.getElementById("sign_link_certif").setAttribute('onclick','signFile('+idReponse+','+is_version+',0);');	
-						parent.document.getElementById("sendPIN").setAttribute('onclick','signFile('+idReponse+','+is_version+',\'\', $(\'valuePIN\').value);');	
-						parent.document.getElementById("valuePIN").setAttribute('onKeyPress','if (event.keyCode == 13) signFile('+idReponse+','+is_version+',\'\', $(\'valuePIN\').value);');	
-						parent.document.getElementById("sign_link_certif").style.color = '';
-						parent.document.getElementById("sign_link_img").src = 'static.php?filename=sign.png';
-					}
-					if (parent.document.getElementById("update_rep_link")) {
-						parent.document.getElementById("update_rep_link").style.display = '';
-						console.log("is_version = "+is_version);
-						/*if (is_version == 2) document.getElementById("update_rep_link").style.display = 'none';
-						else */if (is_version != 1) parent.document.getElementById("update_rep_link").setAttribute('onclick','modifyAttachmentsForm(\'index.php?display=true&module=attachments&page=attachments_content&id='+idReponse+'&relation=1&fromDetail=\',\'98%\',\'auto\');');	
-						else parent.document.getElementById("update_rep_link").setAttribute('onclick','modifyAttachmentsForm(\'index.php?display=true&module=attachments&page=attachments_content&id='+idReponse+'&relation=2&fromDetail=\',\'98%\',\'auto\');');	
-						
-					}
-				}
-			}
-		});
-		parent.document.getElementById("cur_idAffich").setAttribute('value',num_rep);
-		parent.document.getElementById("cur_rep").setAttribute('value',idReponse);
-	}
-}
-
-function hasAllAnsSigned(id_doc){
-	var retour = 'null';
-	new Ajax.Request("index.php?display=true&page=checkAllAnsSigned&module=visa&res_id="+id_doc,
-	{
-		method:'post',
-		asynchronous:false,
-		onSuccess: function(answer){
-			eval("response = "+answer.responseText);
-			retour = response.status;
-		}
-	});
-	return retour;
-}
-
-function signFile(res_id,isVersion, mode, pinCode){
-	var reg = /^[0-9]{4}$/;
-	var func_onclic;
-	if(pinCode == undefined || pinCode=='')
-    {
-        pinCode='';
-    }
-	else if (!reg.test(pinCode)){
-		//alert("Le code PIN doit comporter 4 chiffres");
-		$('badPin').style.display = 'block';
-		$('badPin').innerHTML = 'Le format est incorrect (4 chiffres)';
-		$('valuePIN').value = "";
-	}
-	else {
-		$('modalPIN').style.display = 'none';
-		new Ajax.Request("index.php?display=true&module=visa&page=encodePinCode",
-		{
-			method:'post',
-			asynchronous:false,
-			parameters: { 
-				pinCode : pinCode
-			}			
-		});
-	}
-	if (mode == 2){
-
-		var path = '';
-		if (isVersion == 0) path = 'index.php?display=true&module=visa&page=sign_file&collId=letterbox_coll&id='+res_id;
-		else if (isVersion == 1) path = 'index.php?display=true&module=visa&page=sign_file&collId=letterbox_coll&isVersion&id='+res_id;
-		else if (isVersion == 2) path = 'index.php?display=true&module=visa&page=sign_file&collId=letterbox_coll&isOutgoing&id='+res_id;
-		new Ajax.Request(path,
-		{
-			method:'post',
-			onSuccess: function(answer){
-				eval("response = "+answer.responseText);
-				if (response.status == 0){
-					if ($('cur_idAffich')) var num_rep = $('cur_idAffich').value;
-					if ($('cur_rep')){
-						var newId = response.new_id;
-						var oldRep = $('cur_rep').value;
-						$('cur_rep').value = newId;
-					}
-					if ($('cur_resId')) var num_idMaster = $('cur_resId').value;
-					if ($('update_rep_link')){
-						$('update_rep_link').style.display = 'none';
-					}
-					if ($('sign_link')){
-						$("sign_link").style.display = '';
-						link = 'index.php?display=true&module=attachments&page=del_attachment&relation=1&id='+newId;
-						$("sign_link").setAttribute('onclick','document.getElementById(\'list_attach\').src="'+link+'"');	
-						$("sign_link").style.color = 'green';
-						$("sign_link_img").src = 'static.php?filename=sign_valid.png';
-						$("sign_link_img").title= 'Enlever la signature';
-						$("sign_link_img").style.cursor = 'not-allowed';
-						$("sign_link").setAttribute('disabled','disabled');	
-						//console.log($('sign_link').style);
-					}
-					if ($('sign_link_certif')){
-						$('sign_link_certif').style.color = 'green';
-						$('sign_link_certif').setAttribute('onclick','');	
-					}
-					
-					if(oldRep == newId-1){
-						oldRep = res_id;
-					}
-					if($('viewframevalidRep'+num_rep+'_'+oldRep)) {
-						$('viewframevalidRep'+num_rep+'_'+oldRep).src = "index.php?display=true&module=attachments&page=view_attachment&res_id_master="+num_idMaster+"&id="+newId;			
-						$('viewframevalidRep'+num_rep+'_'+oldRep).id = 'viewframevalidRep'+num_rep+'_'+newId;
-					}
-
-					
-					if($('ans_'+num_rep+'_'+oldRep)) {
-						$('ans_'+num_rep+'_'+oldRep).setAttribute('onclick','updateFunctionModifRep(\''+newId+'\', '+num_rep+', 0);');		
-						$('ans_'+num_rep+'_'+oldRep).id = 'ans_'+num_rep+'_'+newId;							
-					}
-
-					if($('content_'+num_rep+'_'+oldRep)) {
-						$('content_'+num_rep+'_'+oldRep).id = 'content_'+num_rep+'_'+newId;							
-					}
-					var zone_id = 'signedDoc_'+$('cur_resId').value;
-                                        
-                                        if($(zone_id)){
-                                            if (hasAllAnsSigned($('cur_resId').value) == 1){
-						$(zone_id).style.visibility = 'visible';
-                                            }
-                                            else{
-                                                    $(zone_id).style.visibility = 'hidden';
-                                            }
-                                        }
-					
-					$('ans_'+num_rep+'_'+newId).innerHTML='<sup><i class="fa fa-certificate fa-lg fa-fw" style="color:#fdd16c"></i></sup>Réponse signée';
-					$('ans_'+num_rep+'_'+newId).title=$('ans_'+num_rep+'_'+newId).title;
-					//$('list_attach').src = 'index.php?display=true&module=attachments&page=frame_list_attachments&template_selected=documents_list_attachments_simple&load&attach_type_exclude=converted_pdf,print_folder';
-                                        
-                                        loadToolbarBadge('attachments_tab','index.php?display=true&module=attachments&page=load_toolbar_attachments&origin=document&resId='+$('cur_resId').value+'&collId=letterbox_coll');
-				}
-				else{
-					alert(response.error);
-					console.log(func_onclic);
-					$("sign_link").setAttribute('onclick',func_onclic);
-				}	
-				//$("sign_link").removeAttribute("onclick");
-				//$("sign_link_img").style.display = 'none';
-				//$('sign_link').className = 'fa fa-spinner fa-2x fa-spin';
-				document.getElementById("sign_link").className = document.getElementById("sign_link").className.replace( /(?:^|\s)fa fa-spinner fa-2x fa-spin(?!\S)/g , "" )
-				$('sign_link').title="";
-				$("sign_link_img").style.display = '';
-			},
-			onCreate: function(answer){
-				func_onclic = $("sign_link").getAttribute("onclick");
-				$("sign_link").removeAttribute("onclick");
-				$("sign_link_img").style.display = 'none';
-				$('sign_link').className = 'fa fa-spinner fa-2x fa-spin';
-				$('sign_link').title="en cours de traitement..."
-			}
-		});
-	}
-	else {
-		new Ajax.Request("index.php?display=true&module=visa&page=checkPinCode",
-		{
-			method:'post',
-			onSuccess: function(answer){
-				eval("response = "+answer.responseText);
-				if (response.status == 1){
-					$('badPin').style.display = 'none';
-					if (isVersion == 0) window.open('index.php?display=true&module=visa&page=sign_ans&collId=letterbox_coll&id='+res_id+'&modeSign='+mode,'','height=301, width=301,scrollbars=yes,resizable=yes');
-					else if (isVersion == 1) window.open('index.php?display=true&module=visa&page=sign_ans&collId=letterbox_coll&isVersion&id='+res_id+'&modeSign='+mode,'','height=301, width=301,scrollbars=yes,resizable=yes');
-					else if (isVersion == 2) window.open('index.php?display=true&module=visa&page=sign_ans&collId=letterbox_coll&isOutgoing&id='+res_id+'&modeSign='+mode,'','height=301, width=301,scrollbars=yes,resizable=yes');
-				}
-				else if (response.status == 0){
-					if (mode == 1){
-						if (isVersion == 0) window.open('index.php?display=true&module=visa&page=sign_ans&collId=letterbox_coll&id='+res_id+'&modeSign='+mode,'','height=301, width=301,scrollbars=yes,resizable=yes');
-						else if (isVersion == 1) window.open('index.php?display=true&module=visa&page=sign_ans&collId=letterbox_coll&isVersion&id='+res_id+'&modeSign='+mode,'','height=301, width=301,scrollbars=yes,resizable=yes');
-						else if (isVersion == 2) window.open('index.php?display=true&module=visa&page=sign_ans&collId=letterbox_coll&isOutgoing&id='+res_id+'&modeSign='+mode,'','height=301, width=301,scrollbars=yes,resizable=yes');
-					}
-					
-					else {
-							var attr = document.getElementById("sendPIN").getAttribute('onclick').split(',');	
-							document.getElementById("sendPIN").setAttribute('onclick',attr[0]+','+attr[1]+','+mode+','+attr[3]);	
-							
-							var attr2 = document.getElementById("valuePIN").getAttribute('onKeyPress').split(',');	
-							document.getElementById("valuePIN").setAttribute('onKeyPress',attr2[0]+','+attr2[1]+','+mode+','+attr2[3]);	
-							
-							$('modalPIN').style.display = 'block';
-							//console.log("Code PIN :"+pinCode);
-					}
-				}
-			}
-		});
-	
-	}
-	
-}
-
 //load applet in a modal
 function loadAppletSign(url){
     displayModal(url, 'VisaApplet', 300, 300);
 }
 
-
-function translateError(key){
-	var message = "";
-	switch(key){
-		case "300" :
-			message = "L'exécutable de signature est introuvable. Veuillez contacter votre administrateur.";break;
-		case "99" :
-			message = "Erreur lors de la signature numérique";break;
-		case "98" :
-			message = "Code PIN erroné";break;
-		case "97" :
-			message = "Trop de tentatives infructueuses pour le code PIN. Veuillez contacter votre administrateur.";break;
-		case "12" :
-			message = "Le répertoire PDF destination n'a pas de droit d'écriture. Veuillez contacter votre administrateur";break;
-		case "16" :
-			message = "Le code PIN doit comporter 4 chiffres";break;
-		case "51" :
-			message = "Anomalie lors de l'incrustation de l'imagette de signature";break;
-		default :
-			message = "";break;
-	}
-	return message;
-}
-
-
-//destroy the modal of the applet and launch an ajax script
-function endOfAppletSign(objectType, theMsg, newId)
-{
-    if (objectType == 'ans_project') {
-		if (newId != 0){
-			endAttachmentSign(newId);
-		}
-		else{
-			if (theMsg != '' && theMsg != ' ') {
-				if ($('maarchcm_error')) {
-					$('maarchcm_error').innerHTML = translateError(theMsg);
-					$('maarchcm_error').style.display = "block";
-				}
-				if (theMsg == "98"){
-					window.opener.$('modalPIN').style.display = 'block';
-					window.opener.$('badPin').innerHTML = 'Code PIN incorrect (3 essais maximum)';
-					window.opener.$('badPin').style.display = 'block';
-					window.close();
-				}
-			}
-		}
-    }
-    //destroyModal('CMApplet');
-}
-
-function endAttachmentSign(newId)
-{
-	if (window.opener.$('cur_idAffich')) var num_rep = window.opener.$('cur_idAffich').value;
-	if (window.opener.$('cur_rep')){
-		var oldRep = window.opener.$('cur_rep').value;
-		window.opener.$('cur_rep').value = newId;
-	}
-	if (window.opener.$('cur_resId')) var num_idMaster = window.opener.$('cur_resId').value;
-	
-	if (window.opener.$('update_rep_link')){
-		window.opener.$('update_rep_link').style.display = 'none';
-	}
-	if (window.opener.$('sign_link')){
-		window.opener.$('sign_link').style.color = 'green';
-		window.opener.$('sign_link').setAttribute('onclick','');	
-	}
-	
-	if (window.opener.$('sign_link_certif')){
-		window.opener.$('sign_link_certif').style.color = 'green';
-		window.opener.$('sign_link_certif').setAttribute('onclick','');
-	}
-	if(window.opener.$('viewframevalidRep'+num_rep+'_'+oldRep)) {
-		window.opener.$('viewframevalidRep'+num_rep+'_'+oldRep).src = "index.php?display=true&module=attachments&page=view_attachment&res_id_master="+num_idMaster+"&id="+newId;	
-		window.opener.$('viewframevalidRep'+num_rep+'_'+oldRep).id = 'viewframevalidRep'+num_rep+'_'+newId;
-	}
-	
-	if(window.opener.$('ans_'+num_rep+'_'+oldRep)) {
-		window.opener.$('ans_'+num_rep+'_'+oldRep).setAttribute('onclick','updateFunctionModifRep(\''+newId+'\', '+num_rep+', 0);');	
-		$('ans_'+num_rep+'_'+oldRep).id = 'ans_'+num_rep+'_'+newId;				
-	}
-	
-	var zone_id = 'signedDoc_'+window.opener.$('cur_resId').value;
-	if (hasAllAnsSigned(window.opener.$('cur_resId').value) == 1){
-		window.opener.$(zone_id).style.visibility = 'visible';
-	}
-	else{
-		window.opener.$(zone_id).style.visibility = 'hidden';
-	}
-	
-	
-    window.close();
-}
-function generateWaybill(resId)
-{
-    //console.log("Génération du bordereau");
-    new Ajax.Request("index.php?display=true&module=visa&page=visa_waybill",
-            {
-                method: 'post',
-                parameters: {res_id: resId
-                },
-                asynchronous: false,
-                onSuccess: function (answer) {
-                    eval("response = " + answer.responseText);
-                    if (response.status == 1) {
-                        //console.log("path = "+response.path);
-                        //console.log("code = "+response.code);
-                        new Ajax.Request("index.php?display=true&module=visa&page=put_barcode",
-                                {
-                                    method: 'post',
-                                    parameters: {path: response.path,
-                                        res_id: resId,
-                                        code: response.code
-                                    },
-                                    asynchronous: false,
-                                    onSuccess: function (answer) {
-                                        eval("response2 = " + answer.responseText);
-                                        if (response2.status == 1) {
-                                            //console.log("path = "+response2.path);
-                                        }
-                                    }
-                                });
-                    }
-                }
-            });
-
-}
-
-function showNotesPage(id_tabricator) {
-    var tab = $(id_tabricator);
-    var tabDT = tab.getElementsByTagName('DT');
-    for (var i = 0; i < tabDT.length; i++) {
-        tabDT[i].setAttribute("class", "trig");
-        if (tabDT[i].id == "onglet_notes")
-            tabDT[i].setAttribute("class", "trig open");
-    }
-
-    var tabDD = tab.getElementsByTagName('DD');
-    for (var i = 0; i < tabDD.length; i++) {
-        tabDD[i].style.display = "none";
-        if (tabDD[i].id == "page_notes")
-            tabDD[i].style.display = "block";
-    }
-}
-
 function printFolder(res_id, coll_id, form_id, path) {
     //console.log("printFolder");
     new Ajax.Request(path,
diff --git a/modules/visa/visa_mail.php b/modules/visa/visa_mail.php
index 1c344e5eb3a..3291dd53dee 100644
--- a/modules/visa/visa_mail.php
+++ b/modules/visa/visa_mail.php
@@ -49,372 +49,7 @@ function writeLogIndex($EventInfo)
 
 function get_form_txt($values, $path_manage_action,  $id_action, $table, $module, $coll_id, $mode )
 {
-    //DECLARATIONS
-    include('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'definition_mail_categories.php');
-    require_once "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php";
-    require_once("core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_security.php");
-    require_once("apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_business_app_tools.php");
-    require_once("modules" . DIRECTORY_SEPARATOR . "basket" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php");
-    require_once("apps" . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_types.php");
-    require_once("core" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_request.php");
-    
-    //INSTANTIATE
-    $sec = new security();
-    $core_tools = new core_tools();
-    $b = new basket();
-    $type = new types();
-    $business = new business_app_tools();
-    $visa = new visa();
-    $db = new Database();
-
-    //INITIALIZE
-    $frm_str = '';
-    $_SESSION['stockCheckbox']= '';
-    unset($_SESSION['m_admin']['contact']);
-    $_SESSION['req'] = "action";
-    $res_id = $values[0];
-    $_SESSION['doc_id'] = $res_id;
-    $_SESSION['current_basket']['lastBasketFromAction'] = $_SESSION['current_basket']['id'];
-    $view = $sec->retrieve_view_from_coll_id($coll_id);
-    $stmt = $db->query("select alt_identifier,category_id, status from " . $view . " where res_id = ?", array($res_id));
-    $resChrono = $stmt->fetchObject();
-    $chrono_number = $resChrono->alt_identifier;
-    $cat_id = $resChrono->category_id;
-    //LAUNCH DOCLOCKER
-    $docLockerCustomPath = 'apps/maarch_entreprise/actions/docLocker.php';
-    $docLockerPath = $_SESSION['config']['businessappurl'] . '/actions/docLocker.php';
-    
-    if (is_file($docLockerCustomPath)){
-        require_once $docLockerCustomPath;
-    }else if (is_file($docLockerPath)){
-        require_once $docLockerPath;
-    }else{
-        exit("can't find docLocker.php");
-    }
-    
-    $docLocker = new docLocker($res_id);
-    if (!$docLocker->canOpen()) {
-        $docLockerscriptError = '<script>';
-        $docLockerscriptError .= 'destroyModal("modal_' . $id_action . '");';
-        $docLockerscriptError .= 'alert("' . _DOC_LOCKER_RES_ID . '' . $res_id . '' . _DOC_LOCKER_USER . ' ' . $_SESSION['userLock'] . '");';
-        $docLockerscriptError .= '</script>';
-        return $docLockerscriptError;
-    }
-
-    // DocLocker constantly 
-    $frm_str .= '<script>';
-    $frm_str .= 'docLockInterval = setInterval("new Ajax.Request(\'' . $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'lock\': true, \'res_id\': ' . $res_id . '} });", 5000);';
-    $frm_str .= '</script>';
-
-    $docLocker->lock();
-
-    //MODAL CONTENT
-    $frm_str .= '<h2 class="tit" id="action_title">' . _VISA_MAIL . ' ' . _NUM . '<span id="numIdDocPage">';
-
-    if(_ID_TO_DISPLAY == 'res_id'){
-        $frm_str .= $res_id;
-    } else if (_ID_TO_DISPLAY == 'chrono_number'){
-        $frm_str .= $chrono_number;
-    }
-
-    $frm_str .='</span>';
-
-    $frm_str .= '</h2>';
-    $frm_str .='<i onmouseover="this.style.cursor=\'pointer\';" ' . 'onclick="new Ajax.Request(\'' . $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': ' . $res_id . '}, onSuccess: function(answer){var cur_url=window.location.href; if (cur_url.indexOf(\'&directLinkToAction\') != -1) cur_url=cur_url.replace(\'&directLinkToAction\',\'\');window.location.href=cur_url;} });javascript:$(\'baskets\').style.visibility=\'visible\';destroyModal(\'modal_'.$id_action.'\');reinit();" class="fa fa-times-circle fa-2x closeModale" title="'._CLOSE.'"/>';
-    $frm_str .= '</i>';
-    $frm_str .= '<div>';
-    $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&page=show_visaListDocBasket_tab&module=visa&resId='. $res_id.'&collId='.$coll_id.'&view='.$view;
-    $frm_str .= '<i id="firstFrame" class="fa fa-arrow-circle-o-right fa-2x" style="margin-left: 13.8%;cursor: pointer" onclick="loadSpecificTab(\'show_visaListDocBasket_tab\',\''.$pathScriptTab.'\');manageFrame(this)"></i>';
-    $frm_str .= '<i id="secondFrame" class="fa fa-arrow-circle-o-left fa-2x" style="margin-left: 40.9%;cursor: pointer" onclick="manageFrame(this)"></i>';
-    $frm_str .= '<i id="thirdFrame" class="fa fa-arrow-circle-o-right fa-2x" style="margin-left: 0.6%;cursor: pointer" onclick="manageFrame(this)"></i>';
-    $frm_str .= '</div>';
-        
-    //List of documents
-    $frm_str .= '<div id="visa_listDoc" style="display:none;">';
-        $frm_str .= '<iframe src="" name="show_visaListDocBasket_tab" id="show_visaListDocBasket_tab"  scrolling="auto" frameborder="0"  style="width:100%;height:100%;" ></iframe></dd>';
-
-    $frm_str .= '</div>';
-
-    $frm_str .= '<div id="visa_left" style="display:none;">';
-
-    //TODO BEGIN OF CLEAN
-    $frm_str .= '<dl id="tabricatorLeft" >';
-	
-    //Onglet document
-    if ($cat_id != 'outgoing'){
-        $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=view_resource_controler&visu&id='. $res_id.'&collid='.$coll_id;
-        $frm_str .= '<dt id="onglet_entrant" style="padding-top: 6px;" onclick="loadSpecificTab(\'viewframevalidDoc\',\''.$pathScriptTab.'\');return false;">'._INCOMING.' <sup><span id="" style="'.$style2.'" class="'.$class.'"></span></sup></dt><dd style="overflow-y: hidden;">';
-        $frm_str .= '<iframe src="" name="viewframevalidDoc" id="viewframevalidDoc"  scrolling="auto" frameborder="0"  style="width:100%;height:100%;" ></iframe></dd>';
-
-        $frm_str .= '</dd>';
-        $frm_str .= '<script>$$(\'#onglet_entrant\')[0].click();</script>';
-    }else{
-        $frm_str .= '<script>$$(\'#visa_tab\')[0].click();</script>';
-    }
-	
-	
-    //Onglet Circuit 
-    $pathScriptTab = $_SESSION['config']['businessappurl'] . 'index.php?display=true&page=show_visa_tab&module=visa&resId='.$res_id.'&collId='.$coll_id.'&visaStep=true&destination='.$data['destination']['value'];
-    $frm_str .= '<dt id="visa_tab" style="padding-top: 6px;" onclick="loadSpecificTab(\'workflow_visa\',\''.$pathScriptTab.'\');return false;">'._VISA_WORKFLOW.'<span id="visa_tab_img"></span><span id="visa_tab_badge"></span></dt><dd id="page_circuit" style="overflow-x: hidden;">';
-    $frm_str .= '<h2>'._VISA_WORKFLOW.'</h2>';
-    $frm_str .= '<iframe src="" name="workflow_visa" width="100%" height="620px" align="left" scrolling="yes" frameborder="0" id="workflow_visa"></iframe>';
-    $frm_str .= '</dd>';
-    //LOAD TOOLBAR BADGE
-    $toolbarBagde_script = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=visa&page=load_toolbar_visa&resId='.$res_id.'&collId='.$coll_id;
-    $frm_str .='<script>loadToolbarBadge(\'visa_tab\',\''.$toolbarBagde_script.'\');</script>';
-
-
-    //Onglet Avancement 
-    $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=document_workflow_history&id='. $res_id .'&coll_id='. $coll_id.'&load&size=full';
-    $frm_str .= '<dt id="onglet_avancement" style="padding-top: 6px;" onclick="loadSpecificTab(\'workflow_history_document\',\''.$pathScriptTab.'\');return false;">Avancement <sup><span id="" style="'.$style2.'" class="'.$class.'"></span></sup></dt><dd id="page_avancement" style="overflow-x: hidden;">';
-    $frm_str .= '<h2>'. _WF .'</h2>';
-    $frm_str .= '<iframe src="" name="workflow_history_document" width="100%" height="620px" align="left" scrolling="yes" frameborder="0" id="workflow_history_document"></iframe>';
-    $frm_str .= '<br/>';
-    $frm_str .= '<br/>';
-
-    $pathScriptTab = $_SESSION['config']['businessappurl'].'index.php?display=true&dir=indexing_searching&page=document_history&id='. $res_id .'&coll_id='. $coll_id.'&load&size=full';
-    $frm_str .= '<span style="cursor: pointer;" onmouseover="this.style.cursor=\'pointer\';" onclick="new Effect.toggle(\'history_document\', \'blind\', {delay:0.2});whatIsTheDivStatus(\'history_document\', \'divStatus_all_history_div\');loadSpecificTab(\'history_document\',\''.$pathScriptTab.'\');return false;">';
-    $frm_str .= '<span id="divStatus_all_history_div" style="color:#1C99C5;"><i class="fa fa-plus-square-o"></i></span>';
-    $frm_str .= '<b>&nbsp;'. _ALL_HISTORY .'</b>';
-    $frm_str .= '</span>';
-    $frm_str .= '<iframe src="" name="history_document" width="100%" height="620px" align="left" scrolling="yes" frameborder="0" id="history_document" style="display:none;"></iframe>';
-
-    $frm_str .= '</dd>';
-	
-    //Onglet notes
-    if ($core->is_module_loaded('notes')) {
-
-        $pathScriptTab = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=notes&page=notes&identifier=' . $res_id . '&origin=document&coll_id=' . $coll_id . '&load&size=full';
-        $frm_str .= '<dt id="notes_tab" style="padding-top: 6px;" onclick="loadSpecificTab(\'list_notes_doc\',\'' . $pathScriptTab . '\');return false;">' . _NOTES . '<span id="notes_tab_img"></span><span id="notes_tab_badge"></span></dt><dd id="page_notes" style="overflow-x: hidden;"><h2>' . _NOTES . '</h2><iframe name="list_notes_doc" id="list_notes_doc" src="" frameborder="0" scrolling="yes" width="99%" height="570px"></iframe></dd> ';
-        
-        //LOAD TOOLBAR BADGE
-        $toolbarBagde_script = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=notes&page=load_toolbar_notes&resId='.$res_id.'&collId='.$coll_id;
-        $frm_str .='<script>loadToolbarBadge(\'notes_tab\',\''.$toolbarBagde_script.'\');</script>';
-    }
-    $frm_str .= '</dl>';
-    $frm_str .= '</div>';
-	
-    $frm_str .= '<div id="visa_right" style="display:none;">';
-    $frm_str .= '<div style="height:100%;">';
-    $frm_str .= '<dl id="tabricatorRight" >';
-    $tab_path_rep_file = $visa->get_rep_path($res_id, $coll_id);
-    $cptAttach = count($tab_path_rep_file);
-    if ($cptAttach < 6) {
-            $viewMode = 'extended';
-    } elseif ($cptAttach < 10) {
-            $viewMode = 'small';
-    } else {
-            $viewMode = 'verysmall';
-    }
-    for ($i = 0; $i < $cptAttach; $i++) {
-        $num_rep = $i + 1;
-        if ($viewMode == 'verysmall') {
-            $titleRep = $i + 1;
-        } elseif ($viewMode == 'small') {
-            $titleRep = substr($_SESSION['attachment_types'][$tab_path_rep_file[$i]['attachment_type']], 0, 10);
-        } else {
-            if (strlen($tab_path_rep_file[$i]['title']) > 15){
-                $titleRep = substr($_SESSION['attachment_types'][$tab_path_rep_file[$i]['attachment_type']], 0, 15) . '...';
-            }else{
-                $titleRep = $_SESSION['attachment_types'][$tab_path_rep_file[$i]['attachment_type']];
-            }
-        }
-        if ($tab_path_rep_file[$i]['attachment_type'] == 'signed_response') {
-            $titleRep = '<sup><i style="color:#fdd16c" class="fa fa-certificate fa-lg fa-fw"></i></sup>' . $titleRep;
-        }
-        $pathScriptTab = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=visa&page=view_pdf_attachement&res_id_master=' . $res_id . '&id=' . $tab_path_rep_file[$i]['res_id'];
-        $frm_str .= '<dt style="padding-top: 6px;" title="'
-                . $tab_path_rep_file[$i]['title'] . '" id="ans_' . $num_rep . '_' . $tab_path_rep_file[$i]['res_id'] . '" onclick="loadSpecificTab(\'viewframevalidRep' . $num_rep . '_' . $tab_path_rep_file[$i]['res_id'] . '\',\'' . $pathScriptTab . '\');updateFunctionModifRep(\''
-                . $tab_path_rep_file[$i]['res_id'] . '\', ' . $num_rep . ', ' . $tab_path_rep_file[$i]['is_version'] . ');">' . $titleRep
-                . ' <sup><span class="" style="" id=""></span></sup></dt><dd id="content_' . $num_rep . '_' . $tab_path_rep_file[$i]['res_id'] . '">';
-        $frm_str .= '<iframe src="" name="viewframevalidRep' . $num_rep . '" id="viewframevalidRep' . $num_rep . '_' . $tab_path_rep_file[$i]['res_id'] . '"  scrolling="auto" frameborder="0" style="width:100%;height:100%;" ></iframe>';
-        $frm_str .= '</dd>';
-        //$frm_str .= '<script>console.log('.$cptAttach.');</script>';
-        if($i==0){
-            $frm_str .= '<script>$$(\'#ans_' . $num_rep . '_' . $tab_path_rep_file[$i]['res_id'] . '\')[0].click();</script>';
-        }
-
-    }
-            
-    $pathScriptTab = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=attachments&page=frame_list_attachments&template_selected=documents_list_attachments_simple&load&attach_type_exclude=converted_pdf,print_folder';
-
-    $frm_str .= '<dt title="' . _ATTACHED_DOC .'" id="attachments_tab" style="padding-top: 6px;" onclick="loadSpecificTab(\'list_attach\',\''.$pathScriptTab.'\');$(\'cur_idAffich\').value=0;updateFunctionModifRep(0,0,0);">PJ<span id="attachments_tab_img"></span><span id="attachments_tab_badge"></span></dt><dd id="page_pj">';
-
-    //LOAD TOOLBAR BADGE
-    $toolbarBagde_script = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=attachments&page=load_toolbar_attachments&resId='.$res_id.'&collId='.$coll_id;
-    $frm_str .='<script>loadToolbarBadge(\'attachments_tab\',\''.$toolbarBagde_script.'\');</script>';
-        
-    if ($core_tools->is_module_loaded('attachments')) {
-        require 'modules/templates/class/templates_controler.php';
-        $templatesControler = new templates_controler();
-        $templates = array();
-        $templates = $templatesControler->getAllTemplatesForProcess($curdest);
-        $_SESSION['destination_entity'] = $curdest;
-        //var_dump($templates);
-        $frm_str .= '<div id="list_answers_div" onmouseover="this.style.cursor=\'pointer\';" style="width:100%;height:100%;">';
-            $frm_str .= '<div class="block" style="margin-top:-2px;height:95%;">';
-                $frm_str .= '<div id="processframe" name="processframe" style="height:100%;">';
-                    $frm_str .= '<center><h2>' . _PJ . ', ' . _ATTACHEMENTS . '</h2></center>';
-
-                    $frm_str .= '<div class="ref-unit">';
-
-                    $frm_str .= '<center>';
-                    if ($core_tools->is_module_loaded('templates')) {
-                        $frm_str .= '<input type="button" name="attach" id="attach" class="button" value="'
-                            . _CREATE_PJ
-                            .'" onclick="showAttachmentsForm(\'' . $_SESSION['config']['businessappurl']
-                            . 'index.php?display=true&module=attachments&page=attachments_content\')" />';
-                    }
-                    $frm_str .= '</center><iframe name="list_attach" id="list_attach" src="" '
-                    . 'frameborder="0" width="100%" scrolling="yes" height="600px" scrolling="yes" ></iframe>';
-                    $frm_str .= '</div>';
-                $frm_str .= '</div>';
-            $frm_str .= '</div>';
-            //$frm_str .= '<hr />';
-        $frm_str .= '</div>';
-    }
-	
-	
-    $frm_str .= '</dd>';
-
-
-    $frm_str .= '</dl>';
-    $frm_str .= '<div class="toolbar">';
-    $frm_str .= '<table style="width:100%;">';	
-
-    $frm_str .= '<tr>';
-    $frm_str .= '<td>';	
-    $frm_str .= '<form name="index_file" method="post" id="index_file" action="#" class="forms " style="text-align:left;">';
-    $frm_str .= 'Consigne &nbsp;<input type="text" value="'.$visa->getConsigne($res_id, $coll_id, $_SESSION['user']['UserId']).'" style="width:50%;" readonly class="readonly"/><br/>';
-    
-    //GET ACTION LIST BY AJAX REQUEST
-    $frm_str .= '<span id="actionSpan"></span>';
-    $frm_str .= '<script>';
-        $frm_str .= 'change_category_actions(\'' 
-            . $_SESSION['config']['businessappurl'] 
-            . 'index.php?display=true&dir=indexing_searching&page=change_category_actions'
-            . '&resId=' . $res_id . '&collId=' . $coll_id . '\',\'' . $res_id . '\',\'' . $coll_id . '\',\''.$cat_id.'\');';
-    $frm_str .= '</script>';
-    $frm_str .= '<input type="button" name="send" id="send_action" value="'._VALIDATE.'" class="button" onclick="new Ajax.Request(\'' 
-            . $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': ' . $res_id . '} });valid_action_form( \'index_file\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$res_id.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');"/> ';
-    //
-    
-    /*$frm_str .= '<b>'._ACTIONS.' : </b>';
-    $actions  = $b->get_actions_from_current_basket($res_id, $coll_id, 'PAGE_USE');
-    if(count($actions) > 0)
-    {
-        $frm_str .='<select name="chosen_action" id="chosen_action">';
-        $frm_str .='<option value="">'._CHOOSE_ACTION.'</option>';
-        for($ind_act = 0; $ind_act < count($actions);$ind_act++)
-        {
-            if (!($actions[$ind_act]['VALUE'] == "end_action" && $visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT') == $visa->nbVisa($res_id, $coll_id))){
-                $frm_str .='<option value="'.$actions[$ind_act]['VALUE'].'"';
-                if($ind_act==0)
-                {
-                    $frm_str .= 'selected="selected"';
-                }
-                $frm_str .= '>'.$actions[$ind_act]['LABEL'].'</option>';
-            }
-        }
-        $frm_str .='</select> ';
-        $table = $sec->retrieve_table_from_coll($coll_id);
-        $frm_str .= '<input type="button" name="send" id="send_action" value="'._VALIDATE.'" class="button" onclick="new Ajax.Request(\'' 
-            . $_SESSION['config']['businessappurl'] . 'index.php?display=true&dir=actions&page=docLocker\',{ method:\'post\', parameters: {\'AJAX_CALL\': true, \'unlock\': true, \'res_id\': ' . $res_id . '} });valid_action_form( \'index_file\', \''.$path_manage_action.'\', \''. $id_action.'\', \''.$res_id.'\', \''.$table.'\', \''.$module.'\', \''.$coll_id.'\', \''.$mode.'\');"/> ';
-    }*/
-
-
-    $frm_str .= '<input type="hidden" name="cur_rep" id="cur_rep" value="'.$tab_path_rep_file[0]['res_id'].'" >';
-    $frm_str .= '<input type="hidden" name="cur_idAffich" id="cur_idAffich" value="1" >';
-    $frm_str .= '<input type="hidden" name="cur_resId" id="cur_resId" value="'.$res_id.'" >';
-    $frm_str .= '<input type="hidden" name="list_docs" id="list_docs" value="'.$list_docs.'" >';
-
-    $frm_str .= '<input type="hidden" name="values" id="values" value="'.$res_id.'" />';
-    $frm_str .= '<input type="hidden" name="action_id" id="action_id" value="'.$id_action.'" />';
-    $frm_str .= '<input type="hidden" name="mode" id="mode" value="'.$mode.'" />';
-    $frm_str .= '<input type="hidden" name="table" id="table" value="'.$table.'" />';
-    $frm_str .= '<input type="hidden" name="coll_id" id="coll_id" value="'.$coll_id.'" />';
-    $frm_str .= '<input type="hidden" name="module" id="module" value="'.$module.'" />';
-    $frm_str .= '<input type="hidden" name="category_id" id="category_id" value="'.$cat_id.'" />';
-    $frm_str .= '<input type="hidden" name="req" id="req" value="second_request" />';
-
-
-    //$frm_str .= '<input type="hidden" name="next_resId" id="next_resId" value="'.$nextId.'" >';
-    $frm_str .= '</form>';
-    $frm_str .= '</td>';
-    $frm_str .= '<td style="width:25%;">';	
-    //if ($core->test_service('sign_document', 'visa', false) && $currentStatus == 'ESIG') {
-    if ($core->test_service('sign_document', 'visa', false) ) {
-            $color = ' style="float:left;color:#666;" ';
-            $img = '<img id="sign_link_img" src="'.$_SESSION['config']['businessappurl'].'static.php?filename=sign.png" title="Signer ces projets de réponse (sans certificat)" />';
-            if ($tab_path_rep_file[0]['attachment_type'] == 'signed_response'){
-                    $color = ' style="float:left;color:green;cursor:not-allowed;" ';
-                    $img = '<img id="sign_link_img" src="'.$_SESSION['config']['businessappurl'].'static.php?filename=sign_valid.png" title="Enlever la signature" />';
-            } 
-
-            if ($_SESSION['modules_loaded']['visa']['showAppletSign'] == "true"){
-                    $frm_str .= '<a href="javascript://" id="sign_link_certif" '.$color.' onclick="';
-                    if ($tab_path_rep_file[0]['attachment_type'] != 'signed_response') $frm_str .= 'signFile('.$tab_path_rep_file[0]['res_id'].','.$tab_path_rep_file[0]['is_version'].',0);';
-                    $frm_str .= '"><i class="fm fm-file-fingerprint fm-3x" title="Signer ces projets de réponse (avec certificat)"></i></a>';
-            }
-            if ($tab_path_rep_file[0]['attachment_type'] != 'signed_response'){
-                    $frm_str .= ' <a href="javascript://" id="sign_link" '.$color.' onclick="';
-                    $frm_str .= 'signFile('.$tab_path_rep_file[0]['res_id'].','.$tab_path_rep_file[0]['is_version'].',2);';
-            }else{
-                    $frm_str .= ' <a target="list_attach" href="';
-                    $frm_str .= 'index.php?display=true&module=attachments&page=del_attachment&relation=1&id='.$tab_path_rep_file[0]['res_id'];
-            } 
-            $frm_str .= '" id="sign_link" '.$color.'>'.$img.'</a>';
-    }
-
-    $displayModif = ' style="float:right;" ';
-    if ($tab_path_rep_file[0]['attachment_type'] == 'signed_response')
-            $displayModif = ' style="float:right;display:none;" ';
-
-    $frm_str .= ' <a href="javascript://" id="update_rep_link" '.$displayModif.'onclick="';
-
-    /*if ($tab_path_rep_file[0]['attachment_type'] == 'outgoing_mail'){
-            $frm_str .= 'window.open(\''
-    . $_SESSION['config']['businessappurl'] . 'index.php?display=true'
-    . '&module=content_management&page=applet_popup_launcher&objectType=resourceEdit'
-    . '&objectId='
-    . $tab_path_rep_file[0]['res_id']
-    . '&objectTable='
-    . $table
-    . '\', \'\', \'height=200, width=250,scrollbars=no,resizable=no,directories=no,toolbar=no\');';
-    }
-    else*/ 
-    if ($tab_path_rep_file[0]['is_version'] == 0 || $tab_path_rep_file[0]['is_version'] == 2) {
-        $frm_str .= 'modifyAttachmentsForm(\''.$_SESSION['config']['businessappurl'] 
-            . 'index.php?display=true&module=attachments&page=attachments_content&id='
-            . $tab_path_rep_file[0]['res_id'] . '&relation=1&fromDetail=\',\'98%\',\'auto\');';
-    } else {
-       $frm_str .= 'modifyAttachmentsForm(\''.$_SESSION['config']['businessappurl'] 
-            . 'index.php?display=true&module=attachments&page=attachments_content&id='
-            . $tab_path_rep_file[0]['res_id'] . '&relation=2&fromDetail=\',\'98%\',\'auto\');';
-    }
-    $frm_str .= '"><i class="fa fa-pencil-square-o fa-3x" title="Modifier la réponse"></i></a>';
-
-    $frm_str .= '</td>';
-    $frm_str .= '</tr>';	
-    $frm_str .= '</table>';	
-
-    $frm_str .= '</div>';
-    $frm_str .= '</div>';
-
-    $frm_str .= '<div id="modalPIN">';
-    $frm_str .= '<p id="badPin" style="display:none;color:red;font-weight:bold;text-align:center;margin-top: -15px">'. _BAD_PIN .'</p>';
-    $frm_str .= '<label for="valuePIN">Saisissez votre code PIN</label>';
-    $frm_str .= '<input type="password" name="valuePIN" id="valuePIN" onKeyPress="if (event.keyCode == 13) signFile('.$tab_path_rep_file[0]['res_id'].','.$tab_path_rep_file[0]['is_version'].',\'\', $(\'valuePIN\').value);"/><br/>';
-    $frm_str .= '<input type="button" name="sendPIN" id="sendPIN" value="'._VALIDATE.'" class="button" onclick="signFile('.$tab_path_rep_file[0]['res_id'].','.$tab_path_rep_file[0]['is_version'].',\'\', $(\'valuePIN\').value);" />';
-    $frm_str .= '&nbsp;<input type="button" name="cancelPIN" id="cancelPIN" value="'._CANCEL.'" class="button" onclick="$(\'badPin\').style.display = \'none\';$(\'modalPIN\').style.display = \'none\';" />';
-    $frm_str .= '</div>';
-
-    /*** Extra javascript ***/
-    $frm_str .= '<script type="text/javascript">launchTabri();window.scrollTo(0,0);$(\'divList\').style.display = \'none\';';
-    $frm_str .='var height = (parseInt($(\'visa_left\').parentElement.style.height.replace(/px/,""))-65)+"px";$(\'visa_listDoc\').style.height=height;$(\'visa_left\').style.height=height;$(\'visa_right\').style.height=height;$(\'tabricatorRight\').style.height=(parseInt($(\'tabricatorRight\').offsetHeight)-20)+"px";height = (parseInt($(\'tabricatorRight\').offsetHeight)-150)+"px";$(\'list_attach\').style.height=height;';
-    $frm_str .= '$(\'visa_left\').style.display=\'block\';$(\'visa_right\').style.display=\'block\';manageFrame(\'firstFrame\');';
-    $frm_str .='</script>';
-    return addslashes($frm_str);
+    //Keep this file because of manage action
 }
 
 /**
@@ -474,39 +109,6 @@ function get_value_fields($values, $field)
 function manage_form($arr_id, $history, $id_action, $label_action, $status,  $coll_id, $table, $values_form )
 {
 	$res_id = $arr_id[0];
-	
-	$act_chosen = get_value_fields($values_form, 'chosen_action');
-	
-	/*if ($act_chosen == "end_action"){
-		require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php");
-		require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
-		$sec = new security();
-		
-		
-		$replaceValues = array();
-		array_push(
-			$replaceValues,
-			array(
-				'column' => 'process_date',
-				'value' => 'CURRENT_TIMESTAMP',
-				'type' => 'date',
-			)
-		);
-		$where = 'res_id = ? and item_id = ? and difflist_type = ?';
-		$array_what[] = $res_id;
-		$array_what[] = $_SESSION['user']['UserId'];
-		$array_what[] = 'VISA_CIRCUIT';
-		
-		$request = new request();
-		$table = 'listinstance';
-		$request->PDOupdate($table, $replaceValues, $where, $array_what, $_SESSION['config']['databasetype']);
-		
-		$circuit_visa = new visa();
-		if ($circuit_visa->allUserVised($res_id, $coll_id, 'VISA_CIRCUIT')){
-			$up_request = "UPDATE res_letterbox SET status='ESIG' WHERE res_id = $res_id";
-			$db = new Database();
-			$db->query("UPDATE res_letterbox SET status='ESIG' WHERE res_id = ?", array($res_id));
-		}
-	}*/
+
     return array('result' => $res_id.'#', 'history_msg' => '');
 }
-- 
GitLab