1
How to calculate the time the person entered and the time the person left minus the interval and display the total of hours they gave?
For example if a guy made the following schedule: 07:30 12:00 13:30 17:00 would have to display: 8 hours worked. Only I have to calculate several days equal in the image and sum up all the total hours it gave and display the result.
Columns on the bench:
markings
id(int)
day(date) "date of time"
type(char) E(input) or S(output)
time(time) "are the times"
collaborator_id(int)
I have the following sql query:
$sql= mysql_query("SELECT dia, GROUP_CONCAT(hora) FROM marcacoes WHERE colaborador_id = {$colaborador_id} AND dia between '{$periodoInicial}' and '{$periodoFinal}' GROUP BY dia ");
The display is done using php code:
while($exibe = mysql_fetch_assoc($sql)){
$tabela ='<tbody>';
$tabela .='<tr>';
$tabela .='<td>'.date("d-m-Y", strtotime($exibe['dia'])).'</td>';
$tabela .='<td>'.$exibe['GROUP_CONCAT(hora)'].'</a>'.'</td>';
$tabela .='</tr>';
$tabela .='</tbody>';
echo $tabela;
}
Thanks in advance.
How is this marking? You have a column for each record?
– Wallace Maxters
Yes, I have a column for each dial record
– Smoke Rohden
You can add the name of the columns to the question, so I can help you with the answer?
– Wallace Maxters
Got it! I thought your chart was like this:
marcacoes:['id', 'data', 'entrada', 'saida_almoco', 'retorno_almoco', 'saida']
. So I think it would be easier, but we won’t be able to get around it. I’ll think of an answer.– Wallace Maxters
I just edited.. a look at
– Smoke Rohden
Ah, you give one
GROUP BY dia
. This information is important. I will think here– Wallace Maxters
Thank you Wallace..
– Smoke Rohden
sql itself already brings the separate schedules by doing a GROUP_CONCAT(time) and giving a GROUP BY day and I can show only by passing: $displays['GROUP_CONCAT(time)']
– Smoke Rohden