<?php 
session_start();
  error_reporting(E_ALL);
  ini_set('display_errors', 'On');
try {
    $con = new PDO('mysql:host=localhost;dbname=interactivos', 'aofreew', 'conexioneS.118e', array( PDO::ATTR_PERSISTENT => true));
    $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $res=$con->query('SELECT nombre,slug,jj,jg,jp,je,gf,gc,dg,pts FROM  equipos order by pts desc,dg desc',PDO::FETCH_ASSOC);
    $row=$res->fetchAll();
    // var_dump($row[0]['idequipos']);
    // echo "<br>";
  } catch (PDOException $e) {
    print "¡Error!: " . $e->getMessage() . "<br/>";
    die();
}

$con2 = mysqli_connect("localhost","aofreew","conexioneS.118e","interactivos") or die("Ocurrio algun error durante la conexion! " . mysqli_error($con2));
$json = array();
$dias = array( 1=>'Lunes',2=>'Martes',3=>'Miercoles',4=>'Jueves',5=>'Viernes',6=>'Sabado',7=>'Domingo' );
$meses = array(1=>'Enero',2=>'Febrero',3=>'Marzo',4=>'Abril',5=>'Mayo',6=>'Junio',7=>'Julio',8=>'Agosto',9=>'Septiembre',10=>'Octubre',11=>'Noviembre',12=>'Diciembre');
for ($i=1; $i <=17 ; $i++) { 
    $query = "select j.idjuego,equipo_a as slug_a,equipo_b as slug_b,(select jn.texto from jornada jn where jn.idjornada=j.jornada) texto, (select e.nombre from equipos e where e.slug=j.equipo_a) equipo_a, (select ee.nombre from equipos ee where ee.slug=j.equipo_b) equipo_b, j.goles_a, j.goles_b, j.fecha, j.estadio, j.display from juegos j where j.jornada={$i}";
    $res2 = mysqli_query($con2, $query);
    while($row2 = mysqli_fetch_array($res2)) {
      $fecha = $row2['fecha'];
      $dia = date('d', $fecha);
      $diaStr = $dias[date('N', $fecha)];
      $mesStr = $meses[date('n',$fecha)];
      $year = date('Y',$fecha);
      $hora = date('H:i',$fecha);
      $fechaStr = $dia.' '.$mesStr.', '.$year;
      $items[] = array(
        'texto' =>utf8_encode($row2['texto']),
        'idjuego'=>utf8_encode($row2['idjuego']),
        'equipo_a'=>utf8_encode($row2['equipo_a']),
        'equipo_b'=>utf8_encode($row2['equipo_b']),
        'slug_a'=>utf8_encode($row2['slug_a']),
        'slug_b'=>utf8_encode($row2['slug_b']),
        'diaStr'=>utf8_encode($diaStr),
        'fechaStr'=>utf8_encode($fechaStr),
        'timestamp'=>utf8_encode($fecha),
        'hora'=>utf8_encode($hora),
        'goles_a'=>$row2['goles_a'],
        'goles_b'=>$row2['goles_b'],
        'estadio'=>(empty($row2['estadio']) ? ' ' : $row2['estadio']),
        'display'=>$row2['display']
       );
    }
    $json[$i] = $items;
    unset($items);
}

?>
<!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">
  <title>El Universal | Calendario Liga MX</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
  <meta name="robot" content="index,follow" />
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="keywords" content="Liguilla Apertura 2017, Fútbol Mexicano, Estadisticas, Encuentros, Futbol, Partidos, Noticias, Minuto a minuto." />
  <meta name="author" content="El Universal, Compañia Periodística Nacional. México">
  <meta name="description" content="EL UNIVERSAL, periódico líder en noticias de México y el mundo minuto por minuto; información que te interesa sobre mundo, ciudad">
  <meta name="description" content="Sitio líder de noticias minuto x minuto de México y el mundo, con información sobre política, ciudad, videos, interactividad, opinión, blogs" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  
  <!--Open Graph data-->
<meta property="og:title" content="Calendario Liga MX"/>
<meta property="og:url" content="http://interactivo.eluniversal.com.mx/ligamx/index.php" />
<meta property="og:type" content="website"/>
<meta property="og:description" content="Calendario Liga MX - 2017" />
<meta property="og:image" content="http://interactivo.eluniversal.com.mx/ligamx/img/facebook-liga-mx.jpg" />

