<?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="";$docente2="";$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_at 
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){
$act_horario="update horario_at set
docente='".$_POST['docenteb']."',
dia=".$_POST['diasb'].",
hi=".$_POST['hib'].",
mi=".$_POST['mib'].",
hf=".$_POST['hfb'].",
mf=".$_POST['mfb'].",
fecha_modif=now()
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 ";

					

	$insertar_horario='insert into horario_at (dia,hi,mi,hf,mf,fecha_insert,estado,docente)
	values('.$_POST['dias2'].','.$_POST['hi2'].','.$_POST['mi2'].','.$_POST['hf2'].','.$_POST['mf2'].',now(),
	"A",'.$_POST['docente2'].'
	)';
	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>";







 }
}




$select_docente="select distinct horario_at.docente,docente.nombre
				 from horario_at,docente  
				 where horario_at.estado='A' 
				  and docente.teacher_id=horario_at.docente
				 order by horario_at.dia";
					$res_select_docente=mysql_query($select_docente);


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

$arreglo=array(
1=>'Lunes',
2=>'Martes',
3=>'Miercoles',
4=>'Jueves',
5=>'Viernes',
6=>'Sabado',
7=>'Domingo'
);
					
					
					$tbody.="<table class='table table-striped table-bordered '>
					<tr>
					<th>Docente</th>
					<th>Direcci&oacute;n Grupo</th>
					<th>Asignaturas</th>
					<th>Lunes</th>
					<th>Martes</th>
					<th>Miercoles</th>
					<th>Jueves</th>
					<th>Viernes</th>
					</tr>";
					while($doc=mysql_fetch_array($res_select_docente)){
					
					$tbody.="
					<tr>
						<td style='font-size:9px'>$doc[1]</td>
						<td style='font-size:9px'>
						";
					$select_curso="select curso_id,codigo,nombre,id_docente,estado
					from curso where id_docente='".$doc[0]."' and estado='A' ";
					$res_select_curso=mysql_query($select_curso);
					$num_curso=mysql_num_rows($res_select_curso);
					
					if($num_curso>0){
						while($cur=mysql_fetch_array($res_select_curso)){
						$tbody.=" - ".$cur[2];
						}
					}

					$tbody.="
						</td>
						<td style='font-size:9px'>";
						
					$select_asig="select asignatura.nombre,(select curso.codigo from curso where pensum.class_id=curso.curso_id),asignatura.subject_id
					from pensum,asignatura,docente 
					where docente.teacher_id='".$doc[0]."' 
					and pensum.teacher_id=docente.teacher_id
					and pensum.asignatura_id=asignatura.subject_id
					and pensum.estado='A' 
					
					";
					$res_select_asig=mysql_query($select_asig);
					$num_asig=mysql_num_rows($res_select_asig);
					
					if($num_asig>0){
						while($asi=mysql_fetch_array($res_select_asig)){
						$tbody.=" - ".$asi[0]." ".$asi[1]."<br>";
						}
					}
						
					$tbody.="
						</td>
						<td style='font-size:9px'>";	
						$sel_hora="select Id,dia,hi,mi,hf,mf 
						from horario_at
						where docente=".$doc[0]." 
						and dia=1";	
					$res_sel_hora=mysql_query($sel_hora);
					$num_hor=mysql_num_rows($res_sel_hora);
					if($num_hor>0){
						while($hor=mysql_fetch_array($res_sel_hora)){
						if($hor[3]==0){$hor[3]='00';}if($hor[3]==5){$hor[3]='05';}
						if($hor[5]==0){$hor[5]='00';}if($hor[5]==5){$hor[5]='05';}
						//$tbody.="(".$hor[2].":".$hor[3]." - ".$hor[4].":".$hor[5].")";
						
						$tbody.="<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:10px;margin-bottom:5px'>
								    (".$hor[2].":".$hor[3]." - ".$hor[4].":".$hor[5].") &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$hor[0]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$hor[0].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div><br>";
						$tbody.="<div name='mimodala".$hor[0]."' id='mimodala".$hor[0]."' 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'>";
	      					$tbody.="     <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Docente / Coord.&nbsp;
								  </div>
								 <div class='input' >
											<select id='docenteb".$hor[0]."' name='docenteb".$hor[0]."' class='form-control2' style='width:48%;margin-bottom: 10px'>";
											$select_doc2='select teacher_id,nombre,coordinador
											from docente order by coordinador,nombre';
											$res_select_doc2=mysql_query($select_doc2);
											$tbody.="<option value='XX' >Seleccione Doc. - Coord.</option>";
											while($r_sc2=mysql_fetch_array($res_select_doc2)){
											$sel1='  ';
											if($r_sc2[0]==$doc[0]){$sel1=' selected ';}
											if($r_sc2[2]==1){$r_sc2[2]='Coord.';}else{$r_sc2[2]='Docente';}
													$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;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$hor[0]."' name='diasb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($hor[1]==$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".$hor[0]."' name='hib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[2]==$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".$hor[0]."' name='mib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[3]==$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]." >05</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".$hor[0]."' name='hfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[4]==$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".$hor[0]."' name='mfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[5]==$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]." >05</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>";
						$tbody.="              <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$hor[0].")' >Actualizar</button>
									    <button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
									</div>
							      </div>	
							    </div>
							  </div>
							</div>";	
						
						}
					}
					$tbody.="
						</td>
						<td style='font-size:9px'>";	
						$sel_hora="select Id,dia,hi,mi,hf,mf 
						from horario_at
						where docente=".$doc[0]." 
						and dia=2";	
					$res_sel_hora=mysql_query($sel_hora);
					$num_hor=mysql_num_rows($res_sel_hora);
					if($num_hor>0){
						while($hor=mysql_fetch_array($res_sel_hora)){
						if($hor[3]==0){$hor[3]='00';}if($hor[3]==5){$hor[3]='05';}
						if($hor[5]==0){$hor[5]='00';}if($hor[5]==5){$hor[5]='05';}
						$tbody.="<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:10px;margin-bottom:5px'>
								    (".$hor[2].":".$hor[3]." - ".$hor[4].":".$hor[5].") &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$hor[0]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$hor[0].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div><br>";
						$tbody.="<div name='mimodala".$hor[0]."' id='mimodala".$hor[0]."' 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'>";
	      					$tbody.="     <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Docente / Coord.&nbsp;
								  </div>
								 <div class='input' >
											<select id='docenteb".$hor[0]."' name='docenteb".$hor[0]."' class='form-control2' style='width:48%;margin-bottom: 10px'>";
											$select_doc2='select teacher_id,nombre,coordinador
											from docente order by coordinador,nombre';
											$res_select_doc2=mysql_query($select_doc2);
											$tbody.="<option value='XX' >Seleccione Doc. - Coord.</option>";
											while($r_sc2=mysql_fetch_array($res_select_doc2)){
											$sel1='  ';
											if($r_sc2[0]==$doc[0]){$sel1=' selected ';}
											if($r_sc2[2]==1){$r_sc2[2]='Coord.';}else{$r_sc2[2]='Docente';}
													$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;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$hor[0]."' name='diasb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($hor[1]==$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".$hor[0]."' name='hib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[2]==$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".$hor[0]."' name='mib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[3]==$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]." >05</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".$hor[0]."' name='hfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[4]==$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".$hor[0]."' name='mfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[5]==$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]." >05</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>";
						$tbody.="              <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$hor[0].")' >Actualizar</button>
									    <button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
									</div>
							      </div>	
							    </div>
							  </div>
							</div>";
						}
					}
					$tbody.="
						</td>
						<td style='font-size:9px'>";	
						$sel_hora="select Id,dia,hi,mi,hf,mf 
						from horario_at
						where docente=".$doc[0]." 
						and dia=3";	
					$res_sel_hora=mysql_query($sel_hora);
					$num_hor=mysql_num_rows($res_sel_hora);
					if($num_hor>0){
						while($hor=mysql_fetch_array($res_sel_hora)){
						if($hor[3]==0){$hor[3]='00';}if($hor[3]==5){$hor[3]='05';}
						if($hor[5]==0){$hor[5]='00';}if($hor[5]==5){$hor[5]='05';}
						$tbody.="<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:10px;margin-bottom:5px'>
								    (".$hor[2].":".$hor[3]." - ".$hor[4].":".$hor[5].") &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$hor[0]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$hor[0].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div><br>";
						$tbody.="<div name='mimodala".$hor[0]."' id='mimodala".$hor[0]."' 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'>";
	      					$tbody.="     <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Docente / Coord.&nbsp;
								  </div>
								 <div class='input' >
											<select id='docenteb".$hor[0]."' name='docenteb".$hor[0]."' class='form-control2' style='width:48%;margin-bottom: 10px'>";
											$select_doc2='select teacher_id,nombre,coordinador
											from docente order by coordinador,nombre';
											$res_select_doc2=mysql_query($select_doc2);
											$tbody.="<option value='XX' >Seleccione Doc. - Coord.</option>";
											while($r_sc2=mysql_fetch_array($res_select_doc2)){
											$sel1='  ';
											if($r_sc2[0]==$doc[0]){$sel1=' selected ';}
											if($r_sc2[2]==1){$r_sc2[2]='Coord.';}else{$r_sc2[2]='Docente';}
													$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;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$hor[0]."' name='diasb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($hor[1]==$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".$hor[0]."' name='hib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[2]==$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".$hor[0]."' name='mib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[3]==$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]." >05</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".$hor[0]."' name='hfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[4]==$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".$hor[0]."' name='mfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[5]==$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]." >05</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>";
						$tbody.="              <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$hor[0].")' >Actualizar</button>
									    <button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
									</div>
							      </div>	
							    </div>
							  </div>
							</div>";
						}
					}
					$tbody.="
						</td>
						<td style='font-size:9px'>";	
						$sel_hora="select Id,dia,hi,mi,hf,mf 
						from horario_at
						where docente=".$doc[0]." 
						and dia=4";	
					$res_sel_hora=mysql_query($sel_hora);
					$num_hor=mysql_num_rows($res_sel_hora);
					if($num_hor>0){
						while($hor=mysql_fetch_array($res_sel_hora)){
						if($hor[3]==0){$hor[3]='00';}if($hor[3]==5){$hor[3]='05';}
						if($hor[5]==0){$hor[5]='00';}if($hor[5]==5){$hor[5]='05';}
						$tbody.="<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:10px;margin-bottom:5px'>
								    (".$hor[2].":".$hor[3]." - ".$hor[4].":".$hor[5].") &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$hor[0]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$hor[0].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div><br>";
						$tbody.="<div name='mimodala".$hor[0]."' id='mimodala".$hor[0]."' 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'>";
	      					$tbody.="     <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Docente / Coord.&nbsp;
								  </div>
								 <div class='input' >
											<select id='docenteb".$hor[0]."' name='docenteb".$hor[0]."' class='form-control2' style='width:48%;margin-bottom: 10px'>";
											$select_doc2='select teacher_id,nombre,coordinador
											from docente order by coordinador,nombre';
											$res_select_doc2=mysql_query($select_doc2);
											$tbody.="<option value='XX' >Seleccione Doc. - Coord.</option>";
											while($r_sc2=mysql_fetch_array($res_select_doc2)){
											$sel1='  ';
											if($r_sc2[0]==$doc[0]){$sel1=' selected ';}
											if($r_sc2[2]==1){$r_sc2[2]='Coord.';}else{$r_sc2[2]='Docente';}
													$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;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$hor[0]."' name='diasb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($hor[1]==$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".$hor[0]."' name='hib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[2]==$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".$hor[0]."' name='mib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[3]==$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]." >05</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".$hor[0]."' name='hfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[4]==$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".$hor[0]."' name='mfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[5]==$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]." >05</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>";
						$tbody.="              <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$hor[0].")' >Actualizar</button>
									    <button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
									</div>
							      </div>	
							    </div>
							  </div>
							</div>";
						}
					}
					$tbody.="
						</td>
						<td style='font-size:9px'>";	
						$sel_hora="select Id,dia,hi,mi,hf,mf 
						from horario_at
						where docente=".$doc[0]." 
						and dia=5";	
					$res_sel_hora=mysql_query($sel_hora);
					$num_hor=mysql_num_rows($res_sel_hora);
					if($num_hor>0){
						while($hor=mysql_fetch_array($res_sel_hora)){
						if($hor[3]==0){$hor[3]='00';}if($hor[3]==5){$hor[3]='05';}
						if($hor[5]==0){$hor[5]='00';}if($hor[5]==5){$hor[5]='05';}
						$tbody.="<div class='btn-group dropup'>
								  <button type='button' class='btn btn-info btn-xs dropdown-toggle' data-toggle='dropdown' style='font-size:10px;margin-bottom:5px'>
								    (".$hor[2].":".$hor[3]." - ".$hor[4].":".$hor[5].") &nbsp;<span class='caret'></span>
								  </button>
								  <ul class='dropdown-menu' role='menu'>
								    <li><a data-toggle='modal' href='#mimodala".$hor[0]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$hor[0].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div><br>";
						$tbody.="<div name='mimodala".$hor[0]."' id='mimodala".$hor[0]."' 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'>";
	      					$tbody.="     <div class='input' style='float:left;width: 100px;padding-top: 5px;text-align: left;padding-left: 10px;' >
									Docente / Coord.&nbsp;
								  </div>
								 <div class='input' >
											<select id='docenteb".$hor[0]."' name='docenteb".$hor[0]."' class='form-control2' style='width:48%;margin-bottom: 10px'>";
											$select_doc2='select teacher_id,nombre,coordinador
											from docente order by coordinador,nombre';
											$res_select_doc2=mysql_query($select_doc2);
											$tbody.="<option value='XX' >Seleccione Doc. - Coord.</option>";
											while($r_sc2=mysql_fetch_array($res_select_doc2)){
											$sel1='  ';
											if($r_sc2[0]==$doc[0]){$sel1=' selected ';}
											if($r_sc2[2]==1){$r_sc2[2]='Coord.';}else{$r_sc2[2]='Docente';}
													$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;' >
								D&iacute;a&nbsp;
							  </div>
							 <div class='input' >
								<select id='diasb".$hor[0]."' name='diasb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=1;$k<8;$k++){
									if($hor[1]==$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".$hor[0]."' name='hib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[2]==$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".$hor[0]."' name='mib".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[3]==$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]." >05</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".$hor[0]."' name='hfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=6;$k<23;$k++){
									if($hor[4]==$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".$hor[0]."' name='mfb".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								for($k=0;$k<56;$k++){
									if($hor[5]==$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]." >05</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>";
						$tbody.="              <div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_horario(".$hor[0].")' >Actualizar</button>
									    <button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
									</div>
							      </div>	
							    </div>
							  </div>
							</div>";
						}
					}

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


					$tbody.="</table>
					";
					
//					$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'>
					      	<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 width='100'>$arreglo[$i]</td>
								<td>";
						
						 $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=".$i." 
								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=".$i."
								 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]." ( ".$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".$hor[0]."' ><span class='glyphicon glyphicon-cog'></span></i> editar</a></li>
								    <li class='divider'></li>
								    <li><a href='#' onclick='borra_horario(".$hor[0].")'><span class='glyphicon glyphicon-trash'></span> borrar</a></li>
								  </ul>
								</div>
								
								";
								
					$tbody.="<div name='mimodala".$hor[0]."' id='mimodala".$hor[0]."' 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".$hor[0]."' name='l_cursob".$hor[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
				
						
							
								$select_curso2="select curso_id,nombre,codigo
								from curso order by codigo";
								$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".$hor[0]."' name='asignaturab".$hor[0]."' 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]=='DE'){$sela=' selected';}if($r_selhor[7]=='PR'){$selb=' selected';}
								
								$tbody.= "<option value='XX' >Seleccione Asignatura</option>
								<option value='DE' $sela >DESCANSO</option>
								<option value='PR' $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".$hor[0]."' name='diasb".$hor[0]."' 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".$hor[0]."' name='hib".$hor[0]."' 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".$hor[0]."' name='mib".$hor[0]."' 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".$hor[0]."' name='hfb".$hor[0]."' 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".$hor[0]."' name='mfb".$hor[0]."' 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(".$hor[0].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
							 	
							 	
						</div>	
					</div>
				</div>
			</div>	
							";
								
								
							}	
								
						}
						$tbody.="						
								</td>								
							</tr>
							";	      
						      }
					      $tbody.="
					      	 </tbody>	
					      	</table>
					      </div>
					    </div>
					  </div>";
				}
					$tbody.="</div>";

