Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1. <?php
  2. include("conecta.php");
  3. date_default_timezone_set('America/Sao_Paulo');
  4.  
  5.  
  6. if (isset($_POST['pesquisarEmail'])) {
  7.  
  8.   $email = $_POST['email'];
  9.  
  10.   //pesquisando o ID no banco de dados do ESTUDANTE
  11.   $pesquisaId = "SELECT id FROM `estudante` where email='$email'";
  12.   $rodarPesquisaId = mysqli_query($conn, $pesquisaId);
  13.   //Variavel idFR fecth da linha.
  14.   $idFR = mysqli_fetch_row($rodarPesquisaId);
  15.  
  16.   $id = $idFR[0];
  17.  
  18.  
  19.  
  20.   $dias = array(
  21.     '2019-10-21',
  22.     '2019-10-22',
  23.     '2019-10-23',
  24.     '2019-10-24'
  25.   );
  26.  
  27.   $dataInicialTeste = '2000-01-01';
  28.   $dtTotal = DateTime::createFromFormat('Y-m-d H:i:s', $dataInicialTeste.' 00:00:00');
  29.  
  30.   foreach ($dias as $dia) {
  31.     //pesquisando tudo de presenca do aluno
  32.     $dia21 = mysqli_query($conn, "SELECT * FROM presenca where idEstudante='$id' and dia='$dia'") or die(mysqli_error($conn));
  33.  
  34.     $horarioEntrada = null;
  35.     $horarioSaida221 = null;
  36. echo $dia;
  37.  
  38.  
  39.     while ($results = mysqli_fetch_array($dia21)) {
  40.       if ($results['tipo'] == 'Entrada') {
  41.         $horarioEntrada = DateTime::createFromFormat('Y-m-d H:i:s', $dia .' ' .$results['horario']);
  42. echo '<pre>'.print_r ($horarioEntrada,1).'</pre>';
  43. echo ("entrada <br>");
  44.       }
  45.       if ($results['tipo'] == 'Saida') {
  46.         $horarioSaida221 = DateTime::createFromFormat('Y-m-d H:i:s', $dia .' ' .$results['horario']);
  47.         echo '<pre>'.print_r ($horarioSaida221,1).'</pre>';
  48. echo ("saida <br>");
  49.       }
  50.       if ($horarioEntrada != null and $horarioSaida221 != null) {
  51.  
  52.         //$aiff = $horarioEntrada->diff($horarioSaida221)->format("%H:%I:%S");
  53.         $aiff = $horarioEntrada->diff($horarioSaida221);
  54.         $horarioSaida221 = null;
  55.         $horarioEntrada = null;
  56.  
  57.  
  58.      echo '<pre>'.print_r($aiff,1).'</pre>';
  59.         //$horarioTotal = new DateTime('Y-m-d H:i:s', $dia .' ' .$results['horario']);
  60.         $horarioTotal = DateTime::createFromFormat('Y-m-d H:i:s', $dia .'00:00:00');
  61.         $horarioTotal->add($aiff);
  62.      echo '<pre>'.print_r($horarioTotal->format('H:i'),1).'</pre>';
  63.      echo ("<br>");
  64.  
  65.       }
  66.     }
  67.   }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement