<?php   include 'conector.php';
session_start();
include 'menu_header.php';
$men="";$val1="";$val2="";$val3="";$val4="";$cur1="";$cur2="";$cur3="";$cur4="";
$class1="";$class2="";$class3="";$class4="";$act1="";$act2="";$act3="";$act4="";$tbody="";
$l_curso22="";$asignatura2="";$dias2="";$hi2="";$mi2="";$hf2="";$mf2="";

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

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


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

 if($_POST['val1']==2){
$del_horario="delete from horario 
where id=".$_POST['horariob']." ";
//echo $del_horario;
mysql_query($del_horario)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Registro Borrado
			</div>";

 }

 if($_POST['val1']==1){
$select_docente="select docente.teacher_id
	from pensum,docente 
	where
	pensum.teacher_id=docente.teacher_id
	and docente.estado='A'
	and pensum.estado='A'
	and pensum.asignatura_id='".$_POST['asignaturab']."'
	and pensum.class_id='".$_POST['l_cursob']."'
	";
	$res_select_docente=mysql_query($select_docente);
	$rs_sel_doc2=mysql_fetch_array($res_select_docente);
 
 
$act_horario="update horario set
curso='".$_POST['l_cursob']."',
asignatura='".$_POST['asignaturab']."',
dia=".$_POST['diasb'].",
hi=".$_POST['hib'].",
mi=".$_POST['mib'].",
hf=".$_POST['hfb'].",
mf=".$_POST['mfb'].",
fecha_modif=now(),
docente=".$rs_sel_doc2[0]."
where id=".$_POST['horariob']."
";//echo $act_horario;
mysql_query($act_horario)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Horario Actualizado
			</div>";

 }
}

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

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

if($_POST['asignatura2']!='DE'&&$_POST['asignatura2']!='PR'){

	$select_docente="select docente.teacher_id
	from pensum,docente 
	where
	pensum.teacher_id=docente.teacher_id
	and docente.estado='A'
	and pensum.estado='A'
	and pensum.asignatura_id='".$_POST['asignatura2']."'
	and pensum.class_id='".$_POST['l_curso22']."'
	";
	$res_select_docente=mysql_query($select_docente);
	$rs_sel_doc=mysql_fetch_array($res_select_docente);

	if(mysql_query($select_docente)){
	$num_doc=mysql_num_rows($res_select_docente);
	}
						
   if(isset($num_doc)&&$num_doc>0)	{
	$insertar_horario='insert into horario (curso,asignatura,dia,hi,mi,hf,mf,fecha_insert,estado,docente)
	values("'.$_POST['l_curso22'].'","'.$_POST['asignatura2'].'",'.$_POST['dias2'].','.$_POST['hi2'].','.$_POST['mi2'].','.$_POST['hf2'].','.$_POST['mf2'].',now(),
	"A",'.$rs_sel_doc[0].'
	)';
	mysql_query($insertar_horario)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Horario Insertado
			</div>";
	}else{
		$men="<div class=\"alert alert-danger\">
	                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
	                  No se pudo crear Horario -  Debe Revisar Pensum
				</div>";
	}

 }else{
 
 if($_POST['asignatura2']=='DE'){$asign='Descanso';} if($_POST['asignatura2']=='PR'){$asign='Proyecto';}
 $insertar_horario='insert into horario (curso,asignatura,dia,hi,mi,hf,mf,fecha_insert,estado)
	values("'.$_POST['l_curso22'].'","'.$asign.'",'.$_POST['dias2'].','.$_POST['hi2'].','.$_POST['mi2'].','.$_POST['hf2'].','.$_POST['mf2'].',now(),
	"A"
	)';
	mysql_query($insertar_horario)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Descanso Insertado
			</div>";
 
 
 }	






 }
}





$select_curso='select curso_id,nombre,codigo
					from curso order by orden';
					$res_select_curso=mysql_query($select_curso);


 $select_horario="select 
			 curso,asignatura,dia,hi,mi,hf,mf
			 from horario 
			 where horario.estado='A' order by dia";
			 $res_select_horario=mysql_query($select_horario);

					
