<?php
 if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])){exit();}
 global $config;
 require_once 'config/class/class.database.php';
 $db = new database();

 $annees = array(2016, 2017, 2019, 2021);
 if (!empty($_GET['a']) && in_array($_GET['a'], $annees)) $__a=$_GET['a']; else $__a=2019;
?>

<?php $_shouldextend[1]=1; ?>


<?php $this->startSection('wisra_basic_content'); ?>
 @parentXYZABC

<div class="body-content js-body-content blue-body">
 <main id="main">
 <div class="standings-background-hero">
 <picture class="standings-background-hero__pattern left js-lazy-picture loaded">
 <img src="<?php echo $config['app_url'] ?>sources/image/basic/stripes-left.png" data-image-src="<?php echo $config['app_url'] ?>sources/image/basic/stripes-left.png" alt="Standings Background Pattern">
 </picture>
 <picture class="standings-background-hero__pattern right js-lazy-picture loaded">
 <img src="<?php echo $config['app_url'] ?>sources/image/basic/stripes-right.png" data-image-src="<?php echo $config['app_url'] ?>sources/image/basic/stripes-right.png" alt="Standings Background Pattern">
 </picture>
 </div>
 <div class="u-main-gradient">
 <div class="wrapper">
 <div class="col-12">
 <section class="standings">
 <div class="standings__header">
 <div class="standings-header">
 <h1> Récapitulatif </h1>
 </div>
 </div>

 <div class="standings__content js-standings-content">
 <section class="standings-league js-standings-pane">

 <div class="standings-league__header standings-pane-header">
 <div class="standings-pane-header__spacer"></div>
 <div class="standings-pane-header__info">
 <img src="<?php echo $config['app_url'] ?>sources/image/basic/semi-marathon-bejaia-footer.png" alt="<?php echo $config['app_name'] ?> logo" class="standings-pane-header__competition-logo">
 </div>
 <span class="standings-pane-header__name visually-hidden"></span>
 <div class="standings-pane-header__time-info">
 <div class="standings-pane-header__last-updated"> 
 <!--Fin de la course : <?php //echo $config['smib_dapart_date'].' '.$config['smib_annee_encours'] ?>-->
 </div>
 <div class="standings-pane-header__season-info-container">
 <!--<span class="standings-pane-header__season-info js-season-info"> <?php //echo //$config['smib_annee_encours']-2005 ?>ème  </span>
 <span class="standings-pane-header__match-week-info js-match-week-info"> Edition </span>-->
 </div>
 </div>
 </div>
