<?php
error_reporting(E_ERROR | E_PARSE);
include 'conector.php';
session_start();
date_default_timezone_set('America/Bogota');
$today = date("Y-m-d H:i:s");

$men="";
$val1="";
$val2="";
$val3="";
$cur1="";
$cur2="";
$cur3="";
$docu1="";
$docu3="";
$estado1="";
$estado3="";
$indice1="";
$indice3="";
$arreglo1="";
$arreglo3="";
$busca1="";
$busca3="";
$est1="";
$est3="";
$estudiante1="";
$estudiante3="";
$tbody="";
$tbody2="";
$class1="";
$class2="";
$class3="";
$act1="";
$act2="";
$act3="";

if(isset($_SESSION["user"])){
  $class1="class=\"active\"";
  $class2="";
  $act2="";
  $act1=" active ";
  $class3="";
  $act3="";


if(isset($_POST['val3'])&&!empty($_POST['val3'])){
  $class3="class=\"active\"";
  $class2="";
  $act2="";
  $act3=" active ";
  $class1="";
  $act1="";


  if($_POST['val3']==1){
  
  	$select_docs="
		  	select 
			e.nombre,
			b.est_id,
			a.descripcion,
			b.estado,
			b.id
			from documentos a,documentos_det b , estudiante e
			where
			a.id=b.doc_id
			and e.estudiante_id=b.est_id";
			if(isset($_POST['cur3'])){ $select_docs.=" and e.curso_id='".$_POST['cur3']."' ";}		
			if(isset($_POST['est3'])&& ($_POST['est3']!='XX')){ $select_docs.=" and b.estado='".$_POST['est3']."' ";}
			$select_docs.="and a.estado='A' order by e.nombre,a.descripcion	";
			
	//echo	$select_docs."<br>";	
			
	$res_select_docs=mysql_query($select_docs);
	 $num_docs=mysql_num_rows($res_select_docs);					
	 
	 if($num_docs>0){
	 $tbody3.="		
	 				<div class='table-responsive' align='center' style='margin:5px auto'>

						<table id='t_docs' class='table table-striped table-bordered ' style='width:80%;'>
						
						<thead>
						<tr role='row' style='font-size:12px'>
							<th>Cod</th><th>Estudiante</th><th>Documento</th><th>Estado</th><th>&nbsp;</th>
						</tr>
					</thead>";
						
					while($docs_est=mysql_fetch_array($res_select_docs)){	
							
					if($docs_est[3]=='E'){$estado='<span class="label label-success">ENTREGADO</span>';}
					if($docs_est[3]=='P'){$estado='<span class="label label-danger">PENDIENTE</span>';}					
	
	 $tbody3.="			<tr style='font-size:12px'>
							<td>$docs_est[1]</td>
							<td>$docs_est[0]</td>
							<td class=''>$docs_est[2]</td>							
							<td class=''>$estado</td>
							<td></td>
						</tr>";
						
						}
						
						
	 $tbody3.="			</table>
	
						</div>
	
						";
	}else{
	
	
	$men="<div class=\"alert alert-danger\">
	                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
	                    No existen Registros para esta Consulta </div>";
	
	}
  
  }


}




if(isset($_POST['val2'])&&!empty($_POST['val2'])){
  $class2="class=\"active\"";
  $class1="";
  $act1="";
  $act2=" active ";
  $class3="";
  $act3="";

  if($_POST['val2']==1){
  
  	$insertar_doc="insert into documentos (descripcion) values('".$_POST['docu2']."')	";
	mysql_query($insertar_doc)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Registro Insertado
			</div>";
  
  
  }

  if($_POST['val2']==2){
  
  	$borra_doc_="delete from  documentos where id=".$_POST['indice2']."	";
	mysql_query($borra_doc_)or die(mysql_error());
	
	$insert_audit="insert into auditoria (proceso,cod,modulo,usuario,fecha) values ('BORRAR DOCU','ID: ".$_POST['indice2']."','ADMON','".$_SESSION["user"]."','".date("Y-m-d H:i:s")."')  ";
	mysql_query($insert_audit)or die(mysql_error());

	
	
	
	
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Registro Borrado
			</div>";
  
  
  }





}

$select_docs="select id,descripcion,estado from documentos a where  a.estado='A' order by a.descripcion ";

if($res_select_docs=mysql_query($select_docs)){

$filas_docs=mysql_num_rows($res_select_docs);
	if($filas_docs>0){
					$tbody2="<tbody>";
					$cont=1;
		while($r_sd=mysql_fetch_array($res_select_docs)){
					
					$tbody2.="<tr role='row'><td>".$r_sd[0]."</td><td>".$r_sd[1]."</td><td>".$r_sd[2]."</td>
					<td>
					<button type='button' class='btn btn-danger btn-xs' 
									onclick='borra_doc_($r_sd[0])' id='borra' name='borra' ><i class='glyphicon glyphicon-trash'></i> Borrar
						</button>
					
					</td></tr>";
					$cont++;
					
		}
					
					$tbody2.="</tbody>";

	}else{
	$men="<div class=\"alert alert-danger\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    No existen Registros 
			</div>";
	
	}


}



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


  if($_POST['val1']==4){
  
  	$borra_docu_est="delete from documentos_det where id=".$_POST['indice1']."	";
	mysql_query($borra_docu_est)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Registro Eliminado
			</div>";
  
  
  }
 if($_POST['val1']==3){
 
$arreglo_res=explode(",", $_POST['arreglo1']);
	for($i=1;$i<sizeof($arreglo_res);$i++){
		$arreglo_ins=explode(" - ", $arreglo_res[$i]);
		
		//echo $arreglo_ins[0]." - ".$arreglo_ins[1]."<br>";
		$ver='P';
		if($arreglo_ins[1]=='true'){$ver='E';}
		elseif($arreglo_ins[1]=='false'){$ver='P';}
		
		$update_expediente="update documentos_det set 			estado='".$ver."'			where 	est_id=".$_POST['est1']."  and id=".$arreglo_ins[0]." "; 

	//echo 	$update_expediente." -- <br>";	
	mysql_query($update_expediente)or die(mysql_error());

	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Expediente Actualizado Satisfactoriamente.
			</div>";	
	}

 }

 if($_POST['val1']==2){
	$insert_docu_est="insert into documentos_det
	(doc_id,est_id,estado,fecha_insert,user) values
	(".$_POST['docu1'].",".$_POST['est1'].",'P','".$today."','".$_SESSION['user']."')
	";
	mysql_query($insert_docu_est)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Expediente Actualizado                
			</div>";
 }
if($_POST['val1']==1||$_POST['val1']==2||$_POST['val1']==3||$_POST['val1']==4){

$select_est="select nombre,(select nombre_archivo from upload where upload.codigo=estudiante_id and clase='F') from estudiante where
estudiante_id=".$_POST['est1']." ";
if($res_select_est=mysql_query($select_est)){
	$filas_est=mysql_num_rows($res_select_est);
	if($filas_est>0){
	$r_est=mysql_fetch_array($res_select_est);
	$nombre=$r_est[0];
	$nombre_foto=$r_est[0];
	
	
	}

}

$select_doc="
select 
b.est_id,
a.descripcion,
b.estado,
(select nombre_archivo from upload where upload.codigo=b.est_id and clase='F'),
b.id
from documentos a,documentos_det b , estudiante e
where
a.id=b.doc_id
and b.est_id=".$_POST['est1']."
and e.estudiante_id=b.est_id
and a.estado='A' order by a.descripcion
";

if($res_select_doc=mysql_query($select_doc)){

$filas_doc=mysql_num_rows($res_select_doc);
	if($filas_doc>0){
					$tbody="<tbody>";
					$cont=1;
		while($r_sce=mysql_fetch_array($res_select_doc)){
					if(!empty($r_sce[3])&&isset($r_sce[3])){$foto="<div align=center><img style='
						border-radius: 50%;
						-moz-border-radius: 50%;
						-webkit-border-radius: 50%;
						-khtml-border-radius: 50%;
						border: 2px solid #cee6fb;
						
						 overflow: hidden;'  src='img/foto/".$r_sce[3]."' width='50px' height='50px' ></div>";}
					else{$foto="<div align=center><img style='
						border-radius: 50%;
						-moz-border-radius: 50%;
						-webkit-border-radius: 50%;
						-khtml-border-radius: 50%;
						border: 2px solid #cee6fb;
						 overflow: hidden;'  src='img/foto/anon.png' width='50px' height='50px' ></div>";}
					
					if($r_sce[2]=='E'){$ch='checked';}else{$ch='';}
					
					$tbody.="<tr role='row'><td>".$r_sce[1]."</td><td>
					
					
					<input type='checkbox' $ch id='view[".$cont."]' name='view[".$cont."]' value='$r_sce[4]'>


					
					</td>
					<td>
					<button type='button' class='btn btn-danger btn-xs' 
									onclick='borra_doc($r_sce[4])' id='borra' name='borra' ><i class='glyphicon glyphicon-trash'></i> Borrar
						</button>
					
					</td></tr>";
					$cont++;
					
		}
					
					$tbody.="</tbody>";

	}else{
	$men="<div class=\"alert alert-danger\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    No existen Registros para este Estudiante - ".$nombre.".
			</div>";
	
	}


}



 } 
 
}




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\">
    <link rel='stylesheet' href='js/css/jquery-ui-1.9.2.custom.css' />
	<style>
	
		.btn-file {
		    position: relative;
		    overflow: hidden;
		}
		.btn-file input[type=file] {
		    position: absolute;
		    top: 0;
		    right: 0;
		    min-width: 100%;
		    min-height: 100%;
		    font-size: 999px;
		    text-align: right;
		    filter: alpha(opacity=0);
		    opacity: 0;
		    background: red;
		    cursor: inherit;
		    display: block;
		}
		input[readonly] {
			background-color: white !important;
			cursor: text !important;
		}
	
	
	.fileUpload {
	position: relative;
	overflow: hidden;
	margin: 10px;
	}
	.fileUpload input.upload {
	position: absolute;
	top: 0;
	right: 0;
	margin: 10px;
	padding: 10px;
	font-size: 12px;
	cursor: pointer;
	opacity: 0;
	filter: alpha(opacity=0);
	}
	</style>
    <title>Documentos</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>
	<script type='text/javascript' src='/dist/js/bootstrap-filestyle.min.js'> </script>

    <![endif]-->
    <script>
function consultar_doc(){
	if(document.getElementById('l_curso3').value=='XX'){alert('Debe Seleccionar Curso');return false;}else{
	document.getElementById('cur3').value=document.getElementById('l_curso3').value;
	}

	document.getElementById('est3').value=document.getElementById('l_est3').value;
	document.getElementById('val3').value=1;

	document.forms['con_documentos'].submit();


}

function borra_doc_(ind){
	if(confirm('Se eliminaran de todas las tablas del sistema, Desea Continuar?')){
	document.getElementById('indice2').value=ind;
	document.getElementById('val2').value=2;

	document.forms['reg_documentos'].submit();
	}else{
	return false;
	}

}    
function insertar_doc(){
if(document.getElementById('nombre_').value==''){alert('Debe digitar el nombre del documento');return false;}
	else{document.getElementById('docu2').value=document.getElementById('nombre_').value;}
	
	document.getElementById('val2').value=1;

	document.forms['reg_documentos'].submit();

}    
function borra_doc(ind){
	if(confirm('Seguro que Desea borrar este Registro?')){

		if(document.getElementById('buscar_').value==''){alert('Debe digitar el nombre');return false;}
		else{
		var mystr = document.getElementById('buscar_').value;
		var myarr = mystr.split(' - ');var t_id = myarr[0];var t_cur = myarr[2];
		document.getElementById('est1').value=t_id;
		document.getElementById('estudiante1').value=document.getElementById('buscar_').value;
		}
		
		document.getElementById('val1').value=4;
		document.getElementById('indice1').value=ind;	

		document.forms['listar_documentos'].submit();
	}else{
	return false;
	}
}    
function guardar(est){
document.getElementById('estudiante1').value=document.getElementById('buscar_').value;
var arr = new Array();	
for (var i=1;i<document.getElementById('docs_tabla').rows.length;i++) {
		
		arr[i] = document.getElementById('view['+i+']').value +' - '+ document.getElementById('view['+i+']').checked;
		//alert(arr[i]);	
		var mystr = document.getElementById('view['+i+']').value;
		var myarr = mystr.split(';');
		}

		document.getElementById('arreglo1').value=arr;	
		document.getElementById('est1').value=est;
		document.getElementById('val1').value=3;
		document.forms['listar_documentos'].submit();
}    
    
function insertar_docs(){
document.getElementById('val1').value=2;

if(document.getElementById('buscar_').value==''){alert('Debe Buscar Estudiante Previamente');return false;}
		else{
		var mystr = document.getElementById('buscar_').value;
		var myarr = mystr.split(' - ');var t_id = myarr[0];var t_cur = myarr[2];
		document.getElementById('est1').value=t_id;
		document.getElementById('estudiante1').value=document.getElementById('buscar_').value;
		}
if(document.getElementById('s_documento_').value=='XX'){alert('Debe Seleccionar Documento');return false;}
	else{document.getElementById('docu1').value=document.getElementById('s_documento_').value;}		
	document.forms['listar_documentos'].submit();


}    
function busca_docs(){

document.getElementById('val1').value=1;


	if(document.getElementById('buscar_').value==''){alert('Debe digitar el nombre');return false;}
		else{
		var mystr = document.getElementById('buscar_').value;
		var myarr = mystr.split(' - ');var t_id = myarr[0];var t_cur = myarr[2];
		document.getElementById('est1').value=t_id;
		document.getElementById('estudiante1').value=document.getElementById('buscar_').value;
		}
	document.forms['listar_documentos'].submit();	

}
</script>
  
    
    
    
  </head>

  <body>
    <div class=\"navbar navbar-fixed-top navbar-inverse\" role=\"navigation\">
      <div class=\"container\">
       
          <a class=\"\" href=\"general.php\"><img src='img/logo1.png' style='margin-top:5px'></a>

        <a href=\"index.php\"><img src='img/salir.png' style='float:right;margin-top:15px'>
       </a><span style='float:right;margin-right:10px; margin-top:15px' class='label label-success'><span class='glyphicon glyphicon-user'></span> ".$_SESSION["user"]."</span>
        
        
      </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\"><span class=\"glyphicon glyphicon-home\"></span> General</a>
            <a href=\"estudiantes.php\" class=\"list-group-item active\"><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>";
echo $men;
echo	      "<!-- Nav tabs -->
	<ul class=\"nav nav-tabs\">
		<li >&nbsp;</li>
	  <li $class1 ><a href=\"#home\" data-toggle=\"tab\" > Documentos</a></li>
	  <li $class2 ><a href=\"#crear\" data-toggle=\"tab\" > Crear Docs.</a></li>	  
	  <li $class3 ><a href=\"#cons\" data-toggle=\"tab\" > Consulta Curso</a></li>	  
	</ul>
	
	
	<!-- Tab panes -->

	<div class=\"tab-content\">
<div class=\"tab-pane fade in $act3 \" id=\"cons\">
	<form name='con_documentos' id='con_documentos' method='post' action='estudiantes_docs.php' target=''>
	<div class=\"page\">
	

	<input type='hidden' name='val3' id='val3' value='".$val3."'>	
	<input type='hidden' name='cur3' id='cur3' value='".$cur3."'>	
	<input type='hidden' name='docu3' id='docu3' value='".$docu3."'>		
	<input type='hidden' name='estado3' id='estado3' value='".$estado3."'>		
	<input type='hidden' name='indice3' id='indice3' value='".$indice3."'>	
	<input type='hidden' name='arreglo3' id='arreglo3' value='".$arreglo3."'>	
	<input type='hidden' name='busca3' id='busca3' value='".$busca3."'>		
	<input type='hidden' name='est3' id='est3' value='".$est3."'>	
	<input type='hidden' name='estudiante3' id='estudiante3' value='".$estudiante3."'>	
			
		<fieldset>
			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
				Consulta Cursos          
			</legend>			
		</fieldset>
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Curso&nbsp;
		  </div>
		<div class='input' >
		 <select  name='l_curso3' id='l_curso3'  class='form-control' style='width:36%;margin-bottom: 10px'>";

				$sql_doc="select curso_id,codigo,nombre,estado  from curso where estado='A' order by orden";
				$result_sql_doc=mysql_query($sql_doc);
				echo '<option class="" value="XX" >Seleccione Curso</option>';
				while($r=mysql_fetch_array($result_sql_doc)){
				if( $r[1]==$d){$sel_doc=" selected ";}else{$sel_doc='';} 
				if($_POST['cur3']==$r[0]){$sel_doc=' selected ';}
						echo '<option value="'.$r[0].'"  '.$sel_doc.'>'.$r[1].' - '.$r[2].'</option>';
				}

		echo	"</select>
		 

		 </div>
 		<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Estado&nbsp;
		  </div>
		<div class='input' >
		 <select  name='l_est3' id='l_est3'  class='form-control' style='width:36%;margin-bottom: 10px'>";

				echo '<option class="" value="XX" >...</option>';
				echo '<option class="" value="P" >Pendiente</option>';
				echo '<option class="" value="E" >Entregado</option>';				


		echo	"</select>
		 

		 </div>
		 <div class='input' style='width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;'>
 		 <button type='button' class='btn btn-info btn-xs' onclick='consultar_doc()'><i class='glyphicon glyphicon-zoom-in'></i> Buscar</button>
		 </div>
		
		<hr>
		</div>
	
		
		<fieldset>
		";
	
	
	
	
			
	echo $tbody3;
	echo	"
		</fieldset>
		
		
		
		</form>
	
</div>
<div class=\"tab-pane fade in $act2 \" id=\"crear\">
	<form name='reg_documentos' id='reg_documentos' method='post' action='estudiantes_docs.php' target=''>
	<div class=\"page\">
	

	<input type='hidden' name='val2' id='val2' value='".$val2."'>	
	<input type='hidden' name='cur2' id='cur2' value='".$cur2."'>	
	<input type='hidden' name='docu2' id='docu2' value='".$docu2."'>		
	<input type='hidden' name='estado2' id='estado2' value='".$estado2."'>		
	<input type='hidden' name='indice2' id='indice2' value='".$indice2."'>	
	<input type='hidden' name='arreglo2' id='arreglo2' value='".$arreglo2."'>	
	<input type='hidden' name='busca2' id='busca2' value='".$busca2."'>		
	<input type='hidden' name='est2' id='est2' value='".$est2."'>	
	<input type='hidden' name='estudiante2' id='estudiante2' value='".$estudiante2."'>	
			
		<fieldset>
			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
				Crear Documentos          
			</legend>			
		</fieldset>
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Nombre Doc.&nbsp;
		  </div>
		 <div class='' >
		    <input type='text' id='nombre_' name='nombre_' class='form-control' value='' style='width:30%;margin-bottom: 10px' onclick='this.value=\"\"'  >
		 </div>

		 <div class='input' style='width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;'>
 		 <button type='button' class='btn btn-success btn-xs' onclick='insertar_doc()'><i class='glyphicon glyphicon-floppy-saved'></i> Insertar Nuevo</button>
		 </div>
		
	<hr>
	</div>

	
	<fieldset>
	<div class='table-responsive'>
	<table id='docs_tabla2' class='table table-striped table-bordered '>
		<thead>
			<tr role='row'>
				<td>Id</td>
				<td>Nombre</td>				
				<td>Estado</td>								
				<td>&nbsp;</td>								
			</tr>
		</thead>";




		
echo $tbody2;
echo	"</table>
	</div>
	
	</fieldset>
	
	
	
	</form>

</div>

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

	<input type='hidden' name='val1' id='val1' value='".$val1."'>	
	<input type='hidden' name='cur1' id='cur1' value='".$cur1."'>	
	<input type='hidden' name='docu1' id='docu1' value='".$docu1."'>		
	<input type='hidden' name='estado1' id='estado1' value='".$estado1."'>		
	<input type='hidden' name='indice1' id='indice1' value='".$indice1."'>	
	<input type='hidden' name='arreglo1' id='arreglo1' value='".$arreglo1."'>	
	<input type='hidden' name='busca1' id='busca1' value='".$busca1."'>		
	<input type='hidden' name='est1' id='est1' value='".$est1."'>	
	<input type='hidden' name='estudiante1' id='estudiante1' value='".$estudiante1."'>		
			
		<fieldset>
			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
				Consulta Documentos          
			</legend>			
		</fieldset>
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Estudiante&nbsp;
		  </div>
		 <div class='' >
		    <input type='text' id='buscar_' name='buscar_' class='form-control' value='".$_POST['estudiante1']."' style='width:30%;margin-bottom: 10px' onclick='this.value=\"\"'  >
		 </div>
		 <div class='input' style='width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;'>
		 <button type='button' class='btn btn-info btn-xs' onclick='busca_docs()'><i class='glyphicon glyphicon-zoom-in'></i> Buscar</button>
		 </div>
		 <br>
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Documento&nbsp;
		  </div>
		  <div class='input' >
				<select id='s_documento_' name='s_documento_' class='form-control' style='width:30%;margin-bottom: 10px'>";
				
					$select_doc='select id,descripcion 
					from documentos where estado="A" order by descripcion';
					$res_select_doc=mysql_query($select_doc);
					echo "<option value='XX' >Seleccione Documento</option>";
					while($r_sc=mysql_fetch_array($res_select_doc)){
					$sel1='  ';
					//if($edit_est[11]==$r_sc[0]){$sel1=' selected ';}
					//echo "hola";
							echo '<option value="'.$r_sc[0].'"  '.$sel1.'>'.$r_sc[1].' </option>';
					}
					
echo					"</select>
		 </div>

		 <div class='input' style='width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;'>
 		 <button type='button' class='btn btn-success btn-xs' onclick='insertar_docs()'><i class='glyphicon glyphicon-floppy-saved'></i> Insertar Doc.</button>
		 </div>
		
	<hr>
	</div>

	
	<fieldset>
	<div class='table-responsive'>
	<table id='docs_tabla' class='table table-striped table-bordered '>
		<thead>
			<tr role='row'>
				<td>Documento</td>
				<td>Entregado</td>				
				<td>&nbsp;</td>								
			</tr>
		</thead>";
		
echo $tbody;
echo	"</table>
	</div>
	
	<div>
					<a class='btn btn-success btn-xs' name='gt' id='gt' onclick='guardar(".$_POST['est1'].")'>
                			<i class='glyphicon glyphicon-floppy-disk icon-white'></i>  
			                Guardar Todo </a>
					</div>
	</fieldset>
	
	
	
	</form>

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

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

      </div><!--/row-->      </div><!--/row-->
<hr>
       <footer>
        <p>Todos los derechos reservados - Copyright &copy; CDLE</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=\"js/jquery-ui-1.10.3.custom.js\"></script>    
    <script src=\"offcanvas.js\"></script>
     <script src='js/tablesort.min.js'></script>
    <script>
      new Tablesort(document.getElementById('t_docs'));
    </script>
    <script>
     
     
      $(function() {
	$( \"#buscar_\" ).autocomplete(
	{
		 source:'source2.php',		 
		 minLength: 3
	})
	}); 
      $(function() {
	$( \"#buscar_acud\" ).autocomplete(
	{
		 source:'source3.php',		 
		 minLength: 3
	})
	}); 	

      $(function() {
	$( \"#buscar_acud2\" ).autocomplete(
	{
		 source:'source3.php',		 
		 minLength: 3
	})
	}); 	
    </script>	
<script src='js/tablesort.min.js'></script>
    <script>
      new Tablesort(document.getElementById('docs_tabla'));
    </script>
  </body>
</html>
";

}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='index.php' > Registrar</a></div>";
}
?>