abracadabraPDF › Forums › PDF – Général › Feuille de pointage horaire › Répondre à : Feuille de pointage horaire
bonjour,
désolé je n’ai pas suivi les dernières conversations…
Voici ce que j’ai fait :
// Sript de document
function Time2Num(format,temps) {
if(temps=="") return "";
var oTime=util.scand("mm/dd/yyyy "+format,"01/01/1970 "+temps);
var decalageUTC=oTime.getTimezoneOffset()*1000*60
var tempsEcoule=oTime.valueOf()-decalageUTC;
return Math.round(tempsEcoule/1000);
}
function secondes2hhmm(totalSec) {
totalSec=Math.round(totalSec/60);
totalH=Math.floor(totalSec/60);
totalM=((totalSec/60)-totalH)*60;
minutes=util.printf("%,302.0f",totalM);
return totalH+":"+minutes;
}
function calcul(ind) {
var hDebut=this.getField("heureDebut."+ind).value;
var hFin=this.getField("heureFin."+ind).value;
var pause=this.getField("pause."+ind).value;
if(hDebut!="" && hFin!="") {
var debutSec=Time2Num("hh:mm",hDebut);
var finSec=Time2Num("hh:mm",hFin);
var pauseSec=Time2Num("h:mm",pause);
var totalSec=finSec-debutSec-pauseSec;
var suppSec=totalSec-(7*3600);
event.value=secondes2hhmm(totalSec);
if (suppSec>=0) this.getField("heuresSupp."+ind).value=secondes2hhmm(suppSec);
else this.getField("heuresSupp."+ind).value="";
}
}
function laDate(nom,ind) {
var dateBase=this.getField(nom+".0").valueAsString;
if (dateBase!="") {
var laDate=util.scand("dd/mm/yy",dateBase);
laDate.setDate(laDate.getDate()+ind);
return util.printd("dd/mm/yy",laDate);
} else {
return "";
}
}
// date
var nomChamp=event.target.name;
var champ=nomChamp.split(".");
event.value=laDate(champ[0],Number(champ[1]));
// totalHeures
event.value="";
calcul(event.target.name.substring(event.target.name.indexOf(".")+1));
// total
event.value="";
var somme=0;
for (var i=0; i<7; i++) {
if (this.getField("totalHeures."+i).value!="") {
somme+=Time2Num("hh:mm",this.getField("totalHeures."+i).value)
}
}
event.value=secondes2hhmm(somme);
…et le fichier joint.
@+
😎