*/






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

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

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

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

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script>
      <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script>
    <![endif]-->
    <script>
    function 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('docenteb'+id).value=='XX'){alert('Debe seleccionar Docente');return false;}
	else{document.getElementById('docenteb').value=document.getElementById('docenteb'+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 crea_registro(){

	
if(document.getElementById('docente').value=='XX'){alert('Debe seleccionar Docente');return false;}
	else{document.getElementById('docente2').value=document.getElementById('docente').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}


	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'>
             	          <span style='float:right;margin-right:10px; margin-top:15px' class='label label-success'><span class='glyphicon glyphicon-user'></span> ".$_SESSION["user"]."</span>
       </a>
      </div><!-- /.container -->
    </div><!-- /.navbar -->


    <div class=\"container\">

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

       <div class=\"col-xs-6 col-sm-3 sidebar-offcanvas\" id=\"sidebar\" role=\"navigation\">
          <div class=\"list-group\">
            <a href=\"general.php\" class=\"list-group-item active\"><span class=\"glyphicon glyphicon-home\"></span> General</a>
            <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 \"><span class=\"glyphicon glyphicon-edit\"></span> Horario</a>
            <a href=\"horario_atencion.php\" class=\"list-group-item active\"><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>
        </div><!--/span-->

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

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

		<input type='hidden' name='l_curso22' id='l_curso22' value='".$l_curso22."'>
		<input type='hidden' name='asignatura2' id='asignatura2' value='".$asignatura2."'>
		<input type='hidden' name='docente2' id='docente2' value='".$docente2."'>						
		<input type='hidden' name='dias2' id='dias2' value='".$dias2."'>
		<input type='hidden' name='hi2' id='hi2' value='".$hi2."'>		
		<input type='hidden' name='mi2' id='mi2' value='".$mi2."'>				
		<input type='hidden' name='hf2' id='hf2' value='".$hf2."'>		
		<input type='hidden' name='mf2' id='mf2' value='".$mf2."'>				
		
		<div class=\"page\">
			<fieldset>
				<legend>
					<br><span class=\"glyphicon glyphicon-calendar\"></span> Nuevo Horario At.
				</legend>			
			</fieldset>
		
		<div class='input' style='float:left;width: 150px;padding-top: 5px;text-align: left;padding-left: 10px;' >
			Docente / Coord.&nbsp;
		  </div>
		 <div class='input' >
					<select id='docente' name='docente' class='form-control' style='width:24%;margin-bottom: 10px'>";
				
			
				
					$select_doc='select teacher_id,nombre,coordinador
					from docente order by coordinador,nombre';
					$res_select_doc=mysql_query($select_doc);
					echo "<option value='XX' >Seleccione Doc. - Coord.</option>";
					while($r_sc=mysql_fetch_array($res_select_doc)){
					$sel1='  ';
					//if($_POST['area']==$r_ar[0]){$sel1=' selected ';}
					if($r_sc[2]==1){$r_sc[2]='Coord.';}else{$r_sc[2]='Docente';}
							echo '<option value="'.$r_sc[0].'"  '.$sel1.'>'.$r_sc[2].' - '.$r_sc[1].' </option>';
					}
					
echo					"</select>
		 </div>
		
		
		
		

	
		 <div class='input' style='float:left;width: 150px;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: 150px;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: 150px;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: 150px;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: 150px;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 $act1 \" id=\"home\">
	<form name='listar_horario' id='listar_horario' method='post' action='horario_atencion.php' target=''>
	<div class=\"page\">
	

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