Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Horario</title>
- <link rel="shortcut icon" type="image/jpg" href="images.jpg"/> <!-- Poner icono en la barra, es decir, al lado de title -->
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script type="text/javascript">
- function modificarhorario(){
- var idhorario = $('#idhorario').val();
- var profesor2 = $('#profesor2').val();
- var clases2 = $('#clases2').val();
- var dia2 = $('#dia2').val();
- var horainicial2 = $('#horainicial2').val();
- var horafinal2 = $('#horafinal2').val();
- if((profesor2==0) || (clases2==0) || (dia2==0) || (horainicial2==0) || (horafinal2==0)){
- if(profesor2 == 0){
- alertify.error('Debe seleccionar un profesor');
- e.preventDefault();
- }
- if(clases2 == 0){
- alertify.error('Debe seleccionar una clase');
- e.preventDefault();
- }
- if(dia2 == 0){
- alertify.error('Debe seleccionar un dia');
- e.preventDefault();
- }
- if((horainicial2 && horafinal2) == 0){
- alertify.error('Debe seleccionar el horario de clase');
- e.preventDefault();
- }else{
- if(horainicial2==0){
- alertify.error('Debe seleccionar el hora de inicio de clases');
- e.preventDefault();
- }
- if(horafinal2==0){
- alertify.error('Debe seleccionar el hora de final de clases');
- e.preventDefault();
- }
- }
- }else{
- if(horafinal2<=horainicial2){
- alertify.error('Debe seleccionar la hora de clases correctamente');
- e.preventDefault();
- }else{
- $("#mensajehorario").show();
- $.ajax({
- url: "modificarhorario.php",
- method: "post",
- data: { id:idhorario, profesor:profesor2, clases:clases2, dia:dia2, horainicial:horainicial2, horafinal:horafinal2},
- }).done(function(result){
- $("#mensajehorario").html(result);
- }).fail(function(){});
- }
- }
- }
- function modihorario(id){
- $('#modaleditar').modal("show");
- $.ajax({
- url: "modihorario.php",
- method: "post",
- data: {id:id}
- }).done(function(result){
- $("#resultmodi").html(result);
- }).fail(function(){});
- }
- function eliminarhorario(id){
- $("#mensajehorario").show();
- $.ajax({
- url: "eliminarhorario.php",
- method: "post",
- data: {id:id}
- }).done(function(result){
- $("#mensajehorario").html(result);
- }).fail(function(){});
- }
- </script>
- </head>
- <body>
- <?php
- $conexion=mysqli_connect("localhost","root","") or die ("error con la conexion");
- $BaseDeDatos = mysqli_select_db($conexion ,"formgym");
- ?>
- <!-- modal editar-->
- <div id="modaleditar" class="modal fade" role="dialog">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- <h3 class="modal-title"><center>Modificar horario</center></h3>
- </div>
- <div class="modal-body">
- <div class=".col-md-6 .col-md-offset-3" id="resultmodi">
- <!--resultado de modihorario.php -->
- </div>
- </div>
- <div class="modal-footer">
- <center>
- <input type="submit"value="Modificar horario" id="modificar" class="btn btn-primary" onclick="modificarhorario()">
- <button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
- </center>
- </div>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div><!-- /.modal -->
- <!-- Main -->
- <div class="rows"> </div>
- <center><h2>Horario</h2></center>
- <br> </br>
- <table border="2" bordercolor="#000000" width="100%" class="table table-bordered table-striped table-hover">
- <tr class='warning'>
- <th> <center>Hora </center></th>
- <th> <center>Lunes </center></th>
- <th> <center>Martes </center></th>
- <th> <center>Miercoles </center></th>
- <th> <center>Jueves </center></th>
- <th> <center>Viernes </center></th>
- <th> <center>Sabado </center></th>
- </tr>
- <?php
- $lunes=0;
- $martes=0;
- $miercoles=0;
- $jueves=0;
- $viernes=0;
- $sabado=0;
- echo"<tr class='info'>";
- echo"<td>7:00 am - 7:30 am </td>";
- if($lunes !=0){
- $lunes= $lunes - 1;
- }else{
- $lunes=0;
- $e=0;
- $l1 ="SELECT * FROM horario INNER JOIN profesor ON (profesor.idprofesor=horario.idprofesor)INNER JOIN horas ON (horas.idhora=horario.idhorainicio) INNER JOIN dia ON (dia.iddia=horario.iddia)INNER JOIN clase ON (clase.idclases=horario.idclases) WHERE horario.idhorainicio='1' AND horario.iddia='1' ";
- $consulta=mysqli_query($conexion,$l1);
- while($r1=mysqli_fetch_array($consulta)){
- $e=1;
- $id=$r1['idhorario'];
- $nombre=$r1['nombre'];
- $apellido=$r1['apellido'];
- $tipo=$r1['tipo'];
- $idhorainicio=$r1['idhorainicio'];
- $idhorafin=$r1['idhorafin'];
- for($i=$idhorainicio; $i<$idhorafin;$i++){
- $lunes= $lunes + 1;
- }
- echo"<td rowspan='$lunes'> $nombre $apellido - $tipo <br>
- <button type='submit' class='btn btn-link' id='editar' onclick='modihorario(".$id.")'>
- <span class='glyphicon glyphicon-pencil'> Modificar</span>
- </button>
- <button type='submit' class='btn btn-link'onclick='eliminarhorario(".$id.")'>
- <span class='glyphicon glyphicon-remove'> Eliminar</span>
- </button>
- </td>";
- $lunes=$lunes-1;
- }
- if ($e==0){
- echo"<td> Disponible </td>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement