282 lines
10 KiB
JavaScript
282 lines
10 KiB
JavaScript
//<script language="Javascript">
|
|
|
|
var arSigneErreurLayers = new Array();
|
|
arSigneErreurLayers[0]='erreur';
|
|
|
|
|
|
function validRequestSAA(objLink,nbBalAccreditees){
|
|
var sDiv,sBal,sUrl,i, vFlag,size;
|
|
|
|
size = nbBalAccreditees;
|
|
|
|
sDiv='<div class="clErreur">';
|
|
|
|
// on enlève les coches des zones supplémentaires vides
|
|
if (window.document.frmForm1.txt_bs1.value=='') window.document.frmForm1.chk_bs1.checked=false;
|
|
if (window.document.frmForm1.txt_bs2.value=='') window.document.frmForm1.chk_bs2.checked=false;
|
|
|
|
// on teste que les BAL supplémentaires ne correspondent pas à l'une des BAL accréditées
|
|
if (window.document.frmForm1.chk_bs1.checked) {
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) {
|
|
if (window.document.frmForm1.txt_bs1.value.toUpperCase()==window.document.frmForm1.chk_b[i].value) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED2'] + window.document.frmForm1.txt_bs1.value + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.txt_bs1.value.toUpperCase()==window.document.frmForm1.chk_b.value) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED2'] + window.document.frmForm1.txt_bs1.value + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (window.document.frmForm1.chk_bs2.checked) {
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) {
|
|
if (window.document.frmForm1.txt_bs2.value.toUpperCase()==window.document.frmForm1.chk_b[i].value) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED2'] + window.document.frmForm1.txt_bs2.value + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.txt_bs2.value.toUpperCase()==window.document.frmForm1.chk_b.value) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED2'] + window.document.frmForm1.txt_bs2.value + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
}
|
|
|
|
// on teste que les deux BAL supplémentaires soient différentes l'une de l'autre
|
|
if (window.document.frmForm1.chk_bs1.checked & window.document.frmForm1.chk_bs2.checked & (window.document.frmForm1.txt_bs1.value.toUpperCase()==window.document.frmForm1.txt_bs2.value.toUpperCase())) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED2'] + window.document.frmForm1.txt_bs1.value + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
|
|
// on teste qu'il y ait au moins une case de cochée dans les BAL accréditées
|
|
i=0;
|
|
vFlag = false;
|
|
if (size != 1) {
|
|
{while (i<size & !vFlag) {if (window.document.frmForm1.chk_b[i++].checked) vFlag=true;}}
|
|
if (!vFlag) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED1'] + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_b.checked) vFlag=true;
|
|
if (!vFlag) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED7'] + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
|
|
// on teste qu'il n'y ait pas plus de trois BAL sélectionnées
|
|
vFlag=0;
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) if (window.document.frmForm1.chk_b[i].checked) vFlag++;
|
|
if (window.document.frmForm1.chk_bs1.checked) vFlag++;
|
|
if (window.document.frmForm1.chk_bs2.checked) vFlag++;
|
|
if (vFlag>3) {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED6'] + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
}
|
|
|
|
// on construit la requête SAA pour la seconde partie
|
|
sBal='';
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) {
|
|
if (window.document.frmForm1.chk_b[i].defaultChecked) {
|
|
if (!window.document.frmForm1.chk_b[i].checked) sBal+= 'S;'+window.document.frmForm1.chk_b[i].value + ';' ;
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_b[i].checked) sBal+= 'C;'+window.document.frmForm1.chk_b[i].value + ';' ;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_b.defaultChecked) {
|
|
if (!window.document.frmForm1.chk_b.checked) sBal+= 'S;'+window.document.frmForm1.chk_b.value + ';' ;
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_b.checked) sBal+= 'C;'+window.document.frmForm1.chk_b.value + ';' ;
|
|
}
|
|
}
|
|
|
|
if (window.document.frmForm1.chk_bs1.defaultChecked) {
|
|
if (window.document.frmForm1.chk_bs1.checked) {
|
|
if (window.document.frmForm1.chk_bs1.value.toUpperCase()!=window.document.frmForm1.txt_bs1.value) {
|
|
sBal += 'S;'+window.document.frmForm1.chk_bs1.value + ';C;' + window.document.frmForm1.txt_bs1.value + ';' ;
|
|
}
|
|
}
|
|
else {
|
|
sBal += 'S;'+window.document.frmForm1.chk_bs1.value + ';';
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_bs1.checked) {
|
|
sBal += 'C;'+window.document.frmForm1.txt_bs1.value + ';';
|
|
}
|
|
}
|
|
if (window.document.frmForm1.chk_bs2.defaultChecked) {
|
|
if (window.document.frmForm1.chk_bs2.checked) {
|
|
if (window.document.frmForm1.chk_bs2.value.toUpperCase()!=window.document.frmForm1.txt_bs2.value) {
|
|
sBal += 'S;'+window.document.frmForm1.chk_bs2.value + ';C;' + window.document.frmForm1.txt_bs2.value + ';' ;
|
|
}
|
|
}
|
|
else {
|
|
sBal += 'S;'+window.document.frmForm1.chk_bs2.value + ';';
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_bs2.checked) {
|
|
sBal += 'C;'+window.document.frmForm1.txt_bs2.value + ';';
|
|
}
|
|
}
|
|
// On alerte s'il n'y a aucune modification dans le suivi
|
|
if (sBal=='') {
|
|
MM_setTextOfLayer('erreur','',sDiv + aErreur['ACCRED10'] + "</div>")
|
|
MM_showHideLayers('',arSigneErreurLayers,'erreur');
|
|
return(false) ;
|
|
}
|
|
|
|
sUrl = 'module.asp?mod='+sModule+'&id=' + sBDFId + '&ClientRef=' + sClientRef + '&bal=' + sBal;
|
|
objLink.href = sUrl;
|
|
|
|
}
|
|
|
|
function disabledCheckBoxs(nbBalAccreditees) {
|
|
var size, i, nbCheckedAccred, nbCheckedNotAccred;
|
|
//Nombre de Bals selectionnées parmis les Bals accrédités
|
|
//size = window.document.frmForm1.chk_b.length;
|
|
size = nbBalAccreditees;
|
|
nbCheckedAccred = 0;
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) {
|
|
if (window.document.frmForm1.chk_b[i].checked) nbCheckedAccred++;
|
|
}
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.chk_b.checked) nbCheckedAccred++;
|
|
}
|
|
|
|
// Nombre de Bals selectionnées parmis les Bals supplémentaires
|
|
nbCheckedNotAccred = 0;
|
|
if (window.document.frmForm1.chk_bs1.checked) nbCheckedNotAccred++;
|
|
if (window.document.frmForm1.chk_bs2.checked) nbCheckedNotAccred++;
|
|
nbChecked = nbCheckedAccred + nbCheckedNotAccred
|
|
|
|
// Le nombre max de Bals est selectionné ==> griser les Bals restantes
|
|
if (nbChecked==3) {
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) {
|
|
if (!window.document.frmForm1.chk_b[i].checked) {
|
|
window.document.frmForm1.chk_b[i].setAttribute('disabled','disabled');
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (!window.document.frmForm1.chk_b.checked) {
|
|
window.document.frmForm1.chk_b.setAttribute('disabled','disabled');
|
|
}
|
|
}
|
|
if (!window.document.frmForm1.chk_bs1.checked) {
|
|
window.document.frmForm1.txt_bs1.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs1.setAttribute('disabled','disabled');
|
|
}
|
|
if (!window.document.frmForm1.chk_bs2.checked) {
|
|
window.document.frmForm1.txt_bs2.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs2.setAttribute('disabled','disabled');
|
|
}
|
|
}
|
|
|
|
// Le nombre de Bal selectionné est inférieur à 3
|
|
if (nbChecked<3) {
|
|
if (size != 1) {
|
|
for (i=0;i<size;i++) {
|
|
if (!window.document.frmForm1.chk_b[i].checked) {
|
|
window.document.frmForm1.chk_b[i].removeAttribute('disabled');
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (!window.document.frmForm1.chk_b.checked) {
|
|
window.document.frmForm1.chk_b.removeAttribute('disabled');
|
|
}
|
|
}
|
|
switch (nbCheckedAccred) {
|
|
case 0 :
|
|
window.document.frmForm1.txt_bs1.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs1.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs1.checked = false;
|
|
window.document.frmForm1.txt_bs2.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs2.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs2.checked = false;
|
|
break;
|
|
case 1 :
|
|
window.document.frmForm1.txt_bs1.removeAttribute('disabled');
|
|
window.document.frmForm1.chk_bs1.removeAttribute('disabled');
|
|
window.document.frmForm1.txt_bs2.removeAttribute('disabled');
|
|
window.document.frmForm1.chk_bs2.removeAttribute('disabled');
|
|
break;
|
|
case 2 :
|
|
window.document.frmForm1.txt_bs1.removeAttribute('disabled');
|
|
window.document.frmForm1.chk_bs1.removeAttribute('disabled');
|
|
window.document.frmForm1.txt_bs2.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs2.setAttribute('disabled','disabled');
|
|
window.document.frmForm1.chk_bs2.checked = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function checkBoxsFree(indice,nbBalAccreditees) {
|
|
switch (indice) {
|
|
case 1 :
|
|
if (window.document.frmForm1.txt_bs1.value.length == 0) {
|
|
window.document.frmForm1.chk_bs1.checked = false;
|
|
disabledCheckBoxs(nbBalAccreditees);
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.txt_bs1.value.length == 1) {
|
|
window.document.frmForm1.chk_bs1.checked = true;
|
|
disabledCheckBoxs(nbBalAccreditees);
|
|
}
|
|
else
|
|
if (window.document.frmForm1.chk_bs1.checked == false) {
|
|
window.document.frmForm1.chk_bs1.checked = true;
|
|
disabledCheckBoxs(nbBalAccreditees);
|
|
}
|
|
}
|
|
break;
|
|
case 2 :
|
|
if (window.document.frmForm1.txt_bs2.value.length == 0) {
|
|
window.document.frmForm1.chk_bs2.checked = false;
|
|
disabledCheckBoxs(nbBalAccreditees);
|
|
}
|
|
else {
|
|
if (window.document.frmForm1.txt_bs2.value.length == 1) {
|
|
window.document.frmForm1.chk_bs2.checked = true;
|
|
disabledCheckBoxs(nbBalAccreditees);
|
|
}
|
|
else
|
|
if (window.document.frmForm1.chk_bs2.checked == false) {
|
|
window.document.frmForm1.chk_bs2.checked = true;
|
|
disabledCheckBoxs(nbBalAccreditees);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
} |