<?php
/*if ( !isset($site) )
{
    require_once( "../include/config.inc.php" );
    print "accueil =>" . $accueil;
	header( 'Location:  ' . $accueil );
}*/
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'envoi_courriel.inc.php';
require_once 'log.php';
print '
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Administration</title>
	<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
	<!-- CSS -->
	<link href="../src/app.css" rel="stylesheet">
	<!-- navbar -->
	<nav class="navbar navbar-expand-md fixed-top navbar-light bg-light">
      <a class="navbar-brand" href="#">Avions Poèmes</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarCollapse">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item">
            <a class="nav-link" href="#">Anthologie</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#" data-toggle="modal" data-target="#aboutModal" >À propos</a>
          </li>
        </ul>
      </div>
    </nav>
</head>
<body>';


verifPeripetieAvion();

function verifAvionpoeme()
{
	$query = "SELECT * FROM avionpoeme";
	$db->query($query);
	$avions = $db->result->fetch_all(MYSQLI_ASSOC);
	foreach($avions as $avion)
	{

	}
	return $fresult;
}

function verifPeripetieAvion()
{
	print "Vérification des liens péripétie/avionpoème" . EOLH;
	$db = new db();
	// requête Mysql
	$query = "SELECT * FROM avionPeripetie";
	$db->query($query);
	$peripeties = $db->result->fetch_all(MYSQLI_ASSOC);

	$query = "SELECT * FROM avionpoeme";
	$db->query($query);
	$avions = $db->result->fetch_all(MYSQLI_ASSOC);
	$avionsId = array_column($avions, 'expeMail', 'idAvion');
	print_r($avionsId);
	foreach($peripeties as $peripetie)
	{
		print "Péripétie " . $peripetie["idAP"] . EOLH;
		$idAvion = $peripetie["idAvion"];
		if ( empty($avionsId[$idAvion]) )
		{
			print "Péripétie " . $peripetie["idAP"] . " n'a pas d'avion poème idAvion=>" . $idAvion . EOLH;
		}
	}
	$db->close();
}
print "</body></html>";
?>