<!--Twitter Card-->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Calendario Liga MX" />
<meta name="twitter:description" content="Calendario Liga MX - 2017" />
<meta name="twitter:url" content="http://interactivo.eluniversal.com.mx/ligamx/index.php" />
<meta name="twitter:image" content="http://interactivo.eluniversal.com.mx/ligamx/img/twitter-liga-mx.jpg" />

  <!-- Favicon -->
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  <link rel="manifest" href="/manifest.json">
  <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#005383">
  <meta name="theme-color" content="#005383">
  <!-- Termina Favicon)-->

  <!-- Bootstrap Core CSS -->
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom Fonts -->
  <link href="css/font-awesome.min.css" rel="stylesheet">
  <!-- Theme CSS -->
  <link href="css/grayscale.min.css" rel="stylesheet">
  <!-- Sport Css-->
  <link rel="stylesheet" id="sportspress-general-css" href="css/sportspress.css" type="text/css" media="all">
  <link rel="stylesheet" id="rookie-framework-style-css" href="css/framework.css" type="text/css" media="all">
  <link rel="stylesheet" id="rookie-style-css" href="css/style.css" type="text/css" media="all">
  <link rel="stylesheet" id="icons-css" href="css/dashicons.min.css" type="text/css" media="all">
  <!-- Sport Script -->
  <script type="text/javascript" src="js/jquery.js"></script>
  <!-- Js de contador -->
  <script type="text/javascript" src="js/jquery-migrate.min.js"></script>
  <!-- Mantiene en su sitio al logo en responsive -->

  <!-- Owl -->
  <link rel="stylesheet" type="text/css" href="css/owl.css">
  <style>
.navbar-toggler {
  z-index: 1;
}

@media (max-width: 576px) {
nav > .container {
  width: 100%;
}
}

tr:nth-child(1n){
  line-height: 50px;
  background-color: white;
}
body{
    padding-top:80px;
}

.sp-event-results-alter{ min-height: 7px; }
</style>
  <!-- FInal de Mantiene en su sitio al logo en responsive -->
  <!-- Accordion -->
  <link rel="stylesheet" href="css/jquery-ui.css">
  <script src="js/jquery-1.12.4.js.js"></script>
  <script src="js/jquery-ui.js"></script>
  <script>
  $(document).ready(function(){

      $( ".accordion" ).accordion({
        heightStyle: "content"
      });

  $(".link").click(function(event){
       event.preventDefault();
       var elementid = $(this).data("element");
       var offset = $('#'+elementid).offset();
       var scrollto = offset.top - 70; // minus fixed header height
       $('html, body').animate({scrollTop:scrollto}, 200);

     });
  });
  </script>
  </head>

  <body id="page-top" class="contenedor"  style="background-color:#000000;">

<!-- Navegación -->
<nav id="mainNav" class="navbar fixed-top navbar-toggleable-md navbar-light">
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarExample" aria-controls="navbarExample" aria-expanded="false" aria-label="Toggle navigation"> <i class="icon fa fa-bars"></i> </button>
    <div class="container"> <a class="navbar-brand page-scroll" href="http://www.eluniversal.com.mx/"><img class="logo" src="img/logo-eluniversal.png"></a>
    <div class="collapse navbar-collapse" id="navbarExample">
        <ul class="navbar-nav ml-auto">
        <li class="nav-item"> <a class="nav-link page-scroll" href="#page-top">Inicio</a> </li>
        <!--<li class="nav-item"> <a class="" href="#about">Jornadas</a> </li>-->
        <div class="dropdown">
          <a class="nav-link page-scroll dropdown-toggle" data-toggle="dropdown">Jornadas<span class="caret"></span></a>
          <ul class="dropdown-menu" style="background-color: #000000">
          <?php foreach($json as $kei => $val){ ?>
              <div class="nav-item" id="<?php echo $idEnlace='enlace'.$kei; ?>"><li><a href="#" class="link" data-element='<?php echo 'content-'.$kei; ?>'><?php echo 'Jornada '.$kei; ?></a></li></div>
          <?php } ?>
          </ul>
        </div>
        <li class="nav-item"> <a class="nav-link page-scroll" href="#team">Estadísticas</a> </li>
        <?php if(isset($_SESSION['usuario']))
              {
                  if($_SESSION['usuario']==='admin-ud')
                  {
                    echo "<li class='nav-item'> <a class='nav-link page-scroll' href='estadisticas.php'>Administración</a> </li>";
                  }
              } 
         ?>
      </ul>
      </div>
  </div>
  </nav>
<!-- Final de Navegación --> 

