<? include ("clases/autor.class.php");

?>
<html>
	<head><title>mi web</title>
	<link rel="stylesheet" href="media/css/bootstrap.css">
	<link rel="stylesheet" href="media/css/bootstrap.min.css">
	<link rel="stylesheet" href="media/css/bootstrap-theme.css">
	<link rel="stylesheet" href="media/css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="media/css/dataTables.bootstrap.min.css">
	<link rel="stylesheet" href="media/css/fixedHeader.bootstrap.min.css">
	<link rel="stylesheet" href="media/css/responsive.bootstrap.min.css">
	 <script src="media/js/jquery-1.10.2.js"></script>
	<script src="media/js/jquery.dataTables.min.js"></script>
	<script src="media/js/dataTables.bootstrap.min.js"></script>
	<script src="media/js/dataTables.fixedHeader.min.js"></script>
	<script src="media/js/dataTables.responsive.min.js"></script>
	<script src="media/js/responsive.bootstrap.min.js"></script>
	
	<script src="media/js/jquery.min.js"></script>
    <script src="media/js/bootstrap.min.js"></script>
	<script>
		$(document).ready(function() {
		var table = $('#example').DataTable( {
			responsive: true
		} ); 
			new $.fn.dataTable.FixedHeader( table );
		 });
   </script> 
		</head>
	
	<script language="javascript">
	function consultar(f){
	f.action = 'mandocente.php';
	f.submit();return true;
	}
	
	function reiniciarClave(id)
		{
		   document.f1.action="controladores/procesa.php?iddoc="+id+"&text=RE";
		   document.f1.submit();
		   return true;
		}
	</script>
	
	<script>
	function guardar(f)
	{
	  if(f.nombre.value=="")
	  {
	    f.nombre.focus();
		return false;
	  }
	  if(f.apellido.value=="")
	  {
	    f.apellido.focus();
		return false;
	  }
	  if(f.telefono.value=="")
	  {
	    f.telefono.focus();
		return false;
	  }
	  if(f.email.value=="")
	  {
	    f.email.focus();
		return false;
	  }
	 
	  	f.action = 'controladores/procesa.php';
		f.submit();
		return true;
	}
	
	function editar(f)
	{
	  if(f.nombre.value=="")
	  {
	    f.nombre.focus();
		return false;
	  }
	  if(f.apellido.value=="")
	  {
	    f.apellido.focus();
		return false;
	  }
	  if(f.telefono.value=="")
	  {
	    f.telefono.focus();
		return false;
	  }
	  if(f.email.value=="")
	  {
	    f.email.focus();
		return false;
	  }
	  
	  	f.action = 'controladores/procesa.php';
		f.submit();
		return true;
	}

$(document).ready(function() {
  $('a[data-toggle=modal], button[data-toggle=modal]').click(function () {
    var data_id = '';
	var data_des= '';
    if (typeof $(this).data('id') !== 'undefined') {
      data_id = $(this).data('id');	   
    }
    $('#iddoc').val(data_id);
  })
});	
	
	
	</script>
	<script>
	function rellenar(i,n,a,e,t){		   
			 document.form2.iddoc.value=i;
			 document.form2.nombre.value=n;
			 document.form2.apellido.value=a;
			 document.form2.email.value=e;
			 document.form2.telefono.value=t;
			 }
	</script>
	<body>
	<div class="container">
	<div class="row">
		
        
        <div class="col-md-12">
		
        <h4>Lista de Docentes <button class="btn btn-success btn-xs" data-title="AGREGAR" data-toggle="modal" data-target="#nuevo" ><span class="glyphicon glyphicon-plus"></span> Agregar</button><a href="contenido.php" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></h4>
		<form name="f1" method="post" action="">
        <div class="table-responsive">            
              <table width="100%" class="table table-striped table-bordered nowrap" id="example">
                   
                   <thead>
                   <tr>
				    <th width="3%">Foto</th>
                    <th width="19%">Nombres y Apellidos </th>
					<th width="13%">Telefono</th>
                     <th width="13%">Email</th>
                     <th width="3%">Reset</th>
					 <th width="3%">Editar</th>
                   </thead>
    <tbody>
    
    <tr><?
	        $obj = new autor(); //$a = $_POST["txtbuscar"]; 
		   //$lista = $objcur->ListarPorCriterio($a);
		    $lista = $obj->ListaTotal();
		   //////////////////////////////////////////////////77	
			//////////////////////////////////////////////////////////77
		   for($i=0;$i<count($lista); $i++){	    
			
		?>
    <td><?php if($lista[$i]["foto"]==""){echo "<img src='fotos/student.png' width='66' height='64'>";}else{?><img src="fotos/<?= $lista[$i]["foto"];?>" width="66" height="64" class="img-thumbnail img-circle"><?php } ?></td>
    <td><?=$lista[$i]["nombres"];?>
      <?=$lista[$i]["apellidos"];?></td>
    <td><?=$lista[$i]["telefono"];?></td>
    <td><?=$lista[$i]["email"];?></td>
	<td><p data-placement="top" data-toggle="tooltip" title="Resetear clave"><button class="btn btn-warning"  onClick="reiniciarClave('<?=$lista[$i]["iddoc"];?>');"><span class="glyphicon glyphicon-refresh"></span></button>
        </td>
		<td><p data-placement="top" data-toggle="tooltip" title="Edit">
		    <input type="button" name="Submit" value="Editar" data-title="edit" data-toggle="modal" data-target="#edit" onClick="rellenar('<?=$lista[$i]["iddoc"];?>','<?=$lista[$i]["nombres"];?>','<?=$lista[$i]["apellidos"];?>','<?=$lista[$i]["email"];?>','<?=$lista[$i]["telefono"];?>');" class="btn btn-primary">
		</td>
    </tr>
    <?
		  }
		?>

    
 <tr>
    <td width="3%">Foto</td>
	<td width="19%">Nombres y Apellidos </td>
	<td width="13%">Telefono</td>
	 <td width="13%">Email</td>
	 <td width="3%">Reset</td>
	 <td width="3%">Editar</td>
    </tr>
    </tbody>