<?php

 function sectotime($sec) {
 $timo='';
 $hr=floor($sec/3600);
 if ($hr>0) $timo.=$hr.':';
 $sec=$sec-$hr*3600;
 $mn=floor($sec/60);
 if ($mn>0) $timo.=(($mn<9)?'0':'').$mn.':'; else $timo.='00:';
 $sec=$sec-$mn*60;
 if ($sec>0) $timo.=(($sec<9)?'0':'').$sec; else $timo.='00';
 return $timo;
 }

 if ($__a==2016 || $__a==2017) {
/*========================
// Old one
==============================*/
 // Les gagnants
?>

 <div class="widget__header">
 <h3 class="widget__title">Les gagnants</h3>
 </div>

 <table class="standings-league__table standings-table">
 <thead class="standings-table__head">
 <tr>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Nom & Prénom</span>
 <span class="table-head__heading--short">Nom</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Pays</span>
 <span class="table-head__heading--short">Pays</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Course</span>
 <span class="table-head__heading--short">Course</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Sexe</span>
 <span class="table-head__heading--short">Sexe</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Temps</span>
 <span class="table-head__heading--short">Tps</span>
 </th>
 </tr>
 </thead>
 <tbody class="standings-table__body">

<?php
 $req = "
 SELECT A.nomnom, A.prenom, A.time_21_km, B.nom AS pays 
 FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.sexxxx=1 AND A.course=1 AND A.time_21_km>0 AND A.dossart>0
 ORDER BY A.time_21_km LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nomnom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21Km </td>
 <td class="table-stat-row "> Homme </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_21_km']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php
 $req = "
 SELECT A.nomnom, A.prenom, A.time_21_km, B.nom AS pays 
 FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.sexxxx!=1 AND A.course=1 AND A.time_21_km>0 AND A.dossart>0
 ORDER BY A.time_21_km LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nomnom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Dame </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_21_km']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php
 $req = "
 SELECT A.nomnom, A.prenom, A.time_7_km, B.nom AS pays 
 FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.sexxxx=1 AND A.course=2 AND A.time_7_km>0 AND A.dossart>0
 ORDER BY A.time_7_km LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nomnom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 7km </td>
 <td class="table-stat-row "> Homme </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_7_km']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php
 $req = "
 SELECT A.nomnom, A.prenom, A.time_7_km, B.nom AS pays 
 FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.sexxxx!=1 AND A.course=2 AND A.time_7_km>0 AND A.dossart>0
 ORDER BY A.time_7_km LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nomnom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 7km </td>
 <td class="table-stat-row "> Dame </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_7_km']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php 
 // Participation
?>

 <br/>
 <div class="widget__header">
 <h3 class="widget__title">Participation</h3>
 </div>

 <ul class="country-lists">
<?php 
 $pays_nbr=0;
 $req = "
 SELECT COUNT(*) AS nbr, B.nom AS pays FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.course=1 AND A.time_21_km>0 AND A.dossart>0 GROUP BY payspy ORDER BY nbr DESC;
 ";
 $arg = array('an'=>$__a);
 $infoss = $db->select($req, $arg, true);
 foreach ($infoss as $infos) if (!empty($infos['pays'])) {
 $pays_nbr++;
?>
 <li>
 <span class="one__county" title="<?php echo utf8_encode($infos['pays']);?>">
 <span><?php echo utf8_encode($infos['pays']);?></span>
 <span class="nbr_pais"><?php echo $infos['nbr'];?></span>
 </span>
 </li>
<?php } ?>
 </ul>

 <table class="standings-league__table standings-table">
 <tbody class="standings-table__body">
<?php 
 $req = "SELECT 
 (SELECT COUNT(DISTINCT wilaya) FROM participant WHERE annee=:an AND course=1 AND time_21_km>0 AND dossart>0 AND payspy=4) AS wil_nbr, 
 (SELECT COUNT(DISTINCT comune) FROM participant WHERE annee=:an AND course=1 AND time_21_km>0 AND dossart>0 AND payspy=4 AND wilaya=6) AS com_nbr, 
 (SELECT COUNT(*) FROM participant WHERE annee=:an AND course=1 AND sexxxx=1 AND time_21_km>0 AND dossart>0) AS hmn_nbr, 
 (SELECT COUNT(*) FROM participant WHERE annee=:an AND course=1 AND sexxxx!=1 AND time_21_km>0 AND dossart>0) AS fmn_nbr, 
 (SELECT COUNT(*) FROM participant WHERE annee=:an AND course=2 AND sexxxx=1 AND time_7_km>0 AND dossart>0) AS hpn_nbr, 
 (SELECT COUNT(*) FROM participant WHERE annee=:an AND course=2 AND sexxxx!=1 AND time_7_km>0 AND dossart>0) AS fpn_nbr, 
 (SELECT COUNT(*) FROM participant WHERE annee=:an AND enfant=1) AS cpn_nbr;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Nombre de pays participants </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $pays_nbr;?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Nombre de wilayas (S-M) </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['wil_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Nombre de communes de Béjaia (S-M) </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['com_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 21Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['hmn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 21Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['fmn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Participants 21Km </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo ($donnee['hmn_nbr']+$donnee['fmn_nbr']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 7Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['hpn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 7Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['fpn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Participants 7Km </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo ($donnee['hpn_nbr']+$donnee['fpn_nbr']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Enfants 3Km </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['cpn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Total des participants </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo ($donnee['hmn_nbr']+$donnee['fmn_nbr']+$donnee['hpn_nbr']+$donnee['fpn_nbr']+$donnee['cpn_nbr']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php 
 // Moyenne d'ages
 $req = "SELECT
 (SELECT AVG(ageage) FROM participant WHERE annee=:an AND sexxxx=1 AND course=1 AND time_21_km>0 AND dossart>0 AND ageage>0) AS hma_nbr, 
 (SELECT AVG(ageage) FROM participant WHERE annee=:an AND sexxxx!=1 AND course=1 AND time_21_km>0 AND dossart>0 AND ageage>0) AS fma_nbr, 
 (SELECT AVG(ageage) FROM participant WHERE annee=:an AND sexxxx=1 AND course=2 AND time_7_km>0 AND dossart>0 AND ageage>0) AS hpa_nbr, 
 (SELECT AVG(ageage) FROM participant WHERE annee=:an AND sexxxx!=1 AND course=2 AND time_7_km>0 AND dossart>0 AND ageage>0) AS fpa_nbr;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
 if (!empty($donnee)) {
?>

 <br/>
 <div class="widget__header">
 <h3 class="widget__title">Moyenne d'ages</h3>
 </div>

 <table class="standings-league__table standings-table">
 <tbody class="standings-table__body">

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 21Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['hma_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 21Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['fma_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 7Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['hpa_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 7Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['fpa_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>


 </tbody>
 </table>

<?php 
 }

 // Les plus agés
?>

 <br/>
 <div class="widget__header">
 <h3 class="widget__title">Les plus agés</h3>
 </div>

 <table class="standings-league__table standings-table">
 <thead class="standings-table__head">
 <tr>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Nom & Prénom</span>
 <span class="table-head__heading--short">Nom</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Pays</span>
 <span class="table-head__heading--short">Pays</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Course</span>
 <span class="table-head__heading--short">Course</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Sexe</span>
 <span class="table-head__heading--short">Sexe</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Age</span>
 <span class="table-head__heading--short">Age</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Temps</span>
 <span class="table-head__heading--short">Tps</span>
 </th>
 </tr>
 </thead>
 <tbody class="standings-table__body">

<?php 
 $req = "
 SELECT A.nomnom, A.prenom, A.time_21_km, A.ageage, B.nom AS pays 
 FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.sexxxx=1 AND A.course=1 AND A.time_21_km>0 AND A.dossart>0
 ORDER BY A.ageage DESC LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nomnom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Homme </td>
 <td class="table-stat-row "> <?php echo $donnee['ageage'];?> ans </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_21_km']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php 
 $req = "
 SELECT A.nomnom, A.prenom, A.time_21_km, A.ageage, B.nom AS pays 
 FROM participant A LEFT JOIN adex_pays B ON B.id=A.payspy 
 WHERE A.annee=:an AND A.sexxxx!=1 AND A.course=1 AND A.time_21_km>0 AND A.dossart>0
 ORDER BY A.ageage DESC LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nomnom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Dame </td>
 <td class="table-stat-row "> <?php echo $donnee['ageage'];?> ans </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_21_km']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php 
 } else {
/*========================
// 2019 Dassawen
==============================*/
 // Les gagnants
?>




 <div class="widget__header">
 <h3 class="widget__title">Les gagnants</h3>
 </div>

 <table class="standings-league__table standings-table">
 <thead class="standings-table__head">
 <tr>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Nom & Prénom</span>
 <span class="table-head__heading--short">Nom</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading"></span>
 <span class="table-head__heading--short"></span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Pays</span>
 <span class="table-head__heading--short">Pays</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Course</span>
 <span class="table-head__heading--short">Course</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Sexe</span>
 <span class="table-head__heading--short">Sexe</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Temps</span>
 <span class="table-head__heading--short">Tps</span>
 </th>
 </tr>
 </thead>
 <tbody class="standings-table__body">

<?php 
 $req = "
 SELECT A.nom, A.prenom, B.time_course, C.alpha2, C.nom_fr_fr AS pays 
 FROM member A 
 LEFT JOIN member_particip B ON B.membre=A.id LEFT JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND A.sex=1 AND B.course=1 AND B.time_course>0 AND B.dossard>0
 ORDER BY B.time_course LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="badge-row" scope="row">
 <span class="badge-row__badge" title="<?php echo utf8_encode($donnee['pays']);?>">
 <span class="visually-hidden"><?php echo utf8_encode($donnee['pays']);?></span>
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo (!empty($donnee['alpha2'])) ? strtolower($donnee['alpha2']) : 0;?>.svg" width="30" height="30" alt="<?php echo utf8_encode($donnee['pays']);?>">
 </span>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Homme </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_course']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php 
 $req = "
 SELECT A.nom, A.prenom, B.time_course, C.alpha2, C.nom_fr_fr AS pays 
 FROM member A 
 LEFT JOIN member_particip B ON B.membre=A.id LEFT JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND A.sex=0 AND B.course=1 AND B.time_course>0 AND B.dossard>0
 ORDER BY B.time_course LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="badge-row" scope="row">
 <span class="badge-row__badge" title="<?php echo utf8_encode($donnee['pays']);?>">
 <span class="visually-hidden"><?php echo utf8_encode($donnee['pays']);?></span>
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo (!empty($donnee['alpha2'])) ? strtolower($donnee['alpha2']) : 0;?>.svg" width="30" height="30" alt="<?php echo utf8_encode($donnee['pays']);?>">
 </span>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Dame </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_course']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php 
 $req = "
 SELECT A.nom, A.prenom, B.time_course, C.alpha2, C.nom_fr_fr AS pays 
 FROM member A 
 LEFT JOIN member_particip B ON B.membre=A.id LEFT JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND A.sex=1 AND B.course=2 AND B.time_course>0 AND B.dossard>0
 ORDER BY B.time_course LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="badge-row" scope="row">
 <span class="badge-row__badge" title="<?php echo utf8_encode($donnee['pays']);?>">
 <span class="visually-hidden"><?php echo utf8_encode($donnee['pays']);?></span>
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo (!empty($donnee['alpha2'])) ? strtolower($donnee['alpha2']) : 0;?>.svg" width="30" height="30" alt="<?php echo utf8_encode($donnee['pays']);?>">
 </span>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 7km </td>
 <td class="table-stat-row "> Homme </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_course']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php 
 $req = "
 SELECT A.nom, A.prenom, B.time_course, C.alpha2, C.nom_fr_fr AS pays 
 FROM member A 
 LEFT JOIN member_particip B ON B.membre=A.id LEFT JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND A.sex=0 AND B.course=2 AND B.time_course>0 AND B.dossard>0
 ORDER BY B.time_course LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="badge-row" scope="row">
 <span class="badge-row__badge" title="<?php echo utf8_encode($donnee['pays']);?>">
 <span class="visually-hidden"><?php echo utf8_encode($donnee['pays']);?></span>
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo (!empty($donnee['alpha2'])) ? strtolower($donnee['alpha2']) : 0;?>.svg" width="30" height="30" alt="<?php echo utf8_encode($donnee['pays']);?>">
 </span>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 7km </td>
 <td class="table-stat-row "> Dame </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_course']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php 
 // Participation
?>
 <br/>
 <div class="widget__header">
 <h3 class="widget__title">Participation</h3>
 </div>

 <ul class="country-lists">
<?php 
 $pays_nbr=0;
 $req = "
 SELECT COUNT(A.id) AS nbr, C.alpha2, C.nom_fr_fr AS pays FROM member A 
 INNER JOIN member_particip B ON B.membre=A.id INNER JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND B.course=1 AND B.classement>0 AND B.dossard>0 GROUP BY payspy ORDER BY nbr DESC;
 ";
 $arg = array('an'=>$__a);
 $infoss = $db->select($req, $arg, true);
 foreach ($infoss as $infos) if (!empty($infos['pays'])) {
 $pays_nbr++;
?>
 <li>
 <span class="one__county" title="<?php echo utf8_encode($infos['pays']);?>">
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo strtolower($infos['alpha2']);?>.svg" width="40" height="40" alt="<?php echo utf8_encode($infos['pays']);?>">
 <span><?php echo utf8_encode($infos['pays']);?></span>
 <span class="nbr_pais"><?php echo $infos['nbr'];?></span>
 </span>
 </li>
<?php } ?>
 </ul>

 <table class="standings-league__table standings-table">
 <tbody class="standings-table__body">
<?php 
 $req = "SELECT 
 (SELECT COUNT(DISTINCT A.wilaya) FROM member A INNER JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.course=1 AND B.time_course>0 AND B.dossard>0 AND A.payspy=4) AS wil_nbr, 
 (SELECT COUNT(DISTINCT A.comune) FROM member A INNER JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.course=1 AND B.time_course>0 AND B.dossard>0 AND A.payspy=4 AND A.wilaya=6) AS com_nbr, 
 (SELECT COUNT(*) FROM member A LEFT JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.course=1 AND A.sex=1 AND B.time_course>0 AND B.dossard>0) AS hmn_nbr, 
 (SELECT COUNT(*) FROM member A LEFT JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.course=1 AND A.sex=0 AND B.time_course>0 AND B.dossard>0) AS fmn_nbr, 
 (SELECT COUNT(*) FROM member A LEFT JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.course=2 AND A.sex=1 AND B.time_course>0 AND B.dossard>0) AS hpn_nbr, 
 (SELECT COUNT(*) FROM member A LEFT JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.course=2 AND A.sex=0 AND B.time_course>0 AND B.dossard>0) AS fpn_nbr, 
 (SELECT COUNT(*) FROM member A LEFT JOIN member_particip B ON B.membre=A.id WHERE B.annee=:an AND B.enfant=1) AS cpn_nbr;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Nombre de pays participants </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $pays_nbr;?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<?php /*
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Nombre de wilayas (S-M) </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['wil_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Nombre de communes de Béjaia (S-M) </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['com_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
*/?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 21Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['hmn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 21Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['fmn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Participants 21Km </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo ($donnee['hmn_nbr']+$donnee['fmn_nbr']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 7Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['hpn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> 7Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo $donnee['fpn_nbr'];?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Participants 7Km </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo ($donnee['hpn_nbr']+$donnee['fpn_nbr']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Total des participants </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo ($donnee['hmn_nbr']+$donnee['fmn_nbr']+$donnee['hpn_nbr']+$donnee['fpn_nbr']+$donnee['cpn_nbr']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php 
 // Moyenne d'ages
 $req = "SELECT
 (SELECT AVG(A.ageage) FROM member_particip A INNER JOIN member B ON B.id=A.membre WHERE A.annee=:an AND B.sex=1 AND A.course=1 AND A.time_course>0 AND A.dossard>0 AND A.ageage>0) AS hma_nbr, 
 (SELECT AVG(A.ageage) FROM member_particip A INNER JOIN member B ON B.id=A.membre WHERE A.annee=:an AND B.sex!=1 AND A.course=1 AND A.time_course>0 AND A.dossard>0 AND A.ageage>0) AS fma_nbr, 
 (SELECT AVG(A.ageage) FROM member_particip A INNER JOIN member B ON B.id=A.membre WHERE A.annee=:an AND B.sex=1 AND A.course=2 AND A.time_course>0 AND A.dossard>0 AND A.ageage>0) AS hpa_nbr, 
 (SELECT AVG(A.ageage) FROM member_particip A INNER JOIN member B ON B.id=A.membre WHERE A.annee=:an AND B.sex!=1 AND A.course=2 AND A.time_course>0 AND A.dossard>0 AND A.ageage>0) AS fpa_nbr;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
 if (!empty($donnee)) {
?>

 <br/>
 <div class="widget__header">
 <h3 class="widget__title">Moyenne d'ages</h3>
 </div>

 <table class="standings-league__table standings-table">
 <tbody class="standings-table__body">

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 21Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['hma_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 21Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['fma_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 7Km Hommes </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['hpa_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> Course 7Km Dames </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>

 <td class="table-stat-row table-stat-row--points"> <?php echo round($donnee['fpa_nbr']);?> ans </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php 
 }
 // Les plus agés
?>

 <br/>
 <div class="widget__header">
 <h3 class="widget__title">Les plus agés</h3>
 </div>

 <table class="standings-league__table standings-table">
 <thead class="standings-table__head">
 <tr>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Nom & Prénom</span>
 <span class="table-head__heading--short">Nom</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading"></span>
 <span class="table-head__heading--short"></span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Pays</span>
 <span class="table-head__heading--short">Pays</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Course</span>
 <span class="table-head__heading--short">Course</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Sexe</span>
 <span class="table-head__heading--short">Sexe</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Age</span>
 <span class="table-head__heading--short">Age</span>
 </th>
 <th class="table-head" scope="col">
 <span class="table-head__heading">Temps</span>
 <span class="table-head__heading--short">Tps</span>
 </th>
 </tr>
 </thead>
 <tbody class="standings-table__body">

<?php 
 $req = "
 SELECT A.nom, A.prenom, B.ageage, B.time_course, C.alpha2, C.nom_fr_fr AS pays 
 FROM member A 
 LEFT JOIN member_particip B ON B.membre=A.id LEFT JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND A.sex=1 AND B.course=1 AND B.time_course>0 AND B.dossard>0
 ORDER BY B.ageage DESC LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="badge-row" scope="row">
 <span class="badge-row__badge" title="<?php echo utf8_encode($donnee['pays']);?>">
 <span class="visually-hidden"><?php echo utf8_encode($donnee['pays']);?></span>
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo strtolower($donnee['alpha2']);?>.svg" width="30" height="30" alt="<?php echo utf8_encode($donnee['pays']);?>">
 </span>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Homme </td>
 <td class="table-stat-row "> <?php echo $donnee['ageage'];?> ans </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_course']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

<?php 
 $req = "
 SELECT A.nom, A.prenom, B.ageage, B.time_course, C.alpha2, C.nom_fr_fr AS pays 
 FROM member A 
 LEFT JOIN member_particip B ON B.membre=A.id LEFT JOIN ad_pays C ON C.id=A.payspy 
 WHERE B.annee=:an AND A.sex=0 AND B.course=1 AND B.time_course>0 AND B.dossard>0
 ORDER BY B.ageage DESC LIMIT 0,1;
 ";
 $arg = array('an'=>$__a);
 $donnee = $db->select($req, $arg, false);
?>
<tr class="table-standings-row">
 <td class="team-row" scope="row">
 <div class="team-row__name-container">
 <span class="team-row__name"> <?php echo utf8_encode($donnee['prenom'].' '.$donnee['nom']);?> </span>
 <span class="team-row__name--short"></span>
 </div>
 </td>
 <td class="badge-row" scope="row">
 <span class="badge-row__badge" title="<?php echo utf8_encode($donnee['pays']);?>">
 <span class="visually-hidden"><?php echo utf8_encode($donnee['pays']);?></span>
 <img src="<?php echo $config['app_url'] ?>sources/image/svg/flags/<?php echo strtolower($donnee['alpha2']);?>.svg" width="30" height="30" alt="<?php echo utf8_encode($donnee['pays']);?>">
 </span>
 </td>
 <td class="table-stat-row "> <?php echo utf8_encode($donnee['pays']);?> </td>
 <td class="table-stat-row "> 21km </td>
 <td class="table-stat-row "> Dame </td>
 <td class="table-stat-row "> <?php echo $donnee['ageage'];?> ans </td>
 <td class="table-stat-row table-stat-row--points"> <?php echo sectotime($donnee['time_course']);?> </td>
 <td class="standings-table__gap-filler"></td>
</tr>

 </tbody>
 </table>

<?php } ?>



 </section>
 </div>
 </section>
 </div>
 </div>
 </div>
 </main>
</div>

<?php include_once("sources/include/sponsors.php");?>

<?php $this->stopSection(); ?>

<?php /*-------------------------------------- Put here your additional CSS files for this page --------------------------------------*/ ?>
<?php $this->startSection('wisra_css_content'); ?>
 
<?php $this->stopSection(); ?>

<?php /*-------------------------------------- Put here your additional JS files  for this page --------------------------------------*/ ?>
<?php $this->startSection('wisra_js_content'); ?>
 
<?php $this->stopSection(); ?>
<?php if (@$_shouldextend[1]) { echo $this->runChild('layout', ['page_data' => array(
 'plugins' => array(), 
 'title' => "Récapitulatif | Semi Marathon International de Béjaia", 
 'description' => "Récapitulatif, Semi Marathon International de la ville de Béjaia: course 21km, 7km et 3km pour enfants, handisports. organisé par l'Athlétic Méditerranéen Club Béjaia AMCB chaque année, a la vile de Béjaia - Algérie", 
 'keywords' => array("Récapitulatif", "Recapitulatif", "Récapitulatif Semi Marathon Bejaia", "Semi Marathon International de la ville de Béjaia", "Semi Marathon International de Béjaia", "Semi Marathon Béjaia", "SemiMarathon Béjaia", "Demi Marathon Béjaia", "Semi Marathon International Bejaia", "Semi", "Marathon", "Semi-Marathon", "International", "Semi-Marathon International", "Béjaia", "Semi-Marathon International Béjaia", "course 21km", "course 7km", "course 3km", "course enfants", "course handisports", "Athlétic Méditerranéen Club Béjaia", "Athlétic Club", "Athlétic Club Béjaia",  "Athlétic Méditerranéen Club Béjaia", "AMCB", "la vile de Béjaia", "Algérie", "Béjaia Algérie"), 
 'facebook_integration' => false, 
 'google_maps_callback' => '', 
 'filters_header' => 1, 
 'filter_year' => $__a, 
 'filter_link' => 'recapitulatif'
)]); } ?>