<!-- Intro Header -->
<header class="intro">
    <div class="intro-body">
    <div class="container">
        <div class="row">
        <div class="col-md-12">
            <h1 class="brand-heading">Calendario Liga MX</h1>
            <p class="intro-text">Sigue jornada a jornada los resultados de cada partido de la Liga MX, y la lucha por la cima del campeonato del futbol mexicano. </p>
            <div class="date">
            <p>Fecha de Publicación<br>
                18 / 07 / 2017</p>
          </div>
            <div><a href="#about" class="btn btn-circle page-scroll"> <i class="fa fa-angle-double-down animated"></i> </a></div>
          </div>
      </div>
      </div>
  </div>
  </header>
<!-- Final de Header --> 
<!-- Inicia Estadisticas -->

<section id="about" class="container content-section text-center" style="padding: 120px 0;"> 
    <!-- Cuadro de encuentros -->
    <div id="content" class="site-content">
    <?php foreach($json as $kei => $val){?>
    <div class="content-area content-area-right" id='<?php echo 'content-'.$kei; ?>'>
        <main id="main" class="site-main" role="main">
        <article id="post-2" class="post-2 page type-page status-publish hentry">
            <div class="entry-content">
            <div class="homepage-widgets">
                <div class="sp-widget-align-left">
                <aside id="sportspress-event-blocks-3" class="widget widget_sportspress widget_sp_event_blocks">
                    <h4 class="sp-table-caption"><span class="jornada">Jornada <?php echo $kei; ?></span><?php echo $val[0]['texto']; ?></h4>
                    <div class="sp-template sp-template-event-blocks">
                    <div class="sp-table-wrapper">
                        <table class="sp-event-blocks sp-data-table sp-paginated-table" data-sp-rows="8">
                        <thead>
                            <tr>
                            <th></th>
                          </tr>
                          </thead>
                        <tbody>
                          <tr>
                            <td>                              
                              <div class="accordion">
                                <?php foreach($val as $k => $v ){?>
                                <h3 style="text-align:center;"><img class="logs" width="30px" height="auto" style="margin: 0 10px;" src="img/teams/<?php echo $v['slug_a']; ?>.png"><span class="big"><?php echo utf8_decode($v['equipo_a'])?> VS <?php echo utf8_decode($v['equipo_b']); ?></span><span class="small"> VS </span><img class="logs" width="30px" height="auto" style="margin: 0 10px;" src="img/teams/<?php echo $v['slug_b']; ?>.png"></h3>
                                <div> <a class="team-logo logo-odd" title="<?php echo $v['slug_a'] ?>"><img width="100" height="153" src="img/teams/<?php echo $v['slug_a']; ?>.png" class="attachment-sportspress-fit-icon size-sportspress-fit-icon wp-post-image" alt="" sizes="(max-width: 100px) 100vw, 100px"></a> <a class="team-logo logo-even" title="<?php echo $v['slug_b'] ?>"><img width="115" height="153" src="img/teams/<?php echo $v['slug_b']; ?>.png" class="attachment-sportspress-fit-icon size-sportspress-fit-icon wp-post-image" alt="" sizes="(max-width: 115px) 100vw, 115px"></a>
                                  <h5 class="sp-event-date" style="font-size: 12px;"><?php echo $v['diaStr']; ?></h5>
                                  <h5 class="sp-event-results"><span class="sp-result"><?php echo $v['hora']; ?> hrs</span></h5>
                                  <time class="sp-event-date" datetime="2017-04-11 13:45:00"><?php echo $v['fechaStr']; ?></time>
                                  <?php if($v['display']==1){ ?>
                                  <h5 class="sp-event-results"><span class="sp-result marcador"><?php echo $v['goles_a']; ?> - <?php echo $v['goles_b']; ?></span></h5>
                                  <?php }else{ ?>
                                  <h5 class="sp-event-results-alter"></h5>
                                  <?php }?>
                                  <time class="sp-event-date"><?php echo $v['estadio']; ?></time>
                                  <br>
                                </div>
                                <?php 
                                } ?> 
                                <br><br>                               
                              </div>
                            </td>                            
                          </tr>
                          </tbody>
                      </table>
                      </div>
                  </div>
                  </aside>
              </div>
              </div>
          </div>
            <!-- .entry-content --> 
          </article>
        <!-- #post-## -->
      </main>
        <!-- #main --> 
      </div>

      <?php } ?>


    <!-- #primary -->
  </div>
    <!-- Termina cuadro de Encuentros --> 
    
  </section>
