Newer
Older
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";
} else {
firstDiv.style.display = "";
}
} else if (button.id == "secondFrame") {
if (secondDiv.style.display != "none") {
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") {
$("thirdFrame").style.marginLeft = "0.6%";
} else if (firstDiv.style.display != "none" && (secondDiv.style.display == "none" || thirdDiv.style.display == "none")) {
$("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%";
$("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 refreshIcones(id_tableau){
var tableau = document.getElementById(id_tableau);
var arrayLignes = tableau.rows; //l'array est stocké dans une variable
var longueur = arrayLignes.length;//on peut donc appliquer la propriété length
var i=1; //on définit un incrémenteur qui représentera la clé
while(i<longueur)
{
var disabledLine = false;
//Maj de la couleur de ligne
if(i % 2 == 0)
{
arrayLignes[i].className = "";
}
else
{
arrayLignes[i].className = "col";
}
var num = i-1;
if (arrayLignes[i].cells[0].childNodes[1].disabled == true)
disabledLine = true;
//MAJ id et name
//arrayLignes[i].cells[0].innerHTML = i;
arrayLignes[i].cells[0].childNodes[0].id = "rank_" + num;
arrayLignes[i].cells[0].childNodes[1].name = "conseiller_"+num;
arrayLignes[i].cells[0].childNodes[1].id="conseiller_"+num;
if(arrayLignes[i].cells[0].childNodes[2]){
arrayLignes[i].cells[0].childNodes[2].id = "signatory_" + num;
}
arrayLignes[i].cells[1].childNodes[0].name = "down_"+num;
arrayLignes[i].cells[1].childNodes[0].id="down_"+num;
document.getElementById("down_"+num).setAttribute('onclick','deplacerLigne(this.parentNode.parentNode.rowIndex, this.parentNode.parentNode.rowIndex+2, \''+id_tableau+'\');');
arrayLignes[i].cells[2].childNodes[0].name = "up_"+num; arrayLignes[i].cells[2].childNodes[0].id="up_"+num;
document.getElementById("up_"+num).setAttribute('onclick','deplacerLigne(this.parentNode.parentNode.rowIndex, this.parentNode.parentNode.rowIndex-1, \''+id_tableau+'\');');
arrayLignes[i].cells[3].childNodes[0].name = "suppr_"+num; arrayLignes[i].cells[3].childNodes[0].id="suppr_"+num;
arrayLignes[i].cells[4].childNodes[0].name = "add_"+num; arrayLignes[i].cells[4].childNodes[0].id="add_"+num;
arrayLignes[i].cells[5].childNodes[0].name = "consigne_"+num; arrayLignes[i].cells[5].childNodes[0].id="consigne_"+num;
arrayLignes[i].cells[6].childNodes[0].name = "date_"+num; arrayLignes[i].cells[6].childNodes[0].id="date_"+num;
arrayLignes[i].cells[7].childNodes[0].name = "isSign_"+num; arrayLignes[i].cells[7].childNodes[0].id="isSign_"+num;
document.getElementById("rank_" + num).innerHTML = "<span class='nbResZero' style='font-weight:bold;opacity:0.5;'>"+i+"</span> ";
if (longueur > 2)
document.getElementById("suppr_"+num).style.visibility="visible";
else
document.getElementById("suppr_"+num).style.visibility="hidden";
if (i > 1)
document.getElementById("up_"+num).style.visibility="visible";
else
document.getElementById("up_"+num).style.visibility="hidden";
if(arrayLignes[i].cells[0].childNodes[2]){
arrayLignes[i].cells[0].childNodes[2].style.visibility = "hidden";
}
document.getElementById("add_"+num).style.visibility="hidden";
document.getElementById("isSign_"+num).style.visibility="hidden";
document.getElementById("isSign_"+num).checked=false;
//document.getElementById("signatory_" + num).innerHTML = "";
document.getElementById("down_"+num).style.visibility="visible";
}
else {
document.getElementById("add_"+num).style.visibility="visible";
document.getElementById("isSign_"+num).style.visibility="hidden";
document.getElementById("isSign_"+num).checked=true;
if(document.getElementById("signatory_"+num)){
document.getElementById("signatory_"+num).innerHTML = " <i title='Signataire' style='color : #fdd16c' class='fa fa-certificate fa-lg fa-fw'></i>";
}
document.getElementById("down_"+num).style.visibility="hidden";
/* Ajout des conditions pour les lignes disabled */
if (disabledLine){
document.getElementById("suppr_"+num).style.visibility="hidden";
document.getElementById("down_"+num).style.visibility="hidden";
//document.getElementById("up_"+num).style.visibility="hidden";
document.getElementById("isSign_"+num).style.visibility="hidden";
}
if (num > 0) {
prev_num = num-1;
//console.log(document.getElementById('conseiller_'+prev_num));
if (arrayLignes[i-1].cells[0].childNodes[1].disabled == true){
document.getElementById("up_"+num).style.visibility="hidden";
document.getElementById("suppr_"+num).style.visibility="hidden";
}
/*************************************************/
if (i == longueur-1 && document.getElementById("signatory_"+num)){
document.getElementById("signatory_"+num).style.visibility="visible";
}
function addRow(id_tableau)
{
var tableau = document.getElementById(id_tableau);
var ligne = tableau.insertRow(-1);//on a ajouté une ligne
var position = ligne.rowIndex;
if (position%2 == 1) ligne.className = "col";
/*var colonne1 = ligne.insertCell(0);//on a une ajouté une cellule
colonne1.innerHTML += position;//on y met la position
*/
var id_Cons = "conseiller_0";
var last_select = tableau.rows.length-3;
//var listeDeroulante = document.getElementById(id_Cons);
var listeDeroulante = document.getElementById('conseiller_'+last_select);
var colonne2 = ligne.insertCell(0);//on ajoute la seconde cellule
var listOptions = "";
listOptions=listeDeroulante.innerHTML;
colonne2.innerHTML += "<span id='rank_" + position + "'></span><select>"+listOptions+"</select><span id='signatory_" + position + "'><i title=\"Signataire\" style=\"color : #fdd16c;visibility:visible;\" class=\"fa fa-certificate fa-lg fa-fw\"></i></span>";
//colonne2.innerHTML += "</select>";
var colonne3 = ligne.insertCell(1);

Nicolas Couture
committed
//colonne3.innerHTML += "<img src=\"static.php?filename=DownUser.png&module=visa\" id=\"down_"+position+"\" name=\"down_"+position+"\" onclick=\"deplacerLigne(this.parentNode.parentNode.rowIndex, this.parentNode.parentNode.rowIndex+2, '"+id_tableau+"')\" style=\"visibility:hidden;\"/>";
colonne3.innerHTML += "<a href=\"javascript://\" id=\"down_"+position+"\" name=\"down_"+position+"\" onclick=\"deplacerLigne(this.parentNode.parentNode.rowIndex, this.parentNode.parentNode.rowIndex+2, '"+id_tableau+"')\" style=\"visibility:hidden;\" ><i class=\"fa fa-arrow-down fa-2x\" title=\"Déplacer l'utilisateur vers le bas\"></i></a>";

Nicolas Couture
committed
//colonne4.innerHTML += "<img src=\"static.php?filename=UpUser.png&module=visa\" id=\"up_"+position+"\" name=\"up_"+position+"\" onclick=\"deplacerLigne(this.parentNode.parentNode.rowIndex, this.parentNode.parentNode.rowIndex-1, '"+id_tableau+"')\" style=\"visibility:visible;\"/>";
colonne4.innerHTML += "<a href=\"javascript://\" id=\"up_"+position+"\" name=\"up_"+position+"\" onclick=\"deplacerLigne(this.parentNode.parentNode.rowIndex, this.parentNode.parentNode.rowIndex-1, '"+id_tableau+"')\" style=\"visibility:visible;\" ><i class=\"fa fa-arrow-up fa-2x\" title=\"Déplacer l'utilisateur vers le haut\"></i></a>";

Nicolas Couture
committed
//colonne5.innerHTML += "<img src=\"static.php?filename=SupprUser.png&module=visa\" id=\"suppr_"+position+"\" name=\"suppr_"+position+"\" onclick=\"delRow(this.parentNode.parentNode.rowIndex, '"+id_tableau+"')\" style=\"visibility:visible;\"/>";
colonne5.innerHTML += "<a href=\"javascript://\" onclick=\"delRow(this.parentNode.parentNode.rowIndex, '"+id_tableau+"')\" id=\"suppr_"+position+"\" name=\"suppr_"+position+"\" style=\"visibility:visible;\" ><i class=\"fa fa-user-times fa-2x\" title=\"Retirer l'utilisateur du circuit\"></i></a>";

Nicolas Couture
committed
//colonne6.innerHTML += "<img src=\"static.php?filename=AjoutUser.png&module=visa\" id=\"add_"+position+"\" name=\"add_"+position+"\" onclick=\"addRow('"+id_tableau+"')\"style=\"visibility:visible;\"/>";
colonne6.innerHTML += "<a href=\"javascript://\" id=\"add_"+position+"\" name=\"add_"+position+"\" onclick=\"addRow('"+id_tableau+"')\"style=\"visibility:visible;\" ><i class=\"fa fa-user-plus fa-2x\" title=\"Ajouter un utilisateur dans le circuit\"></i></a>";
colonne7.innerHTML += "<input type=\"text\" id=\"consigne_"+position+"\" name=\"consigne_"+position+"\" value=\""+document.getElementById('consigne_'+last_select).value+"\" style=\"width:95%;\"/>";
var colonne8 = ligne.insertCell(6);
colonne8.style.display = 'none';
colonne8.innerHTML += "<input type=\"hidden\" id=\"date_"+position+"\" name=\"date_"+position+"\"/>";
var colonne9 = ligne.insertCell(7);
colonne9.style.display = 'none';
colonne9.innerHTML += "<input type=\"checkbox\" id=\"isSign_"+position+"\" name=\"isSign_"+position+"\"/>";
var colonne10 = ligne.insertCell(8);
//colonne10.style.display = 'none';
colonne10.innerHTML += '<i class="fa fa-plus fa-lg" title="Nouvel utilisateur ajouté"></i>';
//document.getElementById('consigne_'+last_select).value = "";
refreshIcones(id_tableau);
}
function delRow(num, id_tableau){
document.getElementById(id_tableau).deleteRow(num);
refreshIcones(id_tableau);
}
function deplacerLigne(source, cible, id_tableau)
{
var tableau = document.getElementById(id_tableau);
//on initialise nos variables
var ligne = tableau.rows[source];//on copie la ligne
var nouvelle = tableau.insertRow(cible);//on insère la nouvelle ligne
var cellules = ligne.cells;
//on boucle pour pouvoir agir sur chaque cellule
for(var i=0; i<cellules.length; i++)
{
//console.log(cellules[i].innerHTML);
//console.log(cellules[i].);
nouvelle.insertCell(-1).innerHTML += cellules[i].innerHTML;//on copie chaque cellule de l'ancienne à la nouvelle ligne
/*if (i == 6 && cellules[i].childNodes[0].value != ""){
nouvelle.cells[5].childNodes[0].value = cellules[i].childNodes[0].value;
nouvelle.cells[0].childNodes[1].selectedIndex = cellules[i].childNodes[1].selectedIndex;
if(i == 5){
nouvelle.cells[5].childNodes[0].value = cellules[i].childNodes[0].value;
//console.log(cellules[i].childNodes[0].value);
}
nouvelle.cells[i].style.display = 'none';*/
if (i == 7 || i == 6){
nouvelle.cells[i].style.display = 'none';
}
//on supprimer l'ancienne ligne
tableau.deleteRow(ligne.rowIndex);//on met ligne.rowIndex et non pas source car le numéro d'index a pu changer
refreshIcones(id_tableau);
}
function saveVisaWorkflow(res_id, coll_id, id_tableau, fromDetail){
var tableau = document.getElementById(id_tableau);
var arrayLignes = tableau.rows; //l'array est stocké dans une variable
var longueur = arrayLignes.length;//on peut donc appliquer la propriété length
var i=1; //on définit un incrémenteur qui représentera la clé
var conseillers = "";
var consignes = "";
var dates = "";
var isSign = "";

Nicolas Couture
committed
var cons_empty = false;
var detail = "";
if (fromDetail == undefined || fromDetail == "N" ) {
detail = "N";
} else if (fromDetail == "Y") {
detail = "Y";
}
while(i<longueur)
{
var num = i-1;

Nicolas Couture
committed
if (document.getElementById("conseiller_"+num).value == "" ) cons_empty = true;
conseillers += document.getElementById("conseiller_"+num).value + "#";
consignes += document.getElementById("consigne_"+num).value + "#";
dates += document.getElementById("date_"+num).value + "#";
if (document.getElementById("isSign_"+num).checked == true) isSign += "1#";
else isSign += "0#";
$('divErrorVisa').innerHTML = 'Sélectionner au moins un utilisateur';
$('divErrorVisa').style.display = 'table-cell';
Element.hide.delay(5, 'divErrorVisa');

Nicolas Couture
committed
}
new Ajax.Request("index.php?display=true&module=visa&page=saveVisaWF",
{
method:'post',
parameters: {
res_id : res_id,
coll_id : coll_id,
conseillers : conseillers,
consignes : consignes,
dates : dates,
fromDetail : detail,
cons_empty : cons_empty
},
onSuccess: function(answer){
eval("response = "+answer.responseText);
$('divInfoVisa').innerHTML = 'Mise à jour du circuit effectuée';
$('divInfoVisa').style.display = 'table-cell';
Element.hide.delay(5, 'divInfoVisa');
eval(response.exec_js);
} else if (response.status == 2){
$('divErrorVisa').innerHTML = 'Sélectionner au moins un utilisateur';
$('divErrorVisa').style.display = 'table-cell';
Element.hide.delay(5, 'divErrorVisa');
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
function resetVisaWorkflow(res_id, coll_id, id_tableau, fromDetail){
var tableau = document.getElementById(id_tableau);
var arrayLignes = tableau.rows; //l'array est stocké dans une variable
var longueur = arrayLignes.length;//on peut donc appliquer la propriété length
var i=1; //on définit un incrémenteur qui représentera la clé
var conseillers = "";
var consignes = "";
var dates = "";
var isSign = "";
var cons_empty = false;
var detail = "";
if (fromDetail == undefined || fromDetail == "N" ) {
detail = "N";
} else if (fromDetail == "Y") {
detail = "Y";
}
while(i<longueur)
{
var num = i-1;
if (document.getElementById("conseiller_"+num).value == "" ) cons_empty = true;
conseillers += document.getElementById("conseiller_"+num).value + "#";
consignes += document.getElementById("consigne_"+num).value + "#";
dates += document.getElementById("date_"+num).value + "#";
if (document.getElementById("isSign_"+num).checked == true) isSign += "1#";
else isSign += "0#";
i++;
}
new Ajax.Request("index.php?display=true&module=visa&page=resetVisaWF",
{
method:'post',
parameters: {
res_id : res_id,
coll_id : coll_id,
conseillers : conseillers,
consignes : consignes,
dates : dates,
list_sign : isSign,
fromDetail : detail,
cons_empty : cons_empty
},
onSuccess: function(answer){
eval("response = "+answer.responseText);
location.reload();
}
});
}

Damien
committed
function load_listmodel_visa(selectedOption, objectType, diff_list_id, save_auto) {
if (save_auto == undefined || save_auto == '') {
save_auto = false;
}

Damien
committed
var div_id = diff_list_id || 'tab_visaSetWorkflow';

Nicolas Couture
committed
var objectId = selectedOption.value || selectedOption;

Nicolas Couture
committed
var diff_list_div = $(div_id);

Damien
committed
new Ajax.Request("index.php?display=true&module=visa&page=load_listmodel_visa",
{
method:'post',
parameters: {
objectType : objectType,
objectId : objectId

Nicolas Couture
committed
},

Damien
committed
onSuccess: function(answer){
eval("response = "+answer.responseText);
if(response.status == 0 ) {

Nicolas Couture
committed
diff_list_div.innerHTML = response.div_content;
if (save_auto){
var res_id = $('values').value;
var coll_id = $('coll_id').value;
saveVisaWorkflow(res_id, coll_id, diff_list_id);
}

Damien
committed
} else if (response.status != 1 ){

Nicolas Couture
committed
diff_list_div.innerHTML = '';

Damien
committed
try{
$('frm_error').innerHTML = response.error_txt;
} catch(e){}
}
}
}

Nicolas Couture
committed
);
}

Damien
committed
function triggerFlashMsg($divName, $msg) {
var div = $($divName);
div.innerHTML = $msg;
div.style.display = 'table-cell';
Element.hide.delay(5, $divName);
}
function saveVisaModel(id_tableau) {
var tableau = document.getElementById(id_tableau);
var title = $('titleModel').value;
var id_list = $('objectId_input').value;

Nicolas Couture
committed
var arrayLignes = tableau.rows; //l'array est stocké dans une variable

Damien
committed
var longueur = arrayLignes.length;//on peut donc appliquer la propriété length

Nicolas Couture
committed
var conseillers = "";

Damien
committed
var consignes = "";
var isSign = "";
var cons_empty = false;
var i = 1;
while(i < longueur)

Nicolas Couture
committed
{

Damien
committed
var num = i - 1;
if (document.getElementById("conseiller_"+num).value == "" )
cons_empty = true;
conseillers += document.getElementById("conseiller_"+num).value + "#";
consignes += document.getElementById("consigne_"+num).value + "#";

Nicolas Couture
committed

Damien
committed
if (document.getElementById("isSign_"+num).checked == true)
isSign += "1#";
else
isSign += "0#";

Nicolas Couture
committed
i++;
}

Damien
committed

Nicolas Couture
committed
if (cons_empty){

Damien
committed
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
triggerFlashMsg('divErrorVisa', 'Sélectionner au moins un utilisateur');
} else if (title == "") {
triggerFlashMsg('divErrorVisa', 'Titre manquant');
} else {
new Ajax.Request("index.php?display=true&module=visa&page=getVisaModelByTitle",
{
method: 'GET',
dataType: 'JSON',
parameters: {
title: title
},
onSuccess: function (responseValue) {
var response = JSON.parse(responseValue.responseText);
if (response.isWorkflowTitleFree) {
new Ajax.Request("index.php?display=true&module=visa&page=saveVisaModel",
{
method:'POST',
parameters: {
title : title,
id_list : id_list,
list_sign : isSign,
consignes : consignes,
conseillers : conseillers
},
onSuccess: function(responseValue){
var response = JSON.parse(responseValue.responseText);
if (response.status == 1){
triggerFlashMsg('divInfoVisa', 'Modèle sauvegardé');
$('modalSaveVisaModel').style.display = 'none';
}
}
});
} else {
triggerFlashMsg('divErrorVisa', 'Titre déjà utilisé pour un modèle');
}

Nicolas Couture
committed
}

Damien
committed
});
}

Nicolas Couture
committed
}

Damien
committed
/* 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(){

Damien
committed
var tabricatorRight = new Tabricator('tabricatorRight', 'DT');

Nicolas Couture
committed
var tabricatorLeft = new Tabricator('tabricatorLeft', 'DT');

Nicolas Couture
committed
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
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 !");
}
});
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
}
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 !");
}
});

Nicolas Couture
committed
function previousDoc(path_update,collId){
var current = parent.$('cur_resId').value;
$('list_doc_'+current).previousSibling.click();

Nicolas Couture
committed
}
function nextDoc(path_update,collId){
var current = parent.$('cur_resId').value;
$('list_doc_'+current).nextSibling.click();

Nicolas Couture
committed
function updateFunctionModifRep(idReponse, num_rep, is_version){
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';

Nicolas Couture
committed
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;
}

Nicolas Couture
committed
function signFile(res_id,isVersion, mode, pinCode){
var reg = /^[0-9]{4}$/;

Nicolas Couture
committed
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
}
});
}
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;
}

Nicolas Couture
committed
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){
}
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');

Nicolas Couture
committed
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');

Nicolas Couture
committed
}
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);
}

Nicolas Couture
committed
}
}
//load applet in a modal
function loadAppletSign(url){
displayModal(url, 'VisaApplet', 300, 300);
}
function translateError(key){
var message = "";