</table>

<div class="clearfix">

</div>

                
          </div>
  </form>          
        </div>
	</div>
</div>
	
<form action="" method="post" enctype="multipart/form-data" name="f">
<div class="modal fade" id="nuevo" tabindex="-1" role="dialog" aria-labelledby="nuevo" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
        <h4 class="modal-title custom_align" id="Heading">Registro de Docente </h4>
      </div>
      <div class="modal-body">
         <div class="form-group">
		 Nombres:<input type="text" name="nombre" value="<?=$nom;?>" class="form-control">
		 </div>
		 <div class="form-group">
		 Apellidos: <input type="text" name="apellido" value="<?=$ape;?>" class="form-control">
		 </div>
		 <div class="form-group">
		 Telefono: <input type="text" name="telefono" value="<?=$tel;?>" class="form-control">
		 </div>
		 <div class="form-group">
		 Email: <input type="text" name="email" value="<?=$ema;?>" class="form-control">
		 </div>		 
		 <div class="form-group">
		 Foto: <input type="file" name="file" class="form-control"> <input type="hidden" name="MAX_FILE_SIZE" value="4000000">
		 </div><input type="hidden" name="text" value="R">
        <div class="modal-footer ">
        <button type="button" class="btn btn-warning btn-lg" style="width: 100%;" onClick="guardar(this.form);"><span class="glyphicon glyphicon-ok-sign"></span>Guardar</button>
		</div>
      </div>
      </div>
    </div>
  </div>
</form>	

<form name="form2" id="form2" action="" method="post" enctype="multipart/form-data"> 
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
      <div class="modal-dialog">
    <div class="modal-content">
          <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
        <h4 class="modal-title custom_align" id="Heading">Actualizacion de Docente</h4>
      </div>
          <div class="modal-body">
         <div class="form-group">
		 Nombres:<input type="text" name="nombre" value="" class="form-control">
		 </div>
		 <div class="form-group">
		 Apellidos: <input type="text" name="apellido" value="" class="form-control">
		 </div>
		 <div class="form-group">
		 Telefono: <input type="text" name="telefono" value="" class="form-control">
		 </div>
		 <div class="form-group">
		 Email: <input type="text" name="email" value="" class="form-control">
		 </div>
		
		 <div class="form-group">
		 Foto: <input type="file" name="file" class="form-control"> <input type="hidden" name="MAX_FILE_SIZE" value="4000000">
		 </div>
                        <input type="hidden" name="text" value="M">
                        <input type="hidden" name="iddoc" value="">
         </div>
          <div class="modal-footer ">
        <button type="button" class="btn btn-warning btn-lg" style="width: 100%;" onClick="editar(this.form);"><span class="glyphicon glyphicon-ok-sign"></span>Actualizar</button>		
      </div>
        </div>
    <!-- /.modal-content --> 
  </div>
      <!-- /.modal-dialog --> 
    </div>	
</form>	
<script type="text/javascript">
$(document).ready(function(){
$("#mytable #checkall").click(function () {
        if ($("#mytable #checkall").is(':checked')) {
            $("#mytable input[type=checkbox]").each(function () {
                $(this).prop("checked", true);
            });

        } else {
            $("#mytable input[type=checkbox]").each(function () {
                $(this).prop("checked", false);
            });
        }
    });
    
    $("[data-toggle=tooltip]").tooltip();
});

</script>
	</body>	
</html>