<!-- Final de seccion --> 

<!--Inicia segundo section--> <!-- La caja de modales en la linea 253-->
<section id="team" class="section gray-bg">
    <div class="container">
    <div class="title text-center">
        <h2 style="text-align: center;">Estadísticas</h2>
      <!--<h4 class="light muted">Los mejores del juego</h4>-->
        <hr class="one">
      </div>
    <div class="row"> 
        
        <!-- Comienza el ranking de juego -->
        <div class="sp-widget-align-none" style="margin: 0 8px 20px; width: 100%">
        <aside id="sportspress-player-list-3" class="widget widget_sportspress widget_player_list widget_sp_player_list">
            <h4 class="sp-table-caption frag"><span class="jornada">Tabla general</span> Apertura <?php echo date('Y'); ?></h4>
            <div class="sp-template sp-template-player-list">
            <div class="sp-table-wrapper">
                <div class="sp-scrollable-table-wrapper">
                <div id="DataTables_Table_2_wrapper" class="dataTables_wrapper no-footer">
                    <div class="sp-scrollable-table-wrapper">
                    <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
                        <table class="sp-league-table sp-data-table sp-sortable-table sp-scrollable-table sp-paginated-table dataTable no-footer" data-sp-rows="18" id="DataTables_Table_0" role="grid">
                        <thead>
                            <tr role="row">
                            <th class="data-rank sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Pos">Pos</th>
                            <th class="data-name sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Team">Equipo</th>
                            <th class="data-p sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="P">JJ</th>
                            <th class="data-w sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="W">JG</th>
                            <th class="data-d sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="D">JE</th>
                            <th class="data-l sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="L">JP</th>
                            <th class="data-f sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="F">GF</th>
                            <th class="data-a sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="A">GC</th>
                            <th class="data-gd sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="GD">DG</th>
                            <th class="data-pts sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Pts">Pts</th>
                          </tr>
                          </thead>
                        <tbody class="estadisticas">
                            <?php foreach ($row as $iterador => $value){?>
                            <tr class="sp-row-no-0 odd" role="row">
                              <td class="data-rank "><?php echo $iterador+1 ?></td>
                              <td class="data-name has-logo "><span class="team-logo"><img width="100" height="153" src="img/teams/<?php echo $value['slug'] ?>.png" class="attachment-sportspress-fit-icon size-sportspress-fit-icon wp-post-image" alt="" sizes="(max-width: 100px) 100vw, 100px"></span><?php echo $value['nombre'] ?></td>
                              <td class="data-p "><?php echo $value['jj'] ?></td>
                              <td class="data-w "><?php echo $value['jg'] ?></td>
                              <td class="data-d "><?php echo $value['je'] ?></td>
                              <td class="data-l "><?php echo $value['jp'] ?></td>
                              <td class="data-f "><?php echo $value['gf'] ?></td>
                              <td class="data-a "><?php echo $value['gc'] ?></td>
                              <td class="data-gd "><?php echo $value['dg'] ?></td>
                              <td class="data-pts "><?php echo $value['pts'] ?></td>
                            </tr>
                            <?php } ?>
                          </tbody>
                      </table>
                      </div>
                  </div>
                  </div>
              </div>
              </div>
          </div>
          </aside>
      </div>
        <!-- Termina el ranking de juego --> 
      </div>
  </div>
  </section>
<!--Termina segundo section--> 

