<?php    
include '../conector.php';
include '../mysql_compat.php';
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);

$men="";$class1="";$class2="";$act1="";$act2="";$tbody="";$val1="";$val2="";$cur1="";$periodo1="";$nombre1="";
$docente1="";$asignatura1="";$estado1="";$ide1="";$curso1="";$pensum1="";$curso1a="";$pensum1a="";
$nombre_registro2="";$l_curso22="";$docente2="";$asignatura2="";$pensum2="";$periodo2="";$val2="";
$cur="";$pen="";

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

if(isset($_GET['eliminar']) && !empty($_GET['eliminar'])){
 	$logro_id = intval($_GET['eliminar']);
 	$eliminar_logro="delete from logros where id=".$logro_id;
 	if(mysql_query($eliminar_logro)){
 		$men="<div class=\"alert alert-success\">
                     <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                     Logro Eliminado
 		</div>";
 	}
}

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

$cuenta="select docente.teacher_id,docente.coordinador
 	from usuarios,docente
 	where name='".$_SESSION["user"]."'
 	and usuarios.cuenta=docente.email";
$res_cuenta=mysql_query($cuenta);
$rs_cta=array();
if($res_cuenta && mysql_num_rows($res_cuenta)>0){
    $rs_cta=mysql_fetch_array($res_cuenta);
}

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

 if($_POST['val1']==1){

 	
 

 
       $piezas=explode(" - ",$_POST['asignatura1']);


	$act_logro=" update logros set
	descripcion='".$_POST['nombre1']."',
	curso='".$piezas[1]."',
	asignatura='".$piezas[0]."',
	docente='".$_POST['docente1']."',
	planilla='".$_POST['periodo1']."',
	pensum='".$piezas[2]."',
	estado='".$_POST['estado1']."'
	where 
	Id=".$_POST['ide1']."
	";
	mysql_query($act_logro)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Logro Actualizado
			</div>";	
 

  }


   if($_POST['val1']==2||$_POST['val1']==1){

  $select_logro="select 
 		 logros.descripcion ,
 	         logros.curso,
 	         logros.docente,
 	         logros.asignatura,
 	         logros.planilla,
 	         logros.estado,
 	         curso.codigo,
 	         curso.nombre,
 	         docente.nombre,
 	         docente.teacher_id,
 	         asignatura.nombre,
 	         planilla.anno,
 	         planilla.periodo,
 	         logros.id
 		 from logros,curso,docente,asignatura,planilla 
 		 where 
 		 logros.estado in('A','I')
 		 and curso.curso_id=logros.curso
 		 and logros.docente=docente.teacher_id
 		 and logros.docente='".$rs_cta[0]."'
 		 and asignatura.subject_id=logros.asignatura
 		 and planilla.Id=logros.planilla";
   if(isset($_POST['periodo1']) && isset($_POST['cur1'])){
 		 $select_logro.=" and logros.planilla='".$_POST['periodo1']."'
 		 and curso.curso_id='".$_POST['cur1']."'";
   }
   $select_logro.=" order by curso,descripcion";
  $res_select_logro=mysql_query($select_logro);
					$tbody="<tbody>";
					while($r_slog=mysql_fetch_array($res_select_logro)){
					$c1='';$c2='';
					if($r_slog[5]=='A'){$est='Activo';$lab='success ';$c1=' selected ';}else{$est='Inactivo';$lab='danger ';$c2=' selected ';}
					$tbody.="<tr role='row'><td class='descripcion'>".$r_slog[0]."</td><td>".$r_slog[6]." - ".$r_slog[7]."</td><td class='nombre' >".$r_slog[8]."</td><td>".$r_slog[9]."</td><td>".$r_slog[10]." - ".$r_slog[11]."</td><td><span class='label label-".$lab."'>".$est."</span></td>
					<td>
 					<a class='btn btn-info btn-xs'  data-toggle='modal' data-target='#mimodala".$r_slog[12]."' onclick=''>
                 			<i class='glyphicon glyphicon-edit icon-white'></i>  
 			                Editar               
 				        </a>
					<input type='button' value='Eliminar' class='btn btn-danger btn-xs' onclick=\"if(confirm('¿Eliminar logro?')){location.href='logros.php?eliminar=".$r_slog[12]."'}\">
				        </td>
					</tr>";
	
				$tbody.="<div name='mimodala".$r_slog[12]."' id='mimodala".$r_slog[12]."' class='modal fade bs-example-modal-sm' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' aria-hidden='true'>
						  <div class='modal-dialog modal-md'>
						    <div class='modal-content'>
						      <div class='modal-header'>
							      <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>x</button>
						      		<h4 class='modal-title' id='myLargeModalLabel'>Consulta Logro</h4>
	      					      </div>
	      					      <div class='modal-body'>";
						$tbody.="
								 
						 <div class='input' style='float:left;width: 120px;padding-top: 5px;padding-left: 10px;text-align: left;height:20px;font-size:12px;' >
						Descripci&oacute;n &nbsp;  </div>
						<div class='input' ><input    value='".$r_slog[0]."' id='nombre_".$r_slog[12]."' name='nombre_".$r_slog[12]."' type='text' class='form-control2' style='width:60%;margin-bottom: 10px' >
						 </div>		 
					 <div class='input' style='float:left;width: 120px;padding-top: 5px;padding-left: 10px;text-align: left;height:20px;font-size:12px;' >
						Periodo &nbsp;  </div>
						<div class='input' >
						<select id='periodo_".$r_slog[12]."' name='periodo_".$r_slog[12]."' class='form-control2' style='width:60%;margin-bottom: 10px'>";
				
					$select_planilla2="select *  from planilla where estado='A' order by anno desc,periodo ";
					$res_select_planilla2=mysql_query($select_planilla2);
				
					$tbody.="<option value='XX' >Seleccione Periodo</option>";
					while($r_sp2=mysql_fetch_array($res_select_planilla2)){
					$sel3='  ';
					if($r_slog[4]==$r_sp2[0]){$sel3=' selected ';}
							$tbody.='<option style="font-size:9px" value="'.$r_sp2[0].'"  '.$sel3.'>'.$r_sp2[2].' - '.$r_sp2[1].' </option>';
					}		
							
							
					$tbody.="</select>
						 </div>		 


 
					 <div class='input' style='float:left;width: 120px;padding-top: 5px;padding-left: 10px;text-align: left;height:20px;font-size:12px;' >
						Docente &nbsp;  </div>
						<div class='input' >
						<select id='docente_".$r_slog[12]."' name='docente_".$r_slog[12]."' class='form-control2' style='width:50%;margin-bottom: 10px' onchange='agregar2(this.options[this.selectedIndex].value,".$r_slog[12].");'>";
				
			
				
							$select_doc2='select teacher_id,nombre
							from docente where estado="A" order by nombre';
							$res_select_doc2=mysql_query($select_doc2);
							$tbody.="<option value='XX' >Seleccione Docente</option>";
							while($r_sd2=mysql_fetch_array($res_select_doc2)){
							$sel2=' ';
							if($r_slog[2]==$r_sd2[0]){$sel2=' selected ';}
									$tbody.='<option value="'.$r_sd2[0].'"  '.$sel2.'>'.$r_sd2[0].' - '.$r_sd2[1].' </option>';
							}
							
					$tbody.="</select>
						 </div>	

					 <div class='input' style='float:left;width: 120px;padding-top: 5px;padding-left: 10px;text-align: left;height:20px;font-size:12px;' >
						Asignatura &nbsp;  </div>
						<div class='input' >
						<select id='asignatura_".$r_slog[12]."' name='asignatura_".$r_slog[12]."' class='form-control2' style='width:50%;margin-bottom: 10px'>";
				
			
				
							$select_asig2='	select
									asignatura.subject_id,
									asignatura.codigo,
									asignatura.nombre,
									asignatura.sigla,
									asignatura.estado,
									pensum.subject_id,
									pensum.class_id,
									pensum.nombre									
									from asignatura,pensum 
									where asignatura.estado="A"
									and pensum.teacher_id='.$r_slog[2].'
									and pensum.asignatura_id=asignatura.subject_id
									order by pensum.nombre,asignatura.nombre'
									;
							$res_select_asig2=mysql_query($select_asig2);
							$tbody.="<option value='XX' >Seleccione Asignatura</option>";
							while($r_asi2=mysql_fetch_array($res_select_asig2)){
							$sel4=' ';
							if($r_slog[3]==$r_asi2[0]){$sel4=' selected '; $pen=$r_asi2[5];$cur=$r_asi2[6];}

							$tbody.='<option value="'.$r_asi2[0].' - '.$cur.' - '.$pen.'"  '.$sel4.'>'.$r_asi2[2].' - '.$r_asi2[7].' </option>';
									
							}
							
					$tbody.="</select>
						 </div>								 	 
						
				
				 	 <div class='input' style='float:left;width: 120px;padding-top: 5px;padding-left: 10px;text-align: left;height:20px;font-size:12px;' >
								Estado&nbsp;  </div>
					 <div class='input' >
								 <select id='estadoa".$r_slog[12]."' name='estadoa".$r_slog[12]."' class='form-control2' style='width:50%;margin-bottom: 10px'>
								 	<option value='A' $c1 >Activo</option>
								 	<option value='I' $c2 >Inactivo</option>
								 </select>
					 </div>
						 
								 
								 
								 
								 
								 ";

						 $tbody.="<div>
						 <button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualizar_logro(".$r_slog[12].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>";	
					
				
					
					
					
					
					
					
					}
					$tbody.="</tbody>";


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

 if($_POST['val2']==1){
  $class1="";
  $class2="class=\"active\"";
  $act1="";
  $act2=" active ";
		
$select_curso="select curso_id from curso,pensum where curso.curso_id=pensum.class_id and pensum.subject_id=".$_POST['pensum2']." ";
$res_select_curso=mysql_query($select_curso);
$rs_curso=mysql_fetch_array($res_select_curso);

	$insertar_asignatura='insert into logros (descripcion,pensum,asignatura,docente,planilla,curso,estado)
	values("'.$_POST['nombre_registro2'].'","'.$_POST['pensum2'].'","'.$_POST['asignatura2'].'","'.$_POST['docente2'].'","'.$_POST['periodo2'].'","'.$rs_curso[0].'","A"
	)';
	mysql_query($insertar_asignatura)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Registro: ".$_POST['nombre_registro2']." Insertado
			</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'>

    <title>Logros</title>

    <link href='../dist/css/bootstrap.min.css' rel='stylesheet'>
    <link href='../offcanvas.css' rel='stylesheet'>

    <style>
    .sidebar-offcanvas {
        transition: all 0.3s ease-in-out;
    }
    .sidebar-hidden {
        display: none;
    }
    .main-content-full {
        width: 100% !important;
        max-width: 100% !important;
    }
    #menu-toggle {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 9999;
        background: #333;
        border: none;
        color: white;
        font-size: 16px;
        cursor: pointer;
        padding: 8px 10px;
        border-radius: 3px;
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
    }
    #menu-toggle:hover {
        background: #555;
        color: white;
    }
    #menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        background: white;
        border-radius: 1px;
    }
    .navbar-fixed-top {
        padding-left: 60px;
    }
    </style>

    <!--[if lt IE 9]><script src='../assets/js/ie8-responsive-file-warning.js'></script><![endif]-->
    <!--[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 consulta_logro( per,cur){
 if(document.getElementById('l_periodo1').value=='XX'){alert('Debe seleccionar Periodo');return false;}
 	else{document.getElementById('periodo1').value=document.getElementById('l_periodo1').value}			
 if(document.getElementById('l_curso1').value=='XX'){alert('Debe seleccionar Curso');return false;}
 	else{document.getElementById('cur1').value=document.getElementById('l_curso1').value}			


	document.getElementById('val1').value=2;
	document.forms['listar_pensum'].submit();



}        
function actualizar_logro(ide){


 if(document.getElementById('nombre_'+ide).value==''){alert('Debe digitar Descripcion');return false;}
 	else{document.getElementById('nombre1').value=document.getElementById('nombre_'+ide).value}
 if(document.getElementById('periodo_'+ide).value=='XX'){alert('Debe seleccionar Periodo');return false;}
 	else{document.getElementById('periodo1').value=document.getElementById('periodo_'+ide).value}			
 if(document.getElementById('docente_'+ide).value=='XX'){alert('Debe seleccionar Docente');return false;}
 	else{document.getElementById('docente1').value=document.getElementById('docente_'+ide).value}			
 if(document.getElementById('asignatura_'+ide).value=='XX'){alert('Debe seleccionar Asignatura');return false;}
 	else{document.getElementById('asignatura1').value=document.getElementById('asignatura_'+ide).value}			
	
	document.getElementById('estado1').value=document.getElementById('estadoa'+ide).value;
	document.getElementById('ide1').value=ide;

	
	document.getElementById('val1').value=1;
	document.forms['listar_pensum'].submit();
}   

function crea_registro(){

if(document.getElementById('nombre_registro').value==''){alert('Debe digitar el nombre del Registro');return false;}else{document.getElementById('nombre_registro2').value=document.getElementById('nombre_registro').value}
	
if(document.getElementById('l_periodo').value=='XX'){alert('Debe seleccionar el Periodo');return false;}else{document.getElementById('periodo2').value=document.getElementById('l_periodo').value}

document.getElementById('docente2').value=document.getElementById('l_docente').value;

if(document.getElementById('l_materias').value=='XX'){alert('Debe seleccionar Asignatura');return false;}
	else{
		
		var mystr = document.getElementById('l_materias').value;
		var myarr = mystr.split('-');
		var myvar0 = myarr[0];  
		var myvar1 = myarr[1];  
		
		document.getElementById('asignatura2').value=myvar1;
		document.getElementById('pensum2').value=myvar0;		


		
		}


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

function agregar2(doc,ide){

 	var k,c;
 	k=1;c=0;
 	var mat= document.getElementById('asignatura_'+ide);
 	var m1 = document.createElement('option');
 	mat.options.length=0;";
 	$sel2='false';
 	
 	$TABLA_ASIG = mysql_query("SELECT * FROM pensum where estado='A' order by nombre");
 		while($munic = mysql_fetch_array($TABLA_ASIG)) {
 		echo   "if(doc ==$munic[3]) {";
 				$municipios =mysql_query("SELECT * FROM asignatura where subject_id=$munic[4] order by  nombre");
 				if(isset($municipios)){
 				
 				echo "mat.options[0] = new Option('Seleccione Materia...', 'XX', false, false);";  
 					while($m12 = mysql_fetch_array($municipios)) {
 				
 						 echo "mat.options[k] = new Option('".$m12[2]."'+' - '+'".$munic[1]."','".$m12[0]."'+' - '+'".$munic[2]."'+' - '+'".$munic[0]."',$sel2,$sel2);  
 						 k++;";
 					}
 				}
 				
 			echo"
 			
 			}";
 		}

echo	"}


function agregar(doc){

 	var k,c;
 	k=1;c=0;
 	var mat= document.getElementById('l_materias');
 	var m1 = document.createElement('option');
 	mat.options.length=0;";
 	$sel2='false';
 	$TABLA_ASIG = mysql_query("SELECT * FROM pensum where estado='A' order by nombre");
 		while($munic = mysql_fetch_array($TABLA_ASIG)) {
 		echo   "if(doc ==$munic[3]) {";
 				$municipios =mysql_query("SELECT * FROM asignatura where subject_id=$munic[4] order by  nombre");
 				if(isset($municipios)){
 				echo "mat.options[0] = new Option('Seleccione Materia...', 'XX', false, false);";  
 					while($m12 = mysql_fetch_array($municipios)) {
 				
 						 echo "mat.options[k] = new Option('".$m12[2]."'+' - '+'".$munic[1]."' , '".$munic[0]."-".$munic[4]."',$sel2,$sel2);  
 						 k++;";
 					}
 				}
 			echo"}";
 		}
echo	"}


</script>
   
   </head>

  <body>
    <button type=\"button\" id=\"menu-toggle\" onclick=\"toggleMenu()\">
        <span></span>
        <span></span>
        <span></span>
    </button>

    <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 ".$act1."><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=\"horario.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Horario</a>
            <a href=\"logros.php\" class=\"list-group-item active\"><span class=\"glyphicon glyphicon-edit\"></span> Logros</a>            
            <a href=\"planilla.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Planilla Notas</a>   
            <a href=\"planilla_asistencia.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Asistencia</a>                     
            <a href=\"reportes.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Informes</a>
            <a href=\"planilla_obs.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Planilla Obs.</a>
            <a href=\"eventos.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Anuncios</a>";
            if(isset($rs_cta[1]) && $rs_cta[1]==1){
                echo "<a href=\"obs_disciplinarias.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Registro Obs.</a>";
            }
            echo "</div>
        </div><!--/span-->


        <div class=\"col-xs-12 col-sm-9 main-content\" id=\"main-content\">
          <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\">Gestion Registros</a></li>
	  <li $class2 ><a href=\"#profile\" data-toggle=\"tab\">Crear Logro</a></li>
	</ul>
	
	<!-- Tab panes -->

	<div class=\"tab-content\">
	<div class=\"tab-pane fade in $act2 \" id=\"profile\">
		<form name='crear_pensum' id='crear_pensum' method='post' action='logros.php#profile' target='' >
		<input type='hidden' name='val2' id='val2' value='".$val2."'>	
		<input type='hidden' name='nombre_registro2' id='nombre_registro2' value='".$nombre_registro2."'>	
		<input type='hidden' name='l_curso22' id='l_curso22' value='".$l_curso22."'>
		<input type='hidden' name='docente2' id='docente2' value='".$docente2."'>		
		<input type='hidden' name='asignatura2' id='asignatura2' value='".$asignatura2."'>				
		<input type='hidden' name='pensum2' id='pensum2' value='".$pensum2."'>						
		<input type='hidden' name='periodo2' id='periodo2' value='".$periodo2."'>	

		<div class=\"page\">
			<fieldset>
				<legend>
					<br><span class=\"glyphicon glyphicon-plus\"></span> Crear Nuevo Registro          
				</legend>			
			</fieldset>
		
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;text-align: right;' >
			Descripci&oacute;n&nbsp;
		  </div>
		  
		 <div class='input' >
		    <input id='nombre_registro' name='nombre_registro' type='text' class='form-control' placeholder='' style='width:48%;margin-bottom: 10px'>
		 </div>
		  <div class='input' style='float:left;width: 140px;padding-top: 5px;text-align: right;' >
			Periodo&nbsp;
		  </div>
		 
		 ";

				$select_planilla="select *  from planilla where estado='A' order by anno desc,periodo ";
					$res_select_planilla=mysql_query($select_planilla);


echo "
		 <div class='input' >
				<select id='l_periodo' name='l_periodo'  class='form-control' style='width:48%;margin-bottom: 10px'>
					<option value='XX' >Seleccione Periodo</option>";
					while($r_sc=mysql_fetch_array($res_select_planilla)){
					$sel1='  ';
					echo '<option style="font-size:9px" value="'.$r_sc[0].'"  '.$sel1.'  >P'.$r_sc[2].' - '.$r_sc[1].' </option>';
					}
					

echo				'</select>
		 </div>';
echo		 "<div class='input' style='float:left;width: 140px;padding-top: 5px;text-align: right;' >
  			Docente&nbsp;
  		  </div>
  		 <div class='input' >
  		<select class='form-control' style='width:48%;margin-bottom: 10px' name='l_docente' id='l_docente'  onchange='agregar(this.options[this.selectedIndex].value);'  >
  			<option value='XX'>Seleccione Docente</option>";

  				$docente_id = isset($rs_cta[0]) ? $rs_cta[0] : '0';
  				$sql_doc="select teacher_id,nombre  from docente where estado='A' and teacher_id='".$docente_id."' order by nombre";
  				$result_sql_doc=mysql_query($sql_doc);
  				while($r=mysql_fetch_array($result_sql_doc)){
  					echo '<option value="'.$r[0].'">'.$r[0].' - '.$r[1].'</option>';
  				}
  					

echo				"</select>
  		 </div>";



					
echo					'<div class="input" style="float:left;width: 140px;padding-top: 5px;text-align: right;" >
			Asignatura&nbsp;
		  </div>
		 <div class="input" >
			
			<select class="form-control" style="width:48%;margin-bottom: 10px" name="l_materias" id="l_materias"   >
					<option value="XX">Seleccione Materia</option>
			</select>
  		 </div>
		
		<fieldset>
		<legend>
					<br>
					
		</legend>	
			<button type="button" class="btn btn-info" onclick="crea_registro()"> Crear Registro</button>     
			<input type="reset" class="btn" value="Borrar">
						
		</fieldset>
			
			<br>
		</div>
	</form>
</div>';

echo "<div class=\"tab-pane fade in $act1 \" id=\"home\">
   	<form name=\"listar_pensum\" id=\"listar_pensum\" method=\"post\" action=\"logros.php\" target=\"\">
   	<div class=\"page\">";
  
echo "<input type=\"hidden\" name=\"val1\" id=\"val1\" value=\"".$val1."\">	
  	<input type=\"hidden\" name=\"cur1\" id=\"cur1\" value=\"".$cur1."\">	
  	<input type=\"hidden\" name=\"nombre1\" id=\"nombre1\" value=\"".$nombre1."\">
  	<input type=\"hidden\" name=\"periodo1\" id=\"periodo1\" value=\"".$periodo1."\">
  	<input type=\"hidden\" name=\"docente1\" id=\"docente1\" value=\"".$docente1."\">
  	<input type=\"hidden\" name=\"asignatura1\" id=\"asignatura1\" value=\"".$asignatura1."\">
  	
  	<input type=\"hidden\" name=\"curso1\" id=\"curso1\" value=\"".$curso1."\">
  	<input type=\"hidden\" name=\"pensum1\" id=\"pensum1\" value=\"".$pensum1."\">	
  	<input type=\"hidden\" name=\"curso1a\" id=\"curso1a\" value=\"".$curso1a."\">
  	<input type=\"hidden\" name=\"pensum1a\" id=\"pensum1a\" value=\"".$pensum1a."\">	
  	<input type=\"hidden\" name=\"estado1\" id=\"estado1\" value=\"".$estado1."\">						
  	<input type=\"hidden\" name=\"ide1\" id=\"ide1\" value=\"".$ide1."\">";

echo "<fieldset>
  			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
  				Listado de Logros  ";

$select_planilla1="select *  from planilla where estado in ('A','C') order by anno desc,periodo ";
$res_select_planilla1=mysql_query($select_planilla1);



echo "
				<select id='l_periodo1' name='l_periodo1'  style='margin:20px;font-size: 12px;'>
					<option value='XX' >Seleccione Periodo</option>";
					while($r_sc1=mysql_fetch_array($res_select_planilla1)){
					$sel1='  ';
					echo '<option style="font-size:9px" value="'.$r_sc1[0].'"  '.$sel1.'  >P'.$r_sc1[2].' - '.$r_sc1[1].' </option>';
					}
					

echo				"</select>
 			<select style='margin:20px;font-size: 12px;' name='l_curso1' id='l_curso1' >";

 				$sql_doc="select distinct c.curso_id,c.codigo,c.nombre,c.estado  
 					from curso c, pensum p 
 					where c.estado='A' 
 					and p.class_id=c.curso_id 
 					and p.teacher_id='".$rs_cta[0]."' 
 					order by c.orden";
 				$result_sql_doc=mysql_query($sql_doc);
 				echo '<option class="" value="XX" >Seleccione Curso</option>';
 				while($r=mysql_fetch_array($result_sql_doc)){
 						echo '<option value="'.$r[0].'"  >'.$r[1].' - '.$r[2].'</option>';
 				}

echo	"</select>

 				<button type='button' class='btn btn-info btn-sm' onclick='consulta_logro(document.getElementById(\"l_periodo1\").value,document.getElementById(\"l_curso1\").value)'><i class='glyphicon glyphicon-zoom-in'></i> Buscar</button>
 				";			

echo "	          
 			</legend>			
 		</fieldset>
 	</div>
 	
 	<fieldset>
 	<div class='table-responsive'>
 	<p><input type='text' id='search_string' name='search_string' value='Buscar...' onclick='this.value=\"\"' /></p>	
 	<table id='logros' class='table  table-striped table-bordered  '>
 		<thead>
 			<tr role='row'>
 				<th>Descripci&oacute;n</th>
 				<th>Curso</th>				
 				<th>Docente</th>				
 				<th>Asignatura</th>								
 				<th>Periodo</th>				
 				<th>Estado</th>
 				<th></th>										
 			</tr>
 		</thead>";
 		
echo $tbody;
echo	"</div>
 	</table>
 	</fieldset>
 	</form>

</div>";
          
echo "</div><!--/span-->

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


</div></div><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=\"../offcanvas.js\"></script>
       <script>
        
    $.expr[':'].Contains = function(x, y, z){
        return jQuery(x).text().toLowerCase().indexOf(z[3].toLowerCase())>=0;
    };

    // cada que escribamos, vamos a revisar lo que hay escrito 
    $('#search_string').keyup(function() 
    {
        //tomamos el valor que tiene el input
        var search = $('#search_string').val();
        //mostramos todos los valores, para despues ir ocultando los que no coinciden
        $('#logros tr').show();
        
        //esto es para revisar si tenemos algo que buscar, sino, que no lo haga.
        if(search.length>0)
        {
        // con la clase .nombre le decimos en cual de las celdas buscar y si no coincide, ocultamos el tr que contiene a esa celda. 
        $('#logros tr td.descripcion').not(':Contains('+search+')').parent().hide();
        }

});
    
    </script>
<script src='js/tablesort.min.js'></script>
    <script>
      new Tablesort(document.getElementById('logros'));
    </script>
<script>
var menuVisible = true;
function toggleMenu() {
    var sidebar = document.getElementById('sidebar');
    var mainContent = document.getElementById('main-content');
    var toggleBtn = document.getElementById('menu-toggle');
    
    if (menuVisible) {
        sidebar.classList.add('sidebar-hidden');
        if(mainContent) mainContent.classList.add('main-content-full');
        if(mainContent) mainContent.classList.remove('col-sm-9');
        toggleBtn.innerHTML = '<span style=\"transform: rotate(45deg); position: absolute;\"></span><span style=\"opacity: 0;\"></span><span style=\"transform: rotate(-45deg); position: absolute;\"></span>';
    } else {
        sidebar.classList.remove('sidebar-hidden');
        if(mainContent) mainContent.classList.remove('main-content-full');
        if(mainContent) mainContent.classList.add('col-sm-9');
        toggleBtn.innerHTML = '<span></span><span></span><span></span>';
    }
    menuVisible = !menuVisible;
}
</script>
  </body>
</html>
";
}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='index.php' > Registrar</a></div>";
}
?>