| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 
 | <html>
<head>
<title>Salaires de Mr Prout</title>
<script>
var Tab_coupures = new Array();
var Tab_calcul_coupures = new Array();
var nbemployers;
Tab_coupures=[500,200,100,50,20,10,5,2,1,0.50,0.20,0.10,0.05,0.02,0.01];
 
function alert2(alert_message){
        var AlertPage;
	AlertPage = window.open('','Attention','width=400,height=200,left=0,top=100,screenX=0,screenY=100,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'); 
	AlertPage.document.write("<h1>Attention</h1><BR>");
	AlertPage.document.write(alert_message);
	AlertPage.document.write('<BR><INPUT type="button" value="OK" align="" onClick="window.close()">');
}
 
function refresh()
{
    window.location.reload( false );
}
 
function VerifNomValide(IndexNom){
 alert(nbemployers );
  //if (document.NomsSalaires.elements["Nom" + IndexNom].value == ""){
  //  alert2("Vous devez remplir le nom de l'employer " + i);
  //  document.NomsSalaires.elements["Nom" + IndexNom].focus();
  //}
}
 
 
 
function VerifSalaireValide(IndexSalaire){
   // Remplace la virgule par un point si l'utilisateur a utilisé la virgule
alert(nbemployers );
   var Salaire = document.NomsSalaires.elements["Salaire" + IndexSalaire].value.replace(",",".");
   document.NomsSalaires.elements["Salaire" + IndexSalaire].value=Salaire;
   //Test de validité du salaire (Est-ce un nombre? Oui ? bien compris entre 500 et 5000 ? )
   //                                               Non Aie, erreur!
   if (isNaN(parseFloat(Salaire))){
       alert2("Vous navez pas entré un nombre correct") ;
       document.NomsSalaires.elements["Salaire" + IndexSalaire].focus;
   }
   else {
   if (parseFloat(Salaire)>5000 || parseFloat(Salaire)<500){
	if (parseFloat(Salaire) > 5000){
		alert2("Le salaire doit être inférieur ou égal à 5000"); 
        }
	else { 
		alert2("Le salaire doit être supérieur ou égal à 500.");
        }
        document.NomsSalaires.elements["Salaire" + IndexSalaire].focus;
        }
    }
}
 
function RemplirListeNbEmployers(){
  for(i=0;i < 10;i++){
     document.info.Select_NbEmployers.options[i]=new Option();
     document.info.Select_NbEmployers.options[i].value=i+1;
     document.info.Select_NbEmployers.options[i].text=i+1;
  }
}
 
function ChargerEncodage(){
   var i;
   nbemployers=document.info.Select_NbEmployers.options[document.info.Select_NbEmployers.selectedIndex].value;
   document.write ("Veuillez compléter ces informations relatives aux employers et a leur salaires.<BR>");
   document.write ("Vous serez alerté lorsque vous aurez mal remplis un champ.<BR><BR>");
   document.write ('<FORM name="NomsSalaires">');
   for ( i=0 ; i < nbemployers ; i++)
   {
     document.write('<b>Employer ' + (i+1) + '</b><br><br>');
     document.write('  Nom <INPUT type="text" name="Nom' + i + '" onblur="VerifNomValide(' + i + ');">' + '   Salaire <INPUT type="text" name="Salaire' + i + '" onchange="VerifSalaireValide(' + i + ');"><br><br>');
   } 
  document.write ('<INPUT type="button" value="Recommencer" onclick="refresh();">  <INPUT value="Valider" type="Button" onclick="ChargerResultats();">')
  document.write ("</FORM>");
}
 
 
 
function ChargerResultats(){
  var Tab_noms = new Array();
  var Tab_salaires = new Array();
  var TotSalaire = 0;
  for(n=0;n < nbemployers;n++){
      Tab_noms[n]=document.NomsSalaires.elements["Nom" + n].value;
      Tab_salaires[n]=document.NomsSalaires.elements["Salaire" + n].value;
      TotSalaire=TotSalaire+parseFloat(Tab_salaires[n]);
  }
  Tab_noms[n+1]="Totaux";
  Tab_salaires[n+1]=TotSalaire;
 
  document.write("<h1>Fiche salaires</h1><BR>");
  document.write('<TABLE BORDER=1 WIDTH="100%">');
  document.write('<B><TR BGCOLOR="#ffff99"><TD>Noms</TD><TD>Salaires</TD><TD WIDTH="7%">' + Tab_coupures.join('</TD><TD WIDTH="7%">') + '</TD></TR></B>');
  for(n=0;n < nbemployers;n++){
     CalculCoupures (Tab_salaires[n]);
     document.write('<TR BGCOLOR="#ffffcc"><TD BGCOLOR="#ffff99">' + Tab_noms[n] + '</TD><TD BGCOLOR="#ffff99">' + Tab_salaires[n] + '</TD><TD WIDTH="7%">' + Tab_calcul_coupures.join('</TD><TD WIDTH="7%">') + '</TD></TR>');
  }
  document.write('<TR BGCOLOR="#99ffcc"><TD>' + Tab_noms[n+1] + '</TD><TD>' + Tab_salaires[n+1] + '</TD><TD WIDTH="7%">' + Tab_calcul_coupures.join('</TD><TD WIDTH="7%">') + '</TD></TR>');
  document.write("</TABLE>"); 
}
 
function CalculCoupures (salaire){
  salaire = Math.round(parseFloat(salaire)*100);
//   for(i=0;i < Tab_coupures.length;i++){
//     p = Math.floor((salaire / ( Tab_coupures[i]*100)));
//     Tab_calcul_coupures[i] = p;
//     salaire = (salaire - p*100*Tab_coupures[i]);
//   }
    for(i=0;i < Tab_coupures.length;i++){
       Tab_calcul_coupures[i]= Math.floor((salaire / ( Tab_coupures[i]*100)));
       salaire%=Tab_coupures[i]*100;
    }
}
 
</script>
 
</head>
 
<body onload="RemplirListeNbEmployers();">
<form NAME="info">
  <h1>Calcul du salaire des employers</h1><BR><BR>	
  Bonjour Mr Schtoumf ce programme va se charger de calculer les salaires de vos employers.<BR><BR>
  Selectionnez le nombre d'employers <SELECT SIZE=1 NAME=Select_NbEmployers></SELECT>
  et appuyez ensuite sur <INPUT value="Démarrer" type="Button" onclick="ChargerEncodage();">
</form>
</body>
</html> | 
Partager