export_adherent.php 2.02 KB
Newer Older
JonathanMM's avatar
JonathanMM committed
1 2
<?php
session_start();
3
require_once('prelude_page.php');
JonathanMM's avatar
JonathanMM committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
$string = <<<XML
<?xml version="1.0"?>
<kyon version="1.0">
</kyon>
XML;
$xml_retour = simplexml_load_string($string);
$xml_retour->addChild('adherents');
$requete = mysql_query('SELECT * FROM '.$bdd_prefixe.'adherents');
if(!($requete === false))
{
	while($donnees = mysql_fetch_array($requete))
	{
		$adherent = $xml_retour->adherents->addChild('adherent');
		$adherent->addAttribute('id', $donnees['id']);
		$adherent->addAttribute('prenom', $donnees['prenom']);
		$adherent->addAttribute('nom', $donnees['nom']);
		$adherent->addAttribute('adresse', $donnees['adresse']);
		$adherent->addAttribute('telephone', $donnees['telephone']);
		$adherent->addAttribute('courriel', $donnees['courriel']);
		$adherent->addAttribute('id_titre', $donnees['titre']);
		$adherent->addAttribute('date_inscription', $donnees['date_inscription']);
		$adherent->addAttribute('date_fin_cotisation', $donnees['date_fin_cotisation']);
		$requete2 = mysql_query('SELECT *, e.id AS id, e.prenom AS prenom, e.nom AS nom, a.prenom AS prenom_intervenant, a.nom AS nom_intervenant FROM '.$bdd_prefixe.'enfants e LEFT JOIN '.$bdd_prefixe.'adherents a ON a.id = e.id_intervenant WHERE id_parent = '.$donnees['id']);
		if(!($requete2 === false))
		{
			while($donnees2 = mysql_fetch_array($requete2))
			{
				$enfant = $adherent->addChild('enfant');
				$enfant->addAttribute('id', $donnees2['id']);
				$enfant->addAttribute('prenom', $donnees2['prenom']);
				$enfant->addAttribute('nom', $donnees2['nom']);
			}
		}
	}
}

$requete = mysql_query('SELECT * FROM '.$bdd_prefixe.'titre');
$xml_retour->addChild('titres');
if(!($requete === false))
{
	while($donnees = mysql_fetch_array($requete))
	{
		$titre = $xml_retour->titres->addChild('titre');
		$titre->addAttribute('id', $donnees['id']);
		$titre->addAttribute('nom', $donnees['nom']);
	}
}

header('Content-Transfer-Encoding: binary');
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename="kyon.xml"');

echo $xml_retour->asXML();
mysql_close();
?>