Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("conecta.php");
- date_default_timezone_set('America/Sao_Paulo');
- if (isset($_POST['pesquisarEmail'])) {
- $email = $_POST['email'];
- //pesquisando o ID no banco de dados do ESTUDANTE
- $pesquisaId = "SELECT id FROM `estudante` where email='$email'";
- $rodarPesquisaId = mysqli_query($conn, $pesquisaId);
- //Variavel idFR fecth da linha.
- $idFR = mysqli_fetch_row($rodarPesquisaId);
- $id = $idFR[0];
- $dias = array(
- '2019-10-21',
- '2019-10-22',
- '2019-10-23',
- '2019-10-24'
- );
- $dataInicialTeste = '2000-01-01';
- $dtTotal = DateTime::createFromFormat('Y-m-d H:i:s', $dataInicialTeste.' 00:00:00');
- foreach ($dias as $dia) {
- //pesquisando tudo de presenca do aluno
- $dia21 = mysqli_query($conn, "SELECT * FROM presenca where idEstudante='$id' and dia='$dia'") or die(mysqli_error($conn));
- $horarioEntrada = null;
- $horarioSaida221 = null;
- echo $dia;
- while ($results = mysqli_fetch_array($dia21)) {
- if ($results['tipo'] == 'Entrada') {
- $horarioEntrada = DateTime::createFromFormat('Y-m-d H:i:s', $dia .' ' .$results['horario']);
- echo '<pre>'.print_r ($horarioEntrada,1).'</pre>';
- echo ("entrada <br>");
- }
- if ($results['tipo'] == 'Saida') {
- $horarioSaida221 = DateTime::createFromFormat('Y-m-d H:i:s', $dia .' ' .$results['horario']);
- echo '<pre>'.print_r ($horarioSaida221,1).'</pre>';
- echo ("saida <br>");
- }
- if ($horarioEntrada != null and $horarioSaida221 != null) {
- //$aiff = $horarioEntrada->diff($horarioSaida221)->format("%H:%I:%S");
- $aiff = $horarioEntrada->diff($horarioSaida221);
- $horarioSaida221 = null;
- $horarioEntrada = null;
- echo '<pre>'.print_r($aiff,1).'</pre>';
- //$horarioTotal = new DateTime('Y-m-d H:i:s', $dia .' ' .$results['horario']);
- $horarioTotal = DateTime::createFromFormat('Y-m-d H:i:s', $dia .'00:00:00');
- $horarioTotal->add($aiff);
- echo '<pre>'.print_r($horarioTotal->format('H:i'),1).'</pre>';
- echo ("<br>");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement