<?php

date_default_timezone_set('America/Bogota');
$mysql_server = 'localhost';$mysql_login = 'appcdlem_ga2018';$mysql_password = 'S1lvestre.';$mysql_database = 'appcdlem_ga2018';
mysql_connect($mysql_server, $mysql_login, $mysql_password);mysql_select_db($mysql_database);
session_start();

if(isset($_SESSION["user"])&& $_SESSION["tipo"]=='A'){

  $class1="class=\"active\"";
  $class2="";
  $act2="";
  $act1=" active ";

$select_examen="select exam_id,nombre,date,comment,estado from examen where estado='A' order by nombre";
 $res_select_examen=mysql_query($select_examen);
				
					$tbody="<thead>";
					while($r_sex=mysql_fetch_array($res_select_examen)){
					$tbody.="<tr role='row'><td>".$r_sex[1]."</td><td>".$r_sex[2]."</td><td>".$r_sex[3]."</td><td>&nbsp;</td></tr>";
					}
					$tbody.="</thead>";


if(isset($_POST['val1'])&&!empty($_POST['val1'])){

}

if(isset($_POST['val2'])&&!empty($_POST['val2'])){

 if($_POST['val2']==1){
  $class1="";
  $class2="class=\"active\"";
  $act1="";
  $act2=" active ";

		echo $_POST['uploadBtn2']."----<br>";
		echo $_POST['uploadBtn']."----<br>";
		echo $_FILE['uploadBtn2']."----<br>";		
		echo $_FILE['uploadBtn']."----<br>";
	$insertar_examen='insert into examen (nombre,date,comment)
	values("'.$_POST['nombre_examen2'].'","'.$_POST['fecha_examen2'].'","'.$_POST['comentario2'].'"
	)';
	mysql_query($insertar_examen)or die(mysql_error());
	echo "Ex&aacute;men: ".$_POST['nombre_examen2']." Insertado";


 }
}



echo "
<!DOCTYPE html>
<html lang=\"en\">
  <head>
    <meta charset=\"utf-8\">
    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
    <meta name=\"description\" content=\"\">
    <meta name=\"author\" content=\"\">
    <link rel=\"shortcut icon\" href=\"assets/ico/favicon.ico\">

    <title>Ex&aacute;menes</title>

    <!-- Bootstrap core CSS -->
    <link href=\"dist/css/bootstrap.min.css\" rel=\"stylesheet\">

    <!-- Custom styles for this template -->
    <link href=\"offcanvas.css\" rel=\"stylesheet\">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src=\"../../assets/js/ie8-responsive-file-warning.js\"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script>
      <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script>
    <![endif]-->
    <script>
   


function crea_examen(){

if(document.getElementById('nombre_examen').value==''){alert('Debe digitar el nombre');return false;}
	else{document.getElementById('nombre_examen2').value=document.getElementById('nombre_examen').value}
if(document.getElementById('fecha_examen').value==''){alert('Debe digitar el fecha del examen');return false;}
	else{document.getElementById('fecha_examen2').value=document.getElementById('fecha_examen').value}
if(document.getElementById('comentario').value==''){}
	else{document.getElementById('comentario2').value=document.getElementById('comentario').value}


	document.getElementById('val2').value=1;
	document.forms['crear_examen'].submit();			
}


</script>
  
    
    
    
  </head>

  <body>
    <div class=\"navbar navbar-fixed-top navbar-inverse\" role=\"navigation\">
      <div class=\"container\">
        <div class=\"navbar-header\">
          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">
            <span class=\"sr-only\">Toggle navigation</span>
            <span class=\"icon-bar\"></span>
            <span class=\"icon-bar\"></span>
            <span class=\"icon-bar\"></span>
          </button>
          <a class=\"navbar-brand\" href=\"#\">Project name</a>
        </div>
        <div class=\"collapse navbar-collapse\">
          <ul class=\"nav navbar-nav\">
            <li class=\"active\"><a href=\"#\">Home</a></li>
            <li><a href=\"#about\">About</a></li>
            <li><a href=\"#contact\">Contact</a></li>
          </ul>
        </div><!-- /.nav-collapse -->
      </div><!-- /.container -->
    </div><!-- /.navbar -->


    <div class=\"container\">

      <div class=\"row row-offcanvas row-offcanvas-left\">

       <div class=\"col-xs-6 col-sm-3 sidebar-offcanvas\" id=\"sidebar\" role=\"navigation\">
          <div class=\"list-group\">
            <a href=\"general.php\" class=\"list-group-item active\"><span class=\"glyphicon glyphicon-home\"></span> General</a>
            <a href=\"estudiantes.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-th\"></span> Estudiantes</a>
            <a href=\"docentes.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-user\"></span> Docentes</a>
            <a href=\"acudiente.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-user\"></span> Acudientes</a>                      
            <a href=\"asignaturas.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-book\"></span> Asignaturas</a>
            <a href=\"cursos.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-list\"></span> Cursos</a>
            <a href=\"pensum.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-edit\"></span> Pensum</a>    
            <a href=\"logros.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Logros</a>                        
            <a href=\"observaciones.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Indicadores de Comportamiento</a>                                    
            <a href=\"horario.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Horario</a>
<a href=\"horario_atencion.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Horario de Atenci&oacute;n</a>            
<a href=\"planilla_asistencia.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Control de Asistencia</a>            
<a href=\"planilla.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Registro de Calificaciones</a>            
            <a href=\"planilla_obs.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Observador del Estudiante</a>                        
            <a href=\"pagos.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-list\"></span> Pagos</a>                  
            <a href=\"reportes.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Boletines</a>            
<a href=\"eventos.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Anuncios</a>           
            <a href=\"config.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-wrench\"></span> Configuraci&oacute;n</a>
          </div>
        </div><!--/span-->

        <div class=\"col-xs-12 col-sm-9\">
          <p class=\"pull-left visible-xs\">
            <button type=\"button\" class=\"btn btn-primary btn-xs\" data-toggle=\"offcanvas\">menu</button>
          </p>
    
	<div class=\"panel panel-default\">
	<br>
	      <!-- Nav tabs -->
	<ul class=\"nav nav-tabs\">
		<li >&nbsp;</li>
	  <li $class1 ><a href=\"examenes.php#home\" data-toggle=\"tab\">Gestion Ex&aacute;menes</a></li>
	  <li $class2 ><a href=\"#profile\" data-toggle=\"tab\">Crear Ex&aacute;men</a></li>
	</ul>
	
	<!-- Tab panes -->

	<div class=\"tab-content\">
	<div class=\"tab-pane fade in $act2 \" id=\"profile\">
		<form name='crear_examen' id='crear_examen' method='post' action='examenes.php#profile' target='' enctype='multipart/form-data'>
		<input type='hidden' name='val2' id='val2' value='".$val2."'>	
		<input type='hidden' name='nombre_examen2' id='nombre_examen2' value='".$nombre_examen2."'>	
		<input type='hidden' name='fecha_examen2' id='fecha_examen2' value='".$fecha_examen2."'>
		<input type='hidden' name='comentario2' id='comentario2' value='".$comentario2."'>

		
		<div class=\"page\">
			<fieldset>
				<legend>
					<br><span class=\"glyphicon glyphicon-plus\"></span> Crear Nuevo Ex&aacute;men          
				</legend>			
			</fieldset>
		
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;text-align: right;' >
			Nombre&nbsp;
		  </div>
		 <div class='input' >
		    <input id='nombre_examen' name='nombre_examen' type='text' class='form-control' placeholder='ej. Ex&aacute;men del Primer Periodo' style='width:48%;margin-bottom: 10px'>
		 </div>
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;text-align: right;' >
			Fecha&nbsp;
		  </div>
		 <div class='input' >
		    <input type='date' id='fecha_examen' name='fecha_examen' class='form-control' placeholder='dd/mm/aaaa' style='width:48%;margin-bottom: 10px'>
		 </div>
		
		<div class='input' style='float:left;width: 140px;padding-top: 5px;text-align: right;' >
			Comentario&nbsp;
		  </div>
		 <div class='input' >
		    <input id='comentario' name='comentario' type='text' class='form-control' placeholder='' style='width:48%;margin-bottom: 10px'>
		 </div>
		
		
		
		<fieldset>
		<legend>
					<br>
					
		</legend>	
			<button type='button' class='btn btn-info' onclick='crea_examen()'> Crear Ex&aacute;men</button>     
			<input type='reset' class='btn' value='Borrar'>
						
		</fieldset>
			
			<br>
		</div>
	</form>
</div>

<div class=\"tab-pane fade in $act1 \" id=\"home\">
	<form name='listar_examen' id='listar_examen' method='post' action='examenes.php' target=''>
	<div class=\"page\">
	

	<input type='hidden' name='val1' id='val1' value='".$val1."'>	
	<input type='hidden' name='cur1' id='cur1' value='".$cur1."'>	
		<fieldset>
			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
				Lista de Estudiantes          
			</legend>			
		</fieldset>
	</div>
	
	<fieldset>
	<table class='table table-striped table-bordered '>
		<thead>
			<tr role='row'>
				<th>Examen</th>
				<th>Fecha</th>				
				<th>Comentario</th>				
				<th>&nbsp;</th>								
			</tr>
		</thead>";
		
echo $tbody;
echo	"</table>
	</fieldset>
	
	
	
	</form>

</div>
 
         
        </div><!--/span-->

       
      </div><!--/row-->


      <footer>
        <p>&copy; Company 2022</p>
      </footer>

    </div><!--/.container-->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src=\"https://code.jquery.com/jquery-1.10.2.min.js\"></script>
    <script src=\"dist/js/bootstrap.min.js\"></script>
    <script src=\"offcanvas.js\"></script>
  </body>
</html>
";
}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='index.php' > Registrar</a></div>";
}
?>
