<?php include_once($_SERVER['DOCUMENT_ROOT']."/_php_header_civil.php"); ?>

       <script language="JavaScript1.1" type="text/javascript" >
      <!--
        function SEC(usuario,dominio) {
          locationstring = "mailto:" + usuario + "@" + dominio;
          window.location.href = locationstring;
        }
      // -->
      </script>


<hr>

    <?php

    // Recebe vetor com informacoes das disciplinas
    require($_SERVER['DOCUMENT_ROOT']."/scripts/dados_alunos.php");

    $Meses = array("Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez");

    function plural($number){ return ($number < 2) ? "" : "s"; };

    function formata($texto)
    { return htmlentities($texto,ENT_QUOTES,'UTF-8'); };
//    { return htmlentities($texto,ENT_QUOTES,'ISO-8859-1'); };

    function formata2($texto)
    { return htmlentities($texto,ENT_QUOTES,'cp1252'); };


    function ro($texto)
    { return '<sup><u>'.formata($texto).'</u></sup>'; };


//    $Ordena = $_GET["Sort"];
//    $ListaOrdenado = isset($Ordena) && ( ($Ordena == "Name") );
//    if ( $ListaOrdenado ){
//       function cmp_name($a, $b)
//       {
//         if ($a["Nome"] == $b["Nome"]){return 0;}
//         return ($a["Nome"] < $b["Nome"]) ? -1 : 1;
//       };
//       if ($Ordena == "Name") { usort($Aluno, "cmp_name");}
//    };

    if ( isset($_GET["Title"]) ){ $Title = $_GET["Title"];}
    else { $Title = 'Alunos de Graduação da Civil'; };

    echo '<div Class=titulo>'.formata($Title).'</div>'."\n";
    echo '<hr>';

    function Filtro_Ok ( $Dados ){

    if ( isset($_GET["Year"]) ){ $Filtra_Turma = $_GET["Year"];};
      $Filtra_Turma_Ok = isset($Filtra_Turma) && ( $Filtra_Turma > 1975 ) && ( $Filtra_Turma < 2100 );

    if ( isset($_GET["Militar"]) ){ $Filtra_Militar = $_GET["Militar"];};
      $Filtra_Militar_Ok = isset($Filtra_Militar) && ( $Filtra_Militar != "" );

    if ( isset($_GET["Sex"]) ){ $Filtra_Sexo = $_GET["Sex"];};
      $Filtra_Sexo_Ok = isset($Filtra_Sexo) && ( ( $Filtra_Sexo == "M" ) || ( $Filtra_Sexo == "F" ) );

      $Parcial = True;

      if ( $Filtra_Turma_Ok ){
        $Parcial = ( $Dados["Turma"] == $Filtra_Turma );
      };

      if ( $Filtra_Militar_Ok ){
        $Parcial = $Parcial && ( $Dados["Militar"] != "" );
      };

     if ( $Filtra_Sexo_Ok ){
        if ( $Filtra_Sexo == "M" ){ $Filtra_Sexo = ""; }; 
        $Parcial = $Parcial && ( $Dados["Sexo"] == $Filtra_Sexo );
      };


      return $Parcial; 
    }; 

    echo '<CENTER><TABLE BORDER=1>';
    $count = 0; 
    $Ano_Atual = date("Y"); 
//// PROVIS&Oacute;RIO
$Ano_Atual = 2026; 
//// PROVIS&Oacute;RIO
    $count_photo = 0;
    foreach ($Aluno as $Matricula => $Dados){

      $Infra = 3 - ($Dados["Turma"] - $Ano_Atual);
      if ( ! Filtro_Ok($Dados) ){continue;};
      if ( ($Infra < 1) || ($Infra > 3) ){continue;};      

      $EmBranco = 'branco_.jpg';
      $count += 1; 
      $picture = $Dados["Matricula"].".jpg";

      if ( ! file_exists($picture) ) { $picture = $EmBranco; };
      echo '<TR><TD>';
      if ( $picture != $EmBranco ){ echo '<A HREF="'.$picture.'">'; $count_photo += 1; };
      echo '<IMG SRC="'.$picture.'" WIDTH="90" HEIGHT="68" ALT="Foto">';
      if ( $picture != $EmBranco ){ echo '</A>'; };
      echo '</TD><TD>';
      echo formata2($Dados["Nome"]);
      if ( $Dados["Militar"] != "" ){ echo ', '.$Dados["Militar"]; };
      if ( $Dados["Representante"] == "1" ){ echo ' (<strong>representante de turma</strong>)';};

      if ( $Dados["Nascimento"]["Dia"] > 0 ){ echo '<br>Nascimento: '.$Dados["Nascimento"]["Dia"].'-'.
           $Meses[$Dados["Nascimento"]["Mes"]-1].'-'.$Dados["Nascimento"]["Ano"]; };

      echo '<br>Turma '.$Dados["Turma"].' ('.($Infra+2).ro('o').' ano de ITA, '.$Infra.ro('o').' Civil)';
      if ( $Dados["Email"] != "" ){ 
         echo "<br><A HREF=\"javascript:SEC('".str_replace("@","','",$Dados["Email"]).
            "')\" OnMouseOver=\"window.status='E-mail'; return true\">E-mail</A>";};
      echo '</TD></TR>'."\n";       

    };
    echo '</TABLE></CENTER>'."\n";
    echo '<p>Foram exibidos os dados de '.$count.' aluno'.plural($count).' ('.$count_photo.
         ' foto'.plural($count_photo).')</p>';       

    echo '<hr><p class=leia_mais><A HREF="http://www.civil.ita.br/graduacao/alunos/">Alunos de gradua&ccedil;&atilde;o</A></p>';

    ?>

<p>&nbsp;</p>

<?php include_once($_SERVER['DOCUMENT_ROOT']."/_php_footer_civil.php?"); ?>
