I have a project where I must accumulate hours worked for a service in a project, it should store in the bank the hours / days.
Then when started, if there is no previous time it starts from zero, but if there has already been a step previously it should count from that and time and accumulate, saving later on the bank.
Until now, the script is working, but I need to make it dynamic so that the report appears more than one project showing the runtime.
JS
<script language=JavaScript>
<!-- begin
function getSecs(sDias, sHors, sMins, sSecs, campo, tempo) {
sSecs++;
if (sSecs == 60) {
sSecs = 0;
sMins++;
if (sMins <= 9) sMins = sMins;
}
if (sMins == 60) {
sMins = 0;
sHors++;
if (sHors <= 8) sHors = sHors;
}
//converte para horas trabalhadas, se fossem dias normais seria 24h if(sHors==24){
if (sHors == 8) {
sHors = 0;
sDias++;
}
//corrige com 2 digitos
if (sSecs <= 9) sSecs = "0" + sSecs;
if (sMins <= 9) sMins = "0" + sMins;
if (sHors <= 9) sHors = "0" + sHors;
if (sDias <= 9) sDias = "0" + sDias;
document.getElementById(campo)
.innerHTML = sDias + ":" + sHors + ":" + sMins + ":" + sSecs;
setTimeout("getSecs(" + sDias + ", " + sHors + ", " + sMins + "," + sSecs + ", '" + campo + "')", 1000);
form1.tempo.value = sDias + ":" + sHors + ":" + sMins + ":" + sSecs;
}
//-->
</script>
PHP
<?php
var_dump($_POST);
$data1 = '0,1,59,55';
$data2 = '0,7,59,55';
?>
HTML
<script>
setTimeout("getSecs(<?= $data1 ?>, \"campo1\",'tempo;')", 1000);
</script>
<hr>
<form action="" method="POST" enctype="multipart/form-data" role="form" name="form1">
<input type="text" id="campo1" name="tempo" value="">
<hr>
<input type="submit" value="Enviar" class="btn btn-primary" />
I do not understand js, but I think it's the best solution, I found an interesting script of timer , I've already adapted some of the needs, but I can not apply more than one input
causing the code to react dynamically.