//					$tbody.="<tr role='row'><td>".$r_sag[0]."</td><td>".$r_sag[1]."</td><td>".$r_sag[2]."</td><td>".$r_sag[3]."</td><td>".$r_sag[4]."</td><td>&nbsp;</td></tr>
					
				$tbody.="<div class='panel-group' id='accordion'>";
				while($r_cur=mysql_fetch_array($res_select_curso)){
				$tbody.="<div class='panel panel-default'>
					    <div class='panel-heading'>
					      <h4 class='panel-title'>
					        <a data-toggle='collapse' data-parent='#accordion' href='#collapseOne".$r_cur[0]."'>
					          <font size='2.5em'><b>Curso - ".$r_cur[1]."</b></font>
					        </a>
					      </h4>
					    </div>
					    <div id='collapseOne".$r_cur[0]."' class='panel-collapse collapse '>
					      <div class='panel-body'>
					      	<div class='table-responsive'  style='z-index:-1;'>
					      	<table cellpadding='0' cellspacing='0' border='0' class='table table-striped table-bordered '  >
					      	 <tbody>	
					      ";
//table-normal
						  //    for($i=1;$i<8;$i++){
							$tbody.="
							<tr>
								<td  align='center'><strong>Lunes</strong></td>
								<td  align='center'><strong>Martes</strong></td>								
								<td  align='center'><strong>Mi&eacute;rcoles</strong></td>
								<td  align='center'><strong>Jueves</strong></td>
								<td  align='center'><strong>Viernes</strong></td>
								<td  align='center'><strong>S&aacute;bado</strong></td>								
							</tr>
							<tr>	<td>";
						
//inicio ciclo
						 $select_horario="
							select * from 
							(
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf,horario.asignatura  as asig, horario.id, '' 
								from horario
								where horario.estado='A' 
								and horario.dia=1
								and horario.curso=".$r_cur[0]." 
								and horario.asignatura in ('Descanso','Proyecto')
								)
								union
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf, asignatura.nombre  as asig, horario.id, docente.nombre 
								from horario,asignatura,docente 
								where horario.estado='A' 
								 and horario.dia=1
								 and horario.asignatura=asignatura.subject_id
								 and horario.curso=".$r_cur[0]."
								and docente.teacher_id=horario.docente 
								 )
								 ) a
								 order by a.dia,a.hi,a.mi";
							// echo $select_horario."<br>";
							 $res_select_horario=mysql_query($select_horario);
						
							if(mysql_query($select_horario)){
							$num_hor=mysql_num_rows($res_select_horario);
							}
						
						if(isset($num_hor)&&$num_hor>0)	{
							
							while($r_selhor=mysql_fetch_array($res_select_horario)){
							if($r_selhor[4]==0){$r_selhor[4]='00';}if($r_selhor[6]==0){$r_selhor[6]='00';}
							if($r_selhor[4]==5){$r_selhor[4]='05';}if($r_selhor[6]==5){$r_selhor[6]='05';}							
							$tbody.="
								<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:9px;margin-bottom:5px'>
								    ".$r_selhor[7]." <br>( ".$r_selhor[3].":".$r_selhor[4]." - ".$r_selhor[5].":".$r_selhor[6]." ) "."<br>$r_selhor[9] &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$r_selhor[8]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$r_selhor[8].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								<br>
								";
					$tbody.="<div name='mimodala".$r_selhor[8]."' id='mimodala".$r_selhor[8]."' 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'>Editar Horario</h4>
      					      </div>
      					      <div class='modal-body'>";
					
							//if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
						         <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Curso&nbsp;
							  </div>
							 <div class='input' >
								<select id='l_cursob".$r_selhor[8]."' name='l_cursob".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$select_curso2="select curso_id,nombre,codigo
								from curso order by orden";
								$res_select_curso2=mysql_query($select_curso2);
								$tbody.= "<option value='XX' >Seleccione Curso</option>";
								while($r_sc2=mysql_fetch_array($res_select_curso2)){
								$sel1='  ';
								if($r_cur[0]==$r_sc2[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc2[0]."  ".$sel1.">".$r_sc2[2]." - ".$r_sc2[1]." </option>";
								}
								
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Asignatura&nbsp;
							  </div>
							 <div class='input' >
								<select id='asignaturab".$r_selhor[8]."' name='asignaturab".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								
								$select_doc2="select subject_id,codigo,nombre,sigla
									from asignatura 
									where estado='A'
									order by nombre";
								$res_select_doc2=mysql_query($select_doc2);
								$sela='';$selb='';
								if($r_selhor[7]=='Descanso'){$sela=' selected';}if($r_selhor[7]=='Proyecto'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='Descanso' $sela >DESCANSO</option>
								<option value='Proyecto' $selb >PROYECTO</option>								
								";
								while($r_sc3=mysql_fetch_array($res_select_doc2)){
								$sel1='  ';
								if($r_selhor[1]==$r_sc3[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc3[0]."  ".$sel1.">".$r_sc3[2]." </option>";
								}

							$tbody.="</select>
							</div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$r_selhor[8]."' name='diasb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($r_selhor[2]==$k){$sele[$k]= ' selected ';}else{$sele[$k]='';}
								}
								$tbody.="<option value='XX' >Seleccione Dia</option>
									<option value=1 ".$sele[1]." >Lunes</option>
									<option value=2 ".$sele[2]." >Martes</option>
									<option value=3 ".$sele[3]." >Mi&eacute;rcoles</option>
									<option value=4 ".$sele[4]." >Jueves</option>
									<option value=5 ".$sele[5]." >Viernes</option>
									<option value=6 ".$sele[6]." >S&aacute;bado</option>
									<option value=7 ".$sele[7]." >Domingo</option>				
								</select>
							 </div>
							 
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Inicial&nbsp;
							  </div>
							 <div class='input' >
								<select id='hib".$r_selhor[8]."' name='hib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[3]==$k){$sele2[$k]= ' selected ';}else{$sele2[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele2[6]." >06</option><option value=7 ".$sele2[7]." >07</option><option value=8 ".$sele2[8]." >08</option>
									<option value=9 ".$sele2[9]." >09</option><option value=10 ".$sele2[10]." >10</option><option value=11 ".$sele2[11]." >11</option>
									<option value=12 ".$sele2[12]." >12</option><option value=13 ".$sele2[13]." >13</option><option value=14 ".$sele2[14]." >14</option>
									<option value=15 ".$sele2[15]." >15</option><option value=16 ".$sele2[16]." >16</option><option value=17 ".$sele2[17]." >17</option>
									<option value=18 ".$sele2[18]." >18</option><option value=19 ".$sele2[19]." >19</option><option value=20 ".$sele2[20]." >20</option>				
									<option value=21 ".$sele2[21]." >21</option><option value=22 ".$sele2[22]." >22</option>					
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Inicial&nbsp;
								  </div>
								 <div class='input' >
								<select id='mib".$r_selhor[8]."' name='mib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[4]==$k){$sele3[$k]= ' selected ';}else{$sele3[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele3[0]." >00</option><option value=5 ".$sele3[5]." >5</option><option value=10 ".$sele3[10]." >10</option>
									<option value=15 ".$sele3[15]." >15</option><option value=20 ".$sele3[20]." >20</option><option value=25 ".$sele3[25]." >25</option>
									<option value=30 ".$sele3[30]." >30</option><option value=35 ".$sele3[35]." >35</option><option value=40 ".$sele3[40]." >40</option>
									<option value=45 ".$sele3[45]." >45</option><option value=50 ".$sele3[50]." >50</option><option value=55 ".$sele3[55]." >55</option>	
								</select>
					
							 </div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Final&nbsp;
							  </div>
							 <div class='input' >
								<select id='hfb".$r_selhor[8]."' name='hfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[5]==$k){$sele4[$k]= ' selected ';}else{$sele4[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele4[6]." >06</option><option value=7 ".$sele4[7]." >07</option><option value=8 ".$sele4[8]." >08</option>
									<option value=9 ".$sele4[9]." >09</option><option value=10 ".$sele4[10]." >10</option><option value=11 ".$sele4[11]." >11</option>
									<option value=12 ".$sele4[12]." >12</option><option value=13 ".$sele4[13]." >13</option><option value=14 ".$sele4[14]." >14</option>
									<option value=15 ".$sele4[15]." >15</option><option value=16 ".$sele4[16]." >16</option><option value=17 ".$sele4[17]." >17</option>
									<option value=18 ".$sele4[18]." >18</option><option value=19 ".$sele4[19]." >19</option><option value=20 ".$sele4[20]." >20</option>								<option value=21 ".$sele4[21]." >21</option><option value=22 ".$sele4[22]." >22</option>	
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Final&nbsp;
								  </div>
								 <div class='input' >
								<select id='mfb".$r_selhor[8]."' name='mfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[6]==$k){$sele5[$k]= ' selected ';}else{$sele5[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele5[0]." >00</option><option value=5 ".$sele5[5]." >5</option><option value=10 ".$sele5[10]." >10</option>
									<option value=15 ".$sele5[15]." >15</option><option value=20 ".$sele5[20]." >20</option><option value=25 ".$sele5[25]." >25</option>
									<option value=30 ".$sele5[30]." >30</option><option value=35 ".$sele5[35]." >35</option><option value=40 ".$sele5[40]." >40</option>
									<option value=45 ".$sele5[45]." >45</option><option value=50 ".$sele5[50]." >50</option><option value=55 ".$sele5[55]." >55</option>									
								</select>
							 	</div>
							 	
							 <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$r_selhor[8].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
						</div>	
					</div>
				</div>
			</div>	
							";
							}	
						}
						$tbody.="</td>								
							<td>";	      
//fin ciclo
//inicio ciclo
						 $select_horario="
							select * from 
							(
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf,horario.asignatura  as asig, horario.id, '' 
								from horario
								where horario.estado='A' 
								and horario.dia=2
								and horario.curso=".$r_cur[0]." 
								and horario.asignatura in ('Descanso','Proyecto')
								)
								union
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf, asignatura.nombre  as asig, horario.id, docente.nombre 
								from horario,asignatura,docente 
								where horario.estado='A' 
								 and horario.dia=2
								 and horario.asignatura=asignatura.subject_id
								 and horario.curso=".$r_cur[0]."
								and docente.teacher_id=horario.docente 
								 )
								 ) a
								 order by a.dia,a.hi,a.mi";
							// echo $select_horario."<br>";
							 $res_select_horario=mysql_query($select_horario);
						
							if(mysql_query($select_horario)){
							$num_hor=mysql_num_rows($res_select_horario);
							}
						
						if(isset($num_hor)&&$num_hor>0)	{
							
							while($r_selhor=mysql_fetch_array($res_select_horario)){
							if($r_selhor[4]==0){$r_selhor[4]='00';}if($r_selhor[6]==0){$r_selhor[6]='00';}
							if($r_selhor[4]==5){$r_selhor[4]='05';}if($r_selhor[6]==5){$r_selhor[6]='05';}							
							$tbody.="
								<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:9px;margin-bottom:5px'>
								    ".$r_selhor[7]." <br>( ".$r_selhor[3].":".$r_selhor[4]." - ".$r_selhor[5].":".$r_selhor[6]." ) "."<br>$r_selhor[9] &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$r_selhor[8]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$r_selhor[8].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								<br>
								";
					$tbody.="<div name='mimodala".$r_selhor[8]."' id='mimodala".$r_selhor[8]."' 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'>Editar Horario</h4>
      					      </div>
      					      <div class='modal-body'>";
					
							//if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
						         <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Curso&nbsp;
							  </div>
							 <div class='input' >
								<select id='l_cursob".$r_selhor[8]."' name='l_cursob".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$select_curso2="select curso_id,nombre,codigo
								from curso order by orden";
								$res_select_curso2=mysql_query($select_curso2);
								$tbody.= "<option value='XX' >Seleccione Curso</option>";
								while($r_sc2=mysql_fetch_array($res_select_curso2)){
								$sel1='  ';
								if($r_cur[0]==$r_sc2[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc2[0]."  ".$sel1.">".$r_sc2[2]." - ".$r_sc2[1]." </option>";
								}
								
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Asignatura&nbsp;
							  </div>
							 <div class='input' >
								<select id='asignaturab".$r_selhor[8]."' name='asignaturab".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								
								$select_doc2="select subject_id,codigo,nombre,sigla
									from asignatura 
									where estado='A'
									order by nombre";
								$res_select_doc2=mysql_query($select_doc2);
								$sela='';$selb='';
								if($r_selhor[7]=='Descanso'){$sela=' selected';}if($r_selhor[7]=='Proyecto'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='Descanso' $sela >DESCANSO</option>
								<option value='Proyecto' $selb >PROYECTO</option>								
								";
								while($r_sc3=mysql_fetch_array($res_select_doc2)){
								$sel1='  ';
								if($r_selhor[1]==$r_sc3[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc3[0]."  ".$sel1.">".$r_sc3[2]." </option>";
								}

							$tbody.="</select>
							</div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$r_selhor[8]."' name='diasb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($r_selhor[2]==$k){$sele[$k]= ' selected ';}else{$sele[$k]='';}
								}
								$tbody.="<option value='XX' >Seleccione Dia</option>
									<option value=1 ".$sele[1]." >Lunes</option>
									<option value=2 ".$sele[2]." >Martes</option>
									<option value=3 ".$sele[3]." >Mi&eacute;rcoles</option>
									<option value=4 ".$sele[4]." >Jueves</option>
									<option value=5 ".$sele[5]." >Viernes</option>
									<option value=6 ".$sele[6]." >S&aacute;bado</option>
									<option value=7 ".$sele[7]." >Domingo</option>				
								</select>
							 </div>
							 
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Inicial&nbsp;
							  </div>
							 <div class='input' >
								<select id='hib".$r_selhor[8]."' name='hib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[3]==$k){$sele2[$k]= ' selected ';}else{$sele2[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele2[6]." >06</option><option value=7 ".$sele2[7]." >07</option><option value=8 ".$sele2[8]." >08</option>
									<option value=9 ".$sele2[9]." >09</option><option value=10 ".$sele2[10]." >10</option><option value=11 ".$sele2[11]." >11</option>
									<option value=12 ".$sele2[12]." >12</option><option value=13 ".$sele2[13]." >13</option><option value=14 ".$sele2[14]." >14</option>
									<option value=15 ".$sele2[15]." >15</option><option value=16 ".$sele2[16]." >16</option><option value=17 ".$sele2[17]." >17</option>
									<option value=18 ".$sele2[18]." >18</option><option value=19 ".$sele2[19]." >19</option><option value=20 ".$sele2[20]." >20</option>				
									<option value=21 ".$sele2[21]." >21</option><option value=22 ".$sele2[22]." >22</option>					
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Inicial&nbsp;
								  </div>
								 <div class='input' >
								<select id='mib".$r_selhor[8]."' name='mib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[4]==$k){$sele3[$k]= ' selected ';}else{$sele3[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele3[0]." >00</option><option value=5 ".$sele3[5]." >5</option><option value=10 ".$sele3[10]." >10</option>
									<option value=15 ".$sele3[15]." >15</option><option value=20 ".$sele3[20]." >20</option><option value=25 ".$sele3[25]." >25</option>
									<option value=30 ".$sele3[30]." >30</option><option value=35 ".$sele3[35]." >35</option><option value=40 ".$sele3[40]." >40</option>
									<option value=45 ".$sele3[45]." >45</option><option value=50 ".$sele3[50]." >50</option><option value=55 ".$sele3[55]." >55</option>	
								</select>
					
							 </div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Final&nbsp;
							  </div>
							 <div class='input' >
								<select id='hfb".$r_selhor[8]."' name='hfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[5]==$k){$sele4[$k]= ' selected ';}else{$sele4[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele4[6]." >06</option><option value=7 ".$sele4[7]." >07</option><option value=8 ".$sele4[8]." >08</option>
									<option value=9 ".$sele4[9]." >09</option><option value=10 ".$sele4[10]." >10</option><option value=11 ".$sele4[11]." >11</option>
									<option value=12 ".$sele4[12]." >12</option><option value=13 ".$sele4[13]." >13</option><option value=14 ".$sele4[14]." >14</option>
									<option value=15 ".$sele4[15]." >15</option><option value=16 ".$sele4[16]." >16</option><option value=17 ".$sele4[17]." >17</option>
									<option value=18 ".$sele4[18]." >18</option><option value=19 ".$sele4[19]." >19</option><option value=20 ".$sele4[20]." >20</option>								<option value=21 ".$sele4[21]." >21</option><option value=22 ".$sele4[22]." >22</option>	
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Final&nbsp;
								  </div>
								 <div class='input' >
								<select id='mfb".$r_selhor[8]."' name='mfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[6]==$k){$sele5[$k]= ' selected ';}else{$sele5[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele5[0]." >00</option><option value=5 ".$sele5[5]." >5</option><option value=10 ".$sele5[10]." >10</option>
									<option value=15 ".$sele5[15]." >15</option><option value=20 ".$sele5[20]." >20</option><option value=25 ".$sele5[25]." >25</option>
									<option value=30 ".$sele5[30]." >30</option><option value=35 ".$sele5[35]." >35</option><option value=40 ".$sele5[40]." >40</option>
									<option value=45 ".$sele5[45]." >45</option><option value=50 ".$sele5[50]." >50</option><option value=55 ".$sele5[55]." >55</option>									
								</select>
							 	</div>
							 	
							 <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$r_selhor[8].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
						</div>	
					</div>
				</div>
			</div>	
							";
							}	
						}
						$tbody.="</td>								
							<td>";	      
//fin ciclo
//inicio ciclo
						 $select_horario="
							select * from 
							(
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf,horario.asignatura  as asig, horario.id, '' 
								from horario
								where horario.estado='A' 
								and horario.dia=3
								and horario.curso=".$r_cur[0]." 
								and horario.asignatura in ('Descanso','Proyecto')
								)
								union
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf, asignatura.nombre  as asig, horario.id, docente.nombre 
								from horario,asignatura,docente 
								where horario.estado='A' 
								 and horario.dia=3
								 and horario.asignatura=asignatura.subject_id
								 and horario.curso=".$r_cur[0]."
								and docente.teacher_id=horario.docente 
								 )
								 ) a
								 order by a.dia,a.hi,a.mi";
							// echo $select_horario."<br>";
							 $res_select_horario=mysql_query($select_horario);
						
							if(mysql_query($select_horario)){
							$num_hor=mysql_num_rows($res_select_horario);
							}
						
						if(isset($num_hor)&&$num_hor>0)	{
							
							while($r_selhor=mysql_fetch_array($res_select_horario)){
							if($r_selhor[4]==0){$r_selhor[4]='00';}if($r_selhor[6]==0){$r_selhor[6]='00';}
							if($r_selhor[4]==5){$r_selhor[4]='05';}if($r_selhor[6]==5){$r_selhor[6]='05';}							
							$tbody.="
								<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:9px;margin-bottom:5px'>
								    ".$r_selhor[7]." <br>( ".$r_selhor[3].":".$r_selhor[4]." - ".$r_selhor[5].":".$r_selhor[6]." ) "."<br>$r_selhor[9] &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$r_selhor[8]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$r_selhor[8].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								<br>
								";
					$tbody.="<div name='mimodala".$r_selhor[8]."' id='mimodala".$r_selhor[8]."' 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'>Editar Horario</h4>
      					      </div>
      					      <div class='modal-body'>";
					
							//if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
						         <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Curso&nbsp;
							  </div>
							 <div class='input' >
								<select id='l_cursob".$r_selhor[8]."' name='l_cursob".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$select_curso2="select curso_id,nombre,codigo
								from curso order by orden";
								$res_select_curso2=mysql_query($select_curso2);
								$tbody.= "<option value='XX' >Seleccione Curso</option>";
								while($r_sc2=mysql_fetch_array($res_select_curso2)){
								$sel1='  ';
								if($r_cur[0]==$r_sc2[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc2[0]."  ".$sel1.">".$r_sc2[2]." - ".$r_sc2[1]." </option>";
								}
								
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Asignatura&nbsp;
							  </div>
							 <div class='input' >
								<select id='asignaturab".$r_selhor[8]."' name='asignaturab".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								
								$select_doc2="select subject_id,codigo,nombre,sigla
									from asignatura 
									where estado='A'
									order by nombre";
								$res_select_doc2=mysql_query($select_doc2);
								$sela='';$selb='';
								if($r_selhor[7]=='Descanso'){$sela=' selected';}if($r_selhor[7]=='Proyecto'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='Descanso' $sela >DESCANSO</option>
								<option value='Proyecto' $selb >PROYECTO</option>								
								";
								while($r_sc3=mysql_fetch_array($res_select_doc2)){
								$sel1='  ';
								if($r_selhor[1]==$r_sc3[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc3[0]."  ".$sel1.">".$r_sc3[2]." </option>";
								}

							$tbody.="</select>
							</div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$r_selhor[8]."' name='diasb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($r_selhor[2]==$k){$sele[$k]= ' selected ';}else{$sele[$k]='';}
								}
								$tbody.="<option value='XX' >Seleccione Dia</option>
									<option value=1 ".$sele[1]." >Lunes</option>
									<option value=2 ".$sele[2]." >Martes</option>
									<option value=3 ".$sele[3]." >Mi&eacute;rcoles</option>
									<option value=4 ".$sele[4]." >Jueves</option>
									<option value=5 ".$sele[5]." >Viernes</option>
									<option value=6 ".$sele[6]." >S&aacute;bado</option>
									<option value=7 ".$sele[7]." >Domingo</option>				
								</select>
							 </div>
							 
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Inicial&nbsp;
							  </div>
							 <div class='input' >
								<select id='hib".$r_selhor[8]."' name='hib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[3]==$k){$sele2[$k]= ' selected ';}else{$sele2[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele2[6]." >06</option><option value=7 ".$sele2[7]." >07</option><option value=8 ".$sele2[8]." >08</option>
									<option value=9 ".$sele2[9]." >09</option><option value=10 ".$sele2[10]." >10</option><option value=11 ".$sele2[11]." >11</option>
									<option value=12 ".$sele2[12]." >12</option><option value=13 ".$sele2[13]." >13</option><option value=14 ".$sele2[14]." >14</option>
									<option value=15 ".$sele2[15]." >15</option><option value=16 ".$sele2[16]." >16</option><option value=17 ".$sele2[17]." >17</option>
									<option value=18 ".$sele2[18]." >18</option><option value=19 ".$sele2[19]." >19</option><option value=20 ".$sele2[20]." >20</option>				
									<option value=21 ".$sele2[21]." >21</option><option value=22 ".$sele2[22]." >22</option>					
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Inicial&nbsp;
								  </div>
								 <div class='input' >
								<select id='mib".$r_selhor[8]."' name='mib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[4]==$k){$sele3[$k]= ' selected ';}else{$sele3[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele3[0]." >00</option><option value=5 ".$sele3[5]." >5</option><option value=10 ".$sele3[10]." >10</option>
									<option value=15 ".$sele3[15]." >15</option><option value=20 ".$sele3[20]." >20</option><option value=25 ".$sele3[25]." >25</option>
									<option value=30 ".$sele3[30]." >30</option><option value=35 ".$sele3[35]." >35</option><option value=40 ".$sele3[40]." >40</option>
									<option value=45 ".$sele3[45]." >45</option><option value=50 ".$sele3[50]." >50</option><option value=55 ".$sele3[55]." >55</option>	
								</select>
					
							 </div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Final&nbsp;
							  </div>
							 <div class='input' >
								<select id='hfb".$r_selhor[8]."' name='hfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[5]==$k){$sele4[$k]= ' selected ';}else{$sele4[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele4[6]." >06</option><option value=7 ".$sele4[7]." >07</option><option value=8 ".$sele4[8]." >08</option>
									<option value=9 ".$sele4[9]." >09</option><option value=10 ".$sele4[10]." >10</option><option value=11 ".$sele4[11]." >11</option>
									<option value=12 ".$sele4[12]." >12</option><option value=13 ".$sele4[13]." >13</option><option value=14 ".$sele4[14]." >14</option>
									<option value=15 ".$sele4[15]." >15</option><option value=16 ".$sele4[16]." >16</option><option value=17 ".$sele4[17]." >17</option>
									<option value=18 ".$sele4[18]." >18</option><option value=19 ".$sele4[19]." >19</option><option value=20 ".$sele4[20]." >20</option>								<option value=21 ".$sele4[21]." >21</option><option value=22 ".$sele4[22]." >22</option>	
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Final&nbsp;
								  </div>
								 <div class='input' >
								<select id='mfb".$r_selhor[8]."' name='mfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[6]==$k){$sele5[$k]= ' selected ';}else{$sele5[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele5[0]." >00</option><option value=5 ".$sele5[5]." >5</option><option value=10 ".$sele5[10]." >10</option>
									<option value=15 ".$sele5[15]." >15</option><option value=20 ".$sele5[20]." >20</option><option value=25 ".$sele5[25]." >25</option>
									<option value=30 ".$sele5[30]." >30</option><option value=35 ".$sele5[35]." >35</option><option value=40 ".$sele5[40]." >40</option>
									<option value=45 ".$sele5[45]." >45</option><option value=50 ".$sele5[50]." >50</option><option value=55 ".$sele5[55]." >55</option>									
								</select>
							 	</div>
							 	
							 <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$r_selhor[8].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
						</div>	
					</div>
				</div>
			</div>	
							";
							}	
						}
						$tbody.="</td>								
							<td>";	      
//fin ciclo
//inicio ciclo
						 $select_horario="
							select * from 
							(
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf,horario.asignatura  as asig, horario.id, '' 
								from horario
								where horario.estado='A' 
								and horario.dia=4
								and horario.curso=".$r_cur[0]." 
								and horario.asignatura in ('Descanso','Proyecto')
								)
								union
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf, asignatura.nombre  as asig, horario.id, docente.nombre 
								from horario,asignatura,docente 
								where horario.estado='A' 
								 and horario.dia=4
								 and horario.asignatura=asignatura.subject_id
								 and horario.curso=".$r_cur[0]."
								and docente.teacher_id=horario.docente 
								 )
								 ) a
								 order by a.dia,a.hi,a.mi";
							// echo $select_horario."<br>";
							 $res_select_horario=mysql_query($select_horario);
						
							if(mysql_query($select_horario)){
							$num_hor=mysql_num_rows($res_select_horario);
							}
						
						if(isset($num_hor)&&$num_hor>0)	{
							
							while($r_selhor=mysql_fetch_array($res_select_horario)){
							if($r_selhor[4]==0){$r_selhor[4]='00';}if($r_selhor[6]==0){$r_selhor[6]='00';}
							if($r_selhor[4]==5){$r_selhor[4]='05';}if($r_selhor[6]==5){$r_selhor[6]='05';}							
							$tbody.="
								<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:9px;margin-bottom:5px'>
								    ".$r_selhor[7]." <br>( ".$r_selhor[3].":".$r_selhor[4]." - ".$r_selhor[5].":".$r_selhor[6]." ) "."<br>$r_selhor[9] &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$r_selhor[8]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$r_selhor[8].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								<br>
								";
					$tbody.="<div name='mimodala".$r_selhor[8]."' id='mimodala".$r_selhor[8]."' 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'>Editar Horario</h4>
      					      </div>
      					      <div class='modal-body'>";
					
							//if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
						         <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Curso&nbsp;
							  </div>
							 <div class='input' >
								<select id='l_cursob".$r_selhor[8]."' name='l_cursob".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$select_curso2="select curso_id,nombre,codigo
								from curso order by orden";
								$res_select_curso2=mysql_query($select_curso2);
								$tbody.= "<option value='XX' >Seleccione Curso</option>";
								while($r_sc2=mysql_fetch_array($res_select_curso2)){
								$sel1='  ';
								if($r_cur[0]==$r_sc2[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc2[0]."  ".$sel1.">".$r_sc2[2]." - ".$r_sc2[1]." </option>";
								}
								
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Asignatura&nbsp;
							  </div>
							 <div class='input' >
								<select id='asignaturab".$r_selhor[8]."' name='asignaturab".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								
								$select_doc2="select subject_id,codigo,nombre,sigla
									from asignatura 
									where estado='A'
									order by nombre";
								$res_select_doc2=mysql_query($select_doc2);
								$sela='';$selb='';
								if($r_selhor[7]=='Descanso'){$sela=' selected';}if($r_selhor[7]=='Proyecto'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='Descanso' $sela >DESCANSO</option>
								<option value='Proyecto' $selb >PROYECTO</option>								
								";
								while($r_sc3=mysql_fetch_array($res_select_doc2)){
								$sel1='  ';
								if($r_selhor[1]==$r_sc3[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc3[0]."  ".$sel1.">".$r_sc3[2]." </option>";
								}

							$tbody.="</select>
							</div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$r_selhor[8]."' name='diasb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($r_selhor[2]==$k){$sele[$k]= ' selected ';}else{$sele[$k]='';}
								}
								$tbody.="<option value='XX' >Seleccione Dia</option>
									<option value=1 ".$sele[1]." >Lunes</option>
									<option value=2 ".$sele[2]." >Martes</option>
									<option value=3 ".$sele[3]." >Mi&eacute;rcoles</option>
									<option value=4 ".$sele[4]." >Jueves</option>
									<option value=5 ".$sele[5]." >Viernes</option>
									<option value=6 ".$sele[6]." >S&aacute;bado</option>
									<option value=7 ".$sele[7]." >Domingo</option>				
								</select>
							 </div>
							 
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Inicial&nbsp;
							  </div>
							 <div class='input' >
								<select id='hib".$r_selhor[8]."' name='hib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[3]==$k){$sele2[$k]= ' selected ';}else{$sele2[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele2[6]." >06</option><option value=7 ".$sele2[7]." >07</option><option value=8 ".$sele2[8]." >08</option>
									<option value=9 ".$sele2[9]." >09</option><option value=10 ".$sele2[10]." >10</option><option value=11 ".$sele2[11]." >11</option>
									<option value=12 ".$sele2[12]." >12</option><option value=13 ".$sele2[13]." >13</option><option value=14 ".$sele2[14]." >14</option>
									<option value=15 ".$sele2[15]." >15</option><option value=16 ".$sele2[16]." >16</option><option value=17 ".$sele2[17]." >17</option>
									<option value=18 ".$sele2[18]." >18</option><option value=19 ".$sele2[19]." >19</option><option value=20 ".$sele2[20]." >20</option>				
									<option value=21 ".$sele2[21]." >21</option><option value=22 ".$sele2[22]." >22</option>					
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Inicial&nbsp;
								  </div>
								 <div class='input' >
								<select id='mib".$r_selhor[8]."' name='mib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[4]==$k){$sele3[$k]= ' selected ';}else{$sele3[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele3[0]." >00</option><option value=5 ".$sele3[5]." >5</option><option value=10 ".$sele3[10]." >10</option>
									<option value=15 ".$sele3[15]." >15</option><option value=20 ".$sele3[20]." >20</option><option value=25 ".$sele3[25]." >25</option>
									<option value=30 ".$sele3[30]." >30</option><option value=35 ".$sele3[35]." >35</option><option value=40 ".$sele3[40]." >40</option>
									<option value=45 ".$sele3[45]." >45</option><option value=50 ".$sele3[50]." >50</option><option value=55 ".$sele3[55]." >55</option>	
								</select>
					
							 </div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Final&nbsp;
							  </div>
							 <div class='input' >
								<select id='hfb".$r_selhor[8]."' name='hfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[5]==$k){$sele4[$k]= ' selected ';}else{$sele4[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele4[6]." >06</option><option value=7 ".$sele4[7]." >07</option><option value=8 ".$sele4[8]." >08</option>
									<option value=9 ".$sele4[9]." >09</option><option value=10 ".$sele4[10]." >10</option><option value=11 ".$sele4[11]." >11</option>
									<option value=12 ".$sele4[12]." >12</option><option value=13 ".$sele4[13]." >13</option><option value=14 ".$sele4[14]." >14</option>
									<option value=15 ".$sele4[15]." >15</option><option value=16 ".$sele4[16]." >16</option><option value=17 ".$sele4[17]." >17</option>
									<option value=18 ".$sele4[18]." >18</option><option value=19 ".$sele4[19]." >19</option><option value=20 ".$sele4[20]." >20</option>								<option value=21 ".$sele4[21]." >21</option><option value=22 ".$sele4[22]." >22</option>	
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Final&nbsp;
								  </div>
								 <div class='input' >
								<select id='mfb".$r_selhor[8]."' name='mfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[6]==$k){$sele5[$k]= ' selected ';}else{$sele5[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele5[0]." >00</option><option value=5 ".$sele5[5]." >5</option><option value=10 ".$sele5[10]." >10</option>
									<option value=15 ".$sele5[15]." >15</option><option value=20 ".$sele5[20]." >20</option><option value=25 ".$sele5[25]." >25</option>
									<option value=30 ".$sele5[30]." >30</option><option value=35 ".$sele5[35]." >35</option><option value=40 ".$sele5[40]." >40</option>
									<option value=45 ".$sele5[45]." >45</option><option value=50 ".$sele5[50]." >50</option><option value=55 ".$sele5[55]." >55</option>									
								</select>
							 	</div>
							 	
							 <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$r_selhor[8].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
						</div>	
					</div>
				</div>
			</div>	
							";
							}	
						}
						$tbody.="</td>								
							<td>";	      
//fin ciclo
//inicio ciclo
						 $select_horario="
							select * from 
							(
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf,horario.asignatura  as asig, horario.id, '' 
								from horario
								where horario.estado='A' 
								and horario.dia=5
								and horario.curso=".$r_cur[0]." 
								and horario.asignatura in ('Descanso','Proyecto')
								)
								union
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf, asignatura.nombre  as asig, horario.id, docente.nombre 
								from horario,asignatura,docente 
								where horario.estado='A' 
								 and horario.dia=5
								 and horario.asignatura=asignatura.subject_id
								 and horario.curso=".$r_cur[0]."
								and docente.teacher_id=horario.docente 
								 )
								 ) a
								 order by a.dia,a.hi,a.mi";
							// echo $select_horario."<br>";
							 $res_select_horario=mysql_query($select_horario);
						
							if(mysql_query($select_horario)){
							$num_hor=mysql_num_rows($res_select_horario);
							}
						
						if(isset($num_hor)&&$num_hor>0)	{
							
							while($r_selhor=mysql_fetch_array($res_select_horario)){
							if($r_selhor[4]==0){$r_selhor[4]='00';}if($r_selhor[6]==0){$r_selhor[6]='00';}
							if($r_selhor[4]==5){$r_selhor[4]='05';}if($r_selhor[6]==5){$r_selhor[6]='05';}							
							$tbody.="
								<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:9px;margin-bottom:5px'>
								    ".$r_selhor[7]." <br>( ".$r_selhor[3].":".$r_selhor[4]." - ".$r_selhor[5].":".$r_selhor[6]." ) "."<br>$r_selhor[9] &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$r_selhor[8]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$r_selhor[8].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								<br>
								";
					$tbody.="<div name='mimodala".$r_selhor[8]."' id='mimodala".$r_selhor[8]."' 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'>Editar Horario</h4>
      					      </div>
      					      <div class='modal-body'>";
					
							//if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
						         <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Curso&nbsp;
							  </div>
							 <div class='input' >
								<select id='l_cursob".$r_selhor[8]."' name='l_cursob".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$select_curso2="select curso_id,nombre,codigo
								from curso order by orden";
								$res_select_curso2=mysql_query($select_curso2);
								$tbody.= "<option value='XX' >Seleccione Curso</option>";
								while($r_sc2=mysql_fetch_array($res_select_curso2)){
								$sel1='  ';
								if($r_cur[0]==$r_sc2[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc2[0]."  ".$sel1.">".$r_sc2[2]." - ".$r_sc2[1]." </option>";
								}
								
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Asignatura&nbsp;
							  </div>
							 <div class='input' >
								<select id='asignaturab".$r_selhor[8]."' name='asignaturab".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								
								$select_doc2="select subject_id,codigo,nombre,sigla
									from asignatura 
									where estado='A'
									order by nombre";
								$res_select_doc2=mysql_query($select_doc2);
								$sela='';$selb='';
								if($r_selhor[7]=='Descanso'){$sela=' selected';}if($r_selhor[7]=='Proyecto'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='Descanso' $sela >DESCANSO</option>
								<option value='Proyecto' $selb >PROYECTO</option>								
								";
								while($r_sc3=mysql_fetch_array($res_select_doc2)){
								$sel1='  ';
								if($r_selhor[1]==$r_sc3[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc3[0]."  ".$sel1.">".$r_sc3[2]." </option>";
								}

							$tbody.="</select>
							</div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$r_selhor[8]."' name='diasb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($r_selhor[2]==$k){$sele[$k]= ' selected ';}else{$sele[$k]='';}
								}
								$tbody.="<option value='XX' >Seleccione Dia</option>
									<option value=1 ".$sele[1]." >Lunes</option>
									<option value=2 ".$sele[2]." >Martes</option>
									<option value=3 ".$sele[3]." >Mi&eacute;rcoles</option>
									<option value=4 ".$sele[4]." >Jueves</option>
									<option value=5 ".$sele[5]." >Viernes</option>
									<option value=6 ".$sele[6]." >S&aacute;bado</option>
									<option value=7 ".$sele[7]." >Domingo</option>				
								</select>
							 </div>
							 
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Inicial&nbsp;
							  </div>
							 <div class='input' >
								<select id='hib".$r_selhor[8]."' name='hib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[3]==$k){$sele2[$k]= ' selected ';}else{$sele2[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele2[6]." >06</option><option value=7 ".$sele2[7]." >07</option><option value=8 ".$sele2[8]." >08</option>
									<option value=9 ".$sele2[9]." >09</option><option value=10 ".$sele2[10]." >10</option><option value=11 ".$sele2[11]." >11</option>
									<option value=12 ".$sele2[12]." >12</option><option value=13 ".$sele2[13]." >13</option><option value=14 ".$sele2[14]." >14</option>
									<option value=15 ".$sele2[15]." >15</option><option value=16 ".$sele2[16]." >16</option><option value=17 ".$sele2[17]." >17</option>
									<option value=18 ".$sele2[18]." >18</option><option value=19 ".$sele2[19]." >19</option><option value=20 ".$sele2[20]." >20</option>				
									<option value=21 ".$sele2[21]." >21</option><option value=22 ".$sele2[22]." >22</option>					
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Inicial&nbsp;
								  </div>
								 <div class='input' >
								<select id='mib".$r_selhor[8]."' name='mib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[4]==$k){$sele3[$k]= ' selected ';}else{$sele3[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele3[0]." >00</option><option value=5 ".$sele3[5]." >5</option><option value=10 ".$sele3[10]." >10</option>
									<option value=15 ".$sele3[15]." >15</option><option value=20 ".$sele3[20]." >20</option><option value=25 ".$sele3[25]." >25</option>
									<option value=30 ".$sele3[30]." >30</option><option value=35 ".$sele3[35]." >35</option><option value=40 ".$sele3[40]." >40</option>
									<option value=45 ".$sele3[45]." >45</option><option value=50 ".$sele3[50]." >50</option><option value=55 ".$sele3[55]." >55</option>	
								</select>
					
							 </div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Final&nbsp;
							  </div>
							 <div class='input' >
								<select id='hfb".$r_selhor[8]."' name='hfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[5]==$k){$sele4[$k]= ' selected ';}else{$sele4[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele4[6]." >06</option><option value=7 ".$sele4[7]." >07</option><option value=8 ".$sele4[8]." >08</option>
									<option value=9 ".$sele4[9]." >09</option><option value=10 ".$sele4[10]." >10</option><option value=11 ".$sele4[11]." >11</option>
									<option value=12 ".$sele4[12]." >12</option><option value=13 ".$sele4[13]." >13</option><option value=14 ".$sele4[14]." >14</option>
									<option value=15 ".$sele4[15]." >15</option><option value=16 ".$sele4[16]." >16</option><option value=17 ".$sele4[17]." >17</option>
									<option value=18 ".$sele4[18]." >18</option><option value=19 ".$sele4[19]." >19</option><option value=20 ".$sele4[20]." >20</option>								<option value=21 ".$sele4[21]." >21</option><option value=22 ".$sele4[22]." >22</option>	
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Final&nbsp;
								  </div>
								 <div class='input' >
								<select id='mfb".$r_selhor[8]."' name='mfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[6]==$k){$sele5[$k]= ' selected ';}else{$sele5[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele5[0]." >00</option><option value=5 ".$sele5[5]." >5</option><option value=10 ".$sele5[10]." >10</option>
									<option value=15 ".$sele5[15]." >15</option><option value=20 ".$sele5[20]." >20</option><option value=25 ".$sele5[25]." >25</option>
									<option value=30 ".$sele5[30]." >30</option><option value=35 ".$sele5[35]." >35</option><option value=40 ".$sele5[40]." >40</option>
									<option value=45 ".$sele5[45]." >45</option><option value=50 ".$sele5[50]." >50</option><option value=55 ".$sele5[55]." >55</option>									
								</select>
							 	</div>
							 	
							 <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$r_selhor[8].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
						</div>	
					</div>
				</div>
			</div>	
							";
							}	
						}
						$tbody.="</td>								
							<td>";	      
//fin ciclo
//inicio ciclo
						 $select_horario="
							select * from 
							(
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf,horario.asignatura  as asig, horario.id, '' 
								from horario
								where horario.estado='A' 
								and horario.dia=6
								and horario.curso=".$r_cur[0]." 
								and horario.asignatura in ('Descanso','Proyecto')
								)
								union
								(select  horario.curso, horario.asignatura, horario.dia, horario.hi, horario.mi, horario.hf, 
								horario.mf, asignatura.nombre  as asig, horario.id, docente.nombre 
								from horario,asignatura,docente 
								where horario.estado='A' 
								 and horario.dia=6
								 and horario.asignatura=asignatura.subject_id
								 and horario.curso=".$r_cur[0]."
								and docente.teacher_id=horario.docente 
								 )
								 ) a
								 order by a.dia,a.hi,a.mi";
							// echo $select_horario."<br>";
							 $res_select_horario=mysql_query($select_horario);
						
							if(mysql_query($select_horario)){
							$num_hor=mysql_num_rows($res_select_horario);
							}
						
						if(isset($num_hor)&&$num_hor>0)	{
							
							while($r_selhor=mysql_fetch_array($res_select_horario)){
							if($r_selhor[4]==0){$r_selhor[4]='00';}if($r_selhor[6]==0){$r_selhor[6]='00';}
							if($r_selhor[4]==5){$r_selhor[4]='05';}if($r_selhor[6]==5){$r_selhor[6]='05';}							
							$tbody.="
								<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:9px;margin-bottom:5px'>
								    ".$r_selhor[7]." <br>( ".$r_selhor[3].":".$r_selhor[4]." - ".$r_selhor[5].":".$r_selhor[6]." ) "."<br>$r_selhor[9] &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$r_selhor[8]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$r_selhor[8].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								<br>
								";
					$tbody.="<div name='mimodala".$r_selhor[8]."' id='mimodala".$r_selhor[8]."' 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'>Editar Horario</h4>
      					      </div>
      					      <div class='modal-body'>";
					
							//if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
						         <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Curso&nbsp;
							  </div>
							 <div class='input' >
								<select id='l_cursob".$r_selhor[8]."' name='l_cursob".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$select_curso2="select curso_id,nombre,codigo
								from curso order by orden";
								$res_select_curso2=mysql_query($select_curso2);
								$tbody.= "<option value='XX' >Seleccione Curso</option>";
								while($r_sc2=mysql_fetch_array($res_select_curso2)){
								$sel1='  ';
								if($r_cur[0]==$r_sc2[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc2[0]."  ".$sel1.">".$r_sc2[2]." - ".$r_sc2[1]." </option>";
								}
								
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Asignatura&nbsp;
							  </div>
							 <div class='input' >
								<select id='asignaturab".$r_selhor[8]."' name='asignaturab".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								
								$select_doc2="select subject_id,codigo,nombre,sigla
									from asignatura 
									where estado='A'
									order by nombre";
								$res_select_doc2=mysql_query($select_doc2);
								$sela='';$selb='';
								if($r_selhor[7]=='Descanso'){$sela=' selected';}if($r_selhor[7]=='Proyecto'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='Descanso' $sela >DESCANSO</option>
								<option value='Proyecto' $selb >PROYECTO</option>								
								";
								while($r_sc3=mysql_fetch_array($res_select_doc2)){
								$sel1='  ';
								if($r_selhor[1]==$r_sc3[0]){$sel1=' selected ';}
								//echo "hola";
										$tbody.= "<option value=".$r_sc3[0]."  ".$sel1.">".$r_sc3[2]." </option>";
								}

							$tbody.="</select>
							</div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$r_selhor[8]."' name='diasb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($r_selhor[2]==$k){$sele[$k]= ' selected ';}else{$sele[$k]='';}
								}
								$tbody.="<option value='XX' >Seleccione Dia</option>
									<option value=1 ".$sele[1]." >Lunes</option>
									<option value=2 ".$sele[2]." >Martes</option>
									<option value=3 ".$sele[3]." >Mi&eacute;rcoles</option>
									<option value=4 ".$sele[4]." >Jueves</option>
									<option value=5 ".$sele[5]." >Viernes</option>
									<option value=6 ".$sele[6]." >S&aacute;bado</option>
									<option value=7 ".$sele[7]." >Domingo</option>				
								</select>
							 </div>
							 
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Inicial&nbsp;
							  </div>
							 <div class='input' >
								<select id='hib".$r_selhor[8]."' name='hib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[3]==$k){$sele2[$k]= ' selected ';}else{$sele2[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele2[6]." >06</option><option value=7 ".$sele2[7]." >07</option><option value=8 ".$sele2[8]." >08</option>
									<option value=9 ".$sele2[9]." >09</option><option value=10 ".$sele2[10]." >10</option><option value=11 ".$sele2[11]." >11</option>
									<option value=12 ".$sele2[12]." >12</option><option value=13 ".$sele2[13]." >13</option><option value=14 ".$sele2[14]." >14</option>
									<option value=15 ".$sele2[15]." >15</option><option value=16 ".$sele2[16]." >16</option><option value=17 ".$sele2[17]." >17</option>
									<option value=18 ".$sele2[18]." >18</option><option value=19 ".$sele2[19]." >19</option><option value=20 ".$sele2[20]." >20</option>				
									<option value=21 ".$sele2[21]." >21</option><option value=22 ".$sele2[22]." >22</option>					
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Inicial&nbsp;
								  </div>
								 <div class='input' >
								<select id='mib".$r_selhor[8]."' name='mib".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[4]==$k){$sele3[$k]= ' selected ';}else{$sele3[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele3[0]." >00</option><option value=5 ".$sele3[5]." >5</option><option value=10 ".$sele3[10]." >10</option>
									<option value=15 ".$sele3[15]." >15</option><option value=20 ".$sele3[20]." >20</option><option value=25 ".$sele3[25]." >25</option>
									<option value=30 ".$sele3[30]." >30</option><option value=35 ".$sele3[35]." >35</option><option value=40 ".$sele3[40]." >40</option>
									<option value=45 ".$sele3[45]." >45</option><option value=50 ".$sele3[50]." >50</option><option value=55 ".$sele3[55]." >55</option>	
								</select>
					
							 </div>
							 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
								Hora Final&nbsp;
							  </div>
							 <div class='input' >
								<select id='hfb".$r_selhor[8]."' name='hfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($r_selhor[5]==$k){$sele4[$k]= ' selected ';}else{$sele4[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Hora</option>
									<option value=6 ".$sele4[6]." >06</option><option value=7 ".$sele4[7]." >07</option><option value=8 ".$sele4[8]." >08</option>
									<option value=9 ".$sele4[9]." >09</option><option value=10 ".$sele4[10]." >10</option><option value=11 ".$sele4[11]." >11</option>
									<option value=12 ".$sele4[12]." >12</option><option value=13 ".$sele4[13]." >13</option><option value=14 ".$sele4[14]." >14</option>
									<option value=15 ".$sele4[15]." >15</option><option value=16 ".$sele4[16]." >16</option><option value=17 ".$sele4[17]." >17</option>
									<option value=18 ".$sele4[18]." >18</option><option value=19 ".$sele4[19]." >19</option><option value=20 ".$sele4[20]." >20</option>								<option value=21 ".$sele4[21]." >21</option><option value=22 ".$sele4[22]." >22</option>	
									
								</select>
								  </div>
								 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Min. Final&nbsp;
								  </div>
								 <div class='input' >
								<select id='mfb".$r_selhor[8]."' name='mfb".$r_selhor[8]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($r_selhor[6]==$k){$sele5[$k]= ' selected ';}else{$sele5[$k]='';}
								}
								$tbody.="
									<option value='XX' >Seleccione Minutos</option>
									<option value=0 ".$sele5[0]." >00</option><option value=5 ".$sele5[5]." >5</option><option value=10 ".$sele5[10]." >10</option>
									<option value=15 ".$sele5[15]." >15</option><option value=20 ".$sele5[20]." >20</option><option value=25 ".$sele5[25]." >25</option>
									<option value=30 ".$sele5[30]." >30</option><option value=35 ".$sele5[35]." >35</option><option value=40 ".$sele5[40]." >40</option>
									<option value=45 ".$sele5[45]." >45</option><option value=50 ".$sele5[50]." >50</option><option value=55 ".$sele5[55]." >55</option>									
								</select>
							 	</div>
							 	
							 <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$r_selhor[8].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
						</div>	
					</div>
				</div>
			</div>	
							";
							}	
						}
						
//fin ciclo






						$tbody.="						
								</td>								
							</tr>
							";	      
						    //  }
					      $tbody.="
					      	 </tbody>	
					      	</table>
					      	</div>
					      </div>
					    </div>
					  </div>";
				}
					$tbody.="</div>";

$js_asignaturas = "var asignaturas = {\n";
$primero_curso = true;
$cursos_q2 = mysql_query("SELECT curso_id, nombre, codigo FROM curso ORDER BY orden");
while($row_curso = mysql_fetch_array($cursos_q2)){
    if(!$primero_curso) $js_asignaturas .= ",\n";
    $js_asignaturas .= "'".$row_curso[0]."': [";
    $primero_asig = true;
    $asig_q = mysql_query("SELECT pensum.asignatura_id, asignatura.nombre FROM pensum, asignatura WHERE pensum.class_id='".$row_curso[0]."' AND pensum.asignatura_id=asignatura.subject_id AND pensum.estado='A' ORDER BY asignatura.nombre");
    while($row_asig = mysql_fetch_array($asig_q)){
        if(!$primero_asig) $js_asignaturas .= ",";
        $js_asignaturas .= "'".$row_asig[0]."|".addslashes($row_asig[1])."'";
        $primero_asig = false;
    }
    $js_asignaturas .= "]";
    $primero_curso = false;
}
$js_asignaturas .= "\n};\n";

$js_horarios = "var horarios_ocupados = {\n";
$primero_dia = true;
$horarios_q = mysql_query("SELECT curso, dia, hi, mi, hf, mf FROM horario WHERE estado='A'");
while($row_hor = mysql_fetch_array($horarios_q)){
    if(!$primero_dia) $js_horarios .= ",\n";
    $js_horarios .= "'".$row_hor[0]."_".$row_hor[1]."_".$row_hor[2]."_".$row_hor[3]."_".$row_hor[4]."_".$row_hor[5]."': 1";
    $primero_dia = false;
}
$js_horarios .= "\n};\n";

?>
<!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">
	<style>
	</style>
    <title>Horarios</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>
    <?php echo $js_asignaturas; ?>
    <?php echo $js_horarios; ?>
    </script>
    <script>
    function borra_horario(ide){
if (confirm('Esta seguro que desea borrar este registro?')) {	
document.getElementById('horariob').value=ide;	

	document.getElementById('val1').value=2;
	document.forms['listar_horario'].submit();
}
else{return false;}

}
function actualiza_horario(id){

if(document.getElementById('l_cursob'+id).value=='XX'){alert('Debe seleccionar el Curso');return false;}
	else{document.getElementById('l_cursob').value=document.getElementById('l_cursob'+id).value}
if(document.getElementById('asignaturab'+id).value=='XX'){alert('Debe seleccionar Asignatura');return false;}
	else{document.getElementById('asignaturab').value=document.getElementById('asignaturab'+id).value}
if(document.getElementById('diasb'+id).value=='XX'){alert('Debe seleccionar el Dia');return false;}
	else{document.getElementById('diasb').value=document.getElementById('diasb'+id).value}

if(document.getElementById('hib'+id).value=='XX'){alert('Debe seleccionar Hora Inicial');return false;}
	else{document.getElementById('hib').value=document.getElementById('hib'+id).value}
if(document.getElementById('mib'+id).value=='XX'){alert('Debe seleccionar Minuto Inicia');return false;}
	else{document.getElementById('mib').value=document.getElementById('mib'+id).value}
if(document.getElementById('hfb'+id).value=='XX'){alert('Debe seleccionar Hora Final');return false;}
	else{document.getElementById('hfb').value=document.getElementById('hfb'+id).value}
if(document.getElementById('mfb'+id).value=='XX'){alert('Debe seleccionar Minuto Final');return false;}
	else{document.getElementById('mfb').value=document.getElementById('mfb'+id).value}
document.getElementById('horariob').value=id;	

	document.getElementById('val1').value=1;
	document.forms['listar_horario'].submit();
	
}
     
function cargarAsignaturas(cursoId){
    var selectAsig = document.getElementById('asignatura');
    selectAsig.innerHTML = '<option value="XX">Cargando...</option>';
    
    if(cursoId=='XX'){
        selectAsig.innerHTML = '<option value="XX">Seleccione un curso primero</option>';
        return;
    }
    
    selectAsig.innerHTML = '<option value="XX">Seleccione Asignatura</option>';
    selectAsig.innerHTML += '<option value="DE">DESCANSO</option>';
    selectAsig.innerHTML += '<option value="PR">PROYECTO</option>';
    
    if(asignaturas[cursoId] && asignaturas[cursoId].length > 0){
        for(var i=0; i<asignaturas[cursoId].length; i++){
            var parts = asignaturas[cursoId][i].split('|');
            selectAsig.innerHTML += '<option value="'+parts[0]+'">'+parts[1]+'</option>';
        }
    } else {
        selectAsig.innerHTML += '<option value="XX" disabled>No hay asignaturas para este curso</option>';
    }
}

function crea_registro(){

	
if(document.getElementById('l_curso2').value=='XX'){alert('Debe seleccionar el Curso');return false;}
	else{document.getElementById('l_curso22').value=document.getElementById('l_curso2').value}
if(document.getElementById('asignatura').value=='XX'){alert('Debe seleccionar Asignatura');return false;}
	else{document.getElementById('asignatura2').value=document.getElementById('asignatura').value}
if(document.getElementById('dias').value=='XX'){alert('Debe seleccionar Dia');return false;}
	else{document.getElementById('dias2').value=document.getElementById('dias').value}
if(document.getElementById('hi').value=='XX'){alert('Debe Hora Inicial');return false;}
	else{document.getElementById('hi2').value=document.getElementById('hi').value}
if(document.getElementById('mi').value=='XX'){alert('Debe Minuto Inicial');return false;}
	else{document.getElementById('mi2').value=document.getElementById('mi').value}
if(document.getElementById('hf').value=='XX'){alert('Debe Hora Final');return false;}
	else{document.getElementById('hf2').value=document.getElementById('hf').value}
if(document.getElementById('mf').value=='XX'){alert('Debe Minuto Final');return false;}
	else{document.getElementById('mf2').value=document.getElementById('mf').value}

var curso = document.getElementById('l_curso2').value;
var dia = document.getElementById('dias').value;
var hi = parseInt(document.getElementById('hi').value);
var mi = parseInt(document.getElementById('mi').value);
var hf = parseInt(document.getElementById('hf').value);
var mf = parseInt(document.getElementById('mf').value);

var horaInicio = hi * 60 + mi;
var horaFin = hf * 60 + mf;

var hayConflicto = false;
for(var key in horarios_ocupados){
    var parts = key.split('_');
    if(parts[0] == curso && parts[1] == dia){
        var hOcup = parseInt(parts[2]) * 60 + parseInt(parts[3]);
        var fOcup = parseInt(parts[4]) * 60 + parseInt(parts[5]);
        
        if(!(horaFin <= hOcup || horaInicio >= fOcup)){
            hayConflicto = true;
            break;
        }
    }
}

if(hayConflicto){
    alert('Ya existe un horario en ese curso, dia y hora. Por favor elija otro horario.');
    return false;
}

	document.getElementById('val2').value=1;
	document.forms['crear_horario'].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> <?php echo $_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"><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 active"><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>
	<?php echo $men; ?>	
	      
	      <!-- Nav tabs -->
	<ul class="nav nav-tabs">
		<li >&nbsp;</li>
	  <li <?php echo $class1; ?>><a href="#home" data-toggle="tab">Gestion de Horarios</a></li>
	  <li <?php echo $class2; ?>><a href="#profile" data-toggle="tab">Crear Horario</a></li>
	</ul>
	
	<!-- Tab panes -->

	<div class="tab-content">
	<div class="tab-pane fade in <?php echo $act2; ?>" id="profile">
		<form name='crear_horario' id='crear_horario' method='post' action='horario.php#profile' target='' >
		<input type='hidden' name='val2' id='val2' value='<?php echo $val2; ?>'>	

		<input type='hidden' name='l_curso22' id='l_curso22' value='<?php echo $l_curso22; ?>'>
		<input type='hidden' name='asignatura2' id='asignatura2' value='<?php echo $asignatura2; ?>'>				
		<input type='hidden' name='dias2' id='dias2' value='<?php echo $dias2; ?>'>
		<input type='hidden' name='hi2' id='hi2' value='<?php echo $hi2; ?>'>		
		<input type='hidden' name='mi2' id='mi2' value='<?php echo $mi2; ?>'>				
		<input type='hidden' name='hf2' id='hf2' value='<?php echo $hf2; ?>'>		
		<input type='hidden' name='mf2' id='mf2' value='<?php echo $mf2; ?>'>				
		
		<div class="page">
			<fieldset>
				<legend>
					<br><span class="glyphicon glyphicon-calendar"></span> Crear Nuevo Horario          
				</legend>			
			</fieldset>
		
		

		<div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
			Curso&nbsp;
		  </div>
		 <div class='input' >
					<select id='l_curso2' name='l_curso2' class='form-control' style='width:24%;margin-bottom: 10px' onchange='cargarAsignaturas(this.value)'>
					<?php
					$select_curso='select curso_id,nombre,codigo
					from curso order by orden';
					$res_select_curso=mysql_query($select_curso);
					echo "<option value='XX' >Seleccione Curso</option>";
					while($r_sc=mysql_fetch_array($res_select_curso)){
					$sel1='  ';
							echo '<option value="'.$r_sc[0].'"  '.$sel1.'>'.$r_sc[2].' - '.$r_sc[1].' </option>';
					}
					?>
					</select>
		 </div>

	
		<div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
			Asignatura&nbsp;
		  </div>
		 <div class='input' >
					<select id='asignatura' name='asignatura' class='form-control' style='width:24%;margin-bottom: 10px'>
					<?php
					$select_doc="select subject_id,codigo,nombre,sigla
					from asignatura 
					where estado='A'
					order by nombre";
					$res_select_doc=mysql_query($select_doc);
					echo "<option value='XX' >Seleccione Asignatura</option>
					<option value='DE' >DESCANSO</option>
					<option value='PR' >PROYECTO</option>					
					";
					while($r_sd=mysql_fetch_array($res_select_doc)){
					$sel1='  ';
							echo '<option value="'.$r_sd[0].'"  '.$sel1.'>'.$r_sd[2].' </option>';
					}
					?>
					</select>
		 </div>
		 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
			D&iacute;a&nbsp;
		  </div>
		 <div class='input' >
			<select id='dias' name='dias' class='form-control' style='width:24%;margin-bottom: 10px'>
				<option value='XX' >Seleccione Dia</option>
				<option value=1>Lunes</option>
				<option value=2>Martes</option>
				<option value=3>Mi&eacute;rcoles</option>
				<option value=4>Jueves</option>
				<option value=5>Viernes</option>
				<option value=6>S&aacute;bado</option>
				<option value=7>Domingo</option>				
			</select>
		 </div>
		 
		 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
			Hora Inicial&nbsp;
		  </div>
		 <div class='input' >
			<select id='hi' name='hi' class='form-control' style='width:24%;margin-bottom: 10px'>
				<option value='XX' >Seleccione Hora</option>
				<option value=6>06</option>	
				<option value=7>07</option>
				<option value=8>08</option>
				<option value=9>09</option>
				<option value=10>10</option>
				<option value=11>11</option>
				<option value=12>12</option>				
				<option value=13>13</option>
				<option value=14>14</option>
				<option value=15>15</option>
				<option value=16>16</option>
				<option value=17>17</option>
				<option value=18>18</option>
				<option value=19>19</option>
				<option value=20>20</option>				
				<option value=21>21</option>
				<option value=22>22</option>					
				
			</select>
			  </div>
			 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
				Min. Inicial&nbsp;
			  </div>
			 <div class='input' >
			<select id='mi' name='mi' class='form-control' style='width:24%;margin-bottom: 10px'>
				<option value='XX' >Seleccione Minutos</option>
				<option value=0>00</option>
				<option value=5>05</option>
				<option value=10>10</option>
				<option value=15>15</option>
				<option value=20>20</option>
				<option value=25>25</option>
				<option value=30>30</option>
				<option value=35>35</option>
				<option value=40>40</option>
				<option value=45>45</option>
				<option value=50>50</option>
				<option value=55>55</option>
		
			</select>

		 </div>
		 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
			Hora Final&nbsp;
		  </div>
		 <div class='input' >
			<select id='hf' name='hf' class='form-control' style='width:24%;margin-bottom: 10px'>
				<option value='XX' >Seleccione Hora</option>
				<option value=6>06</option>
				<option value=7>07</option>
				<option value=8>08</option>
				<option value=9>09</option>
				<option value=10>10</option>
				<option value=11>11</option>
				<option value=12>12</option>				
				<option value=13>13</option>
				<option value=14>14</option>
				<option value=15>15</option>
				<option value=16>16</option>
				<option value=17>17</option>
				<option value=18>18</option>
				<option value=19>19</option>
				<option value=20>20</option>				
				<option value=21>21</option>
				<option value=22>22</option>				
				
			</select>
			  </div>
			 <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
				Min. Final&nbsp;
			  </div>
			 <div class='input' >
			<select id='mf' name='mf' class='form-control' style='width:24%;margin-bottom: 10px'>
				<option value='XX' >Seleccione Minutos</option>
				<option value=0>00</option>
				<option value=5>05</option>
				<option value=10>10</option>
				<option value=15>15</option>
				<option value=20>20</option>
				<option value=25>25</option>
				<option value=30>30</option>
				<option value=35>35</option>
				<option value=40>40</option>
				<option value=45>45</option>
				<option value=50>50</option>
				<option value=55>55</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>

<div class="tab-pane fade in <?php echo $act1; ?>" id="home">
	<form name='listar_horario' id='listar_horario' method='post' action='horario.php' target=''>
	<div class="page">
	

	<input type='hidden' name='val1' id='val1' value='<?php echo $val1; ?>'>	
	<input type='hidden' name='cur1' id='cur1' value='<?php echo $cur1; ?>'>	
	<input type='hidden' name='l_cursob' id='l_cursob' value='<?php echo $l_cursob; ?>'>		
	<input type='hidden' name='asignaturab' id='asignaturab' value='<?php echo $asignaturab; ?>'>		
	<input type='hidden' name='diasb' id='diasb' value='<?php echo $diasb; ?>'>		
	<input type='hidden' name='hib' id='hib' value='<?php echo $hib; ?>'>		
	<input type='hidden' name='mib' id='mib' value='<?php echo $mib; ?>'>		
	<input type='hidden' name='hfb' id='hfb' value='<?php echo $hfb; ?>'>		
	<input type='hidden' name='mfb' id='mfb' value='<?php echo $mfb; ?>'>	
	<input type='hidden' name='horariob' id='horariob' value='<?php echo $horariob; ?>'>								
	
		<fieldset>
			<legend><br><span class="glyphicon glyphicon-calendar"></span> 
				Horarios          
			</legend>			
		</fieldset>
	</div>
	<fieldset>
	<div class='table-responsive'>
	<?php echo $tbody; ?>
	</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="offcanvas.js"></script>
  </body>
</html>
<?php
}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='index.php' > Registrar</a></div>";
}
   ?>