<!-- Footer -->
<footer>
    <div class="container">
    <div class="row">
        <div class="col-md-12 text-center text-center-mobile"> <img src="img/logo-eluniversal.png" width="200" height="18" alt="eluniversal">
        <h5 class="light regular light-white">© 2017 EL UNIVERSAL Online S.A. de C.V.<br>
            Compañía Periodística Nacional</h5>
      </div>
        <div class="col-md-12 text-center text-center-mobile">
        <div class="row opening-hours">
            <div class="col-md-4 text-center text-center-mobile">
            <h5 class="light-white light">Edición:</h5>
            <h5 class="regular-white">Universo Deportivo</h5>
          </div>
            <div class="col-md-4 text-center text-center-mobile">
            <h5 class="light-white light">Diseño Web:</h5>
            <h5 class="regular-white">Alejandro Sandoval</h5>
          </div>
          <div class="col-md-4 text-center text-center-mobile">
            <h5 class="light-white light">Desarrollo:</h5>
            <h5 class="regular-white">José Alfredo Ponce</h5>
          </div>
          </div>
      </div>
      </div>
    <div class="row bottom-footer text-center-mobile">
        <div class="col-md-12 text-center text-center-mobile">
        <ul class="social-footer">
            <li><a href="http://www.facebook.com/share.php?u=http://interactivo.eluniversal.com.mx/ligamx/index.php&title=El Universal | Liguilla Clausura 2017" onClick="window.open(this.href, this.target, 'width=500,height=400, scrollbars=1'); return false;"><i class="fa fa-facebook" ></i></a></li>
            <li><a href="http://twitter.com/home?status=El Universal Liguilla Clausura 2017+http://interactivo.eluniversal.com.mx/ligamx/index.php" onClick="window.open(this.href, this.target, 'width=500,height=400, scrollbars=1'); return false;"><i class="fa fa-twitter"></i></a></li>
            <li><a href="https://plus.google.com/share?url=http://interactivo.eluniversal.com.mx/ligamx/index.php" onClick="window.open(this.href, this.target, 'width=500,height=400, scrollbars=1'); return false;"><i class="fa fa-google-plus"></i></a></li>
          </ul>
      </div>
      </div>
  </div>
  </footer>
<!-- Termina Footer --> 

<!-- Comienzan Scripts --> 
<!-- jQuery Version 3.1.1 --> 
<script src="js/jquery.js"></script> 
<!-- Bootstrap Core JavaScript --> 
<script src="js/bootstrap.min.js"></script> 
<!-- Plugin JavaScript & Scrolling --> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script> 
<!-- Theme JavaScript --> 
<script src="js/grayscale.min.js"></script> 
<!-- Organización de tablas --> 
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script> 
<!-- Comienza Cuenta Regresiva --> 
<script type="text/javascript" src="js/jquery.countdown.min.js"></script> 
<script type="text/javascript">
/* <![CDATA[ */
var localized_strings = {"days":"Días","hrs":"hrs","mins":"mins","secs":"segs","previous":"Prev","next":"Sig"};
/* ]]> */</script> <!-- Termina Cuenta Regresiva --> 
<!-- Complemento de tablas --> 
<script type="text/javascript" src="js/sportspress.js"></script> 
<!-- Codigo JS para animaciones y comportamientos --> 
<script src="js/main.js"></script>

<!-- Terminan Scripts -->
</body>
  <!-- Inicia comScore Certifica code 1.1104.26-->
  <script type="text/javascript">
// <![CDATA[
function comScore(t){var b="comScore",o=document,f=o.location,a="",e="undefined",g=2048,s,k,p,h,r="characterSet",n="defaultCharset",m=(typeof encodeURIComponent!=e?encodeURIComponent:escape);if(o.cookie.indexOf(b+"=")!=-1){p=o.cookie.split(";");for(h=0,f=p.length;h<f;h++){var q=p[h].indexOf(b+"=");if(q!=-1){a="&"+unescape(p[h].substring(q+b.length+1))}}}t=t+"&ns__t="+(new Date().getTime());t=t+"&ns_c="+(o[r]?o[r]:(o[n]?o[n]:""))+"&c8="+m(o.title)+a+"&c7="+m(f&&f.href?f.href:o.URL)+"&c9="+m(o.referrer);if(t.length>g&&t.indexOf("&")>0){s=t.substr(0,g-8).lastIndexOf("&");t=(t.substring(0,s)+"&ns_cut="+m(t.substring(s+1))).substr(0,g)}if(o.images){k=new Image();if(typeof ns_p==e){ns_p=k}k.src=t}else{o.write('<p><'+'img src="'+t+'" height="1" width="1" alt="*"></p>')}};
comScore('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/p?c1=2&c2=6906641&ns_site=el-universal&name=eluniversal.Graficos.ligamx');
// ]]>
</script>
  <noscript>
  <p><img src="http://b.scorecardresearch.com/p?c1=2&amp;c2=6906641&amp;ns_site=el-universal&amp;name=el-universal.Graficos.ligamx" height="1" width="1" alt="*"></p>
  </noscript>
  <!-- Fin comScore Certifica-->
  <!--Código de Google Analytics-->
  <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
  <script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5566785-1");
pageTracker._trackPageview();
</script>
  <!--Fin de Google Analytics-->
  <!-- Contador interno// -->
  <script language="JavaScript" src="http://hits.eluniversal.com.mx/accesos/accesos_detalle.php?p_id_nota=1890&var_secc=500&var_cabeza=ligamx"></script>
</html>