<?php
/***************************************************************************
recherches.php - description
-------------------
copyright : (C) 2002 by Cédric Rochat
email : hide@address.com
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
require ("util.php");
if (!$IDDVD) echo "<center><h1>Recherches avancées</h1></center><hr>";
if ($erase) $condition='false';
if ($condition=='true')
{
if ($IDDVD!="")
{ // Accès direct à la fiche du DVD
$connexion = Connexion (NOM, PASSE, BASE, SERVEUR);
$request = ExecRequete ("SELECT IDDVD FROM $pTable_Prefixe"."DVD WHERE IDDVD=$IDDVD", BASE);
//$request_executed = mysql_fetch_array($request);
$TestExistence=mysql_num_rows($request);
if ($TestExistence==0) echo "<table width='100%' border='0' valign='top'><br><br><tr><td><center><h2>Ce DVD n'existe pas !!</h2><br><a href='index.php?sousPage=recherches.php'>Retour</a></center></td></tr></table>";
else include ("ficheDVD.php");
}
else
{ // Jointures
$connexion = Connexion (NOM, PASSE, BASE, SERVEUR);
if (($acteur=="") and ($realisateur==""))
{
$requete_PartiePrincipale=" FROM
$pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie
WHERE Duree BETWEEN '$duree_min_heures:$duree_min_minutes' AND '$duree_max_heures:$duree_max_minutes'";
}
if (($acteur=="") and ($realisateur!=""))
{
$requete_PartiePrincipale=" FROM
$pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie,
$pTable_Prefixe"."RealisateursDVD LEFT JOIN $pTable_Prefixe"."Realisateurs ON $pTable_Prefixe"."RealisateursDVD.IDRealisateur=$pTable_Prefixe"."Realisateurs.IDRealisateur
WHERE $pTable_Prefixe"."DVD.IDDVD=$pTable_Prefixe"."RealisateursDVD.IDDVD
AND Duree BETWEEN '$duree_min_heures:$duree_min_minutes' AND '$duree_max_heures:$duree_max_minutes'";
}
if (($acteur!="") and ($realisateur==""))
{
$requete_PartiePrincipale=" FROM
$pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie,
$pTable_Prefixe"."ActeursDVD LEFT JOIN $pTable_Prefixe"."Acteurs ON $pTable_Prefixe"."ActeursDVD.IDActeur=$pTable_Prefixe"."Acteurs.IDActeur
WHERE $pTable_Prefixe"."DVD.IDDVD=$pTable_Prefixe"."ActeursDVD.IDDVD
AND Duree BETWEEN '$duree_min_heures:$duree_min_minutes' AND '$duree_max_heures:$duree_max_minutes'";
}
if (($acteur!="") and ($realisateur!=""))
{
$requete_PartiePrincipale=" FROM
$pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie,
$pTable_Prefixe"."ActeursDVD LEFT JOIN $pTable_Prefixe"."Acteurs ON $pTable_Prefixe"."ActeursDVD.IDActeur=$pTable_Prefixe"."Acteurs.IDActeur,
$pTable_Prefixe"."RealisateursDVD LEFT JOIN $pTable_Prefixe"."Realisateurs ON $pTable_Prefixe"."RealisateursDVD.IDRealisateur=$pTable_Prefixe"."Realisateurs.IDRealisateur
WHERE $pTable_Prefixe"."DVD.IDDVD=$pTable_Prefixe"."ActeursDVD.IDDVD
AND $pTable_Prefixe"."DVD.IDDVD=$pTable_Prefixe"."RealisateursDVD.IDDVD
AND Duree BETWEEN '$duree_min_heures:$duree_min_minutes' AND '$duree_max_heures:$duree_max_minutes'";
}
if ($acteur!="")
{
if ($choixRecherche==1) $acteur_search_request1="NomPrenomActeur, "; else $acteur_search_request1=", NomPrenomActeur";
$acteur_search_request2=", $pTable_Prefixe"."ActeursDVD.IDActeur";
}
else
{
if ($choixRecherche==1)
{
$choixRecherche=0;
echo "<h2>Votre choix de chercher un acteur n'a pas été pris en compte, car le champ correspondant était vide !!</h2>";
}
if ($choixTri==1)
{
$choixTri=0;
echo "<h2>Votre choix de trier par acteurs n'a pas été pris en compte, car le champ correspondant était vide !!</h2>";
}
}
if ($realisateur!="")
{
if ($choixRecherche==2) $realisateur_search_request1="NomPrenomRealisateur, "; else $realisateur_search_request1=", NomPrenomRealisateur";
$realisateur_search_request2=", $pTable_Prefixe"."RealisateursDVD.IDRealisateur";
}
else
{
if ($choixRecherche==2)
{
$choixRecherche=0;
echo "<h2>Votre choix de chercher un réalisateur n'a pas été pris en compte, car le champ correspondant était vide !!</h2>";
}
if ($choixTri==2)
{
$choixTri=0;
echo "<h2>Votre choix de trier par réalisateurs n'a pas été pris en compte, car le champ correspondant était vide !!</h2>";
}
}
switch ($choixRecherche)
{
case 0 :
$requete_choixRecherche="SELECT $pTable_Prefixe"."DVD.IDDVD, Titre, Duree, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie $acteur_search_request1 $realisateur_search_request1 $acteur_search_request2 $realisateur_search_request2";
break;
case 1 :
$requete_choixRecherche="SELECT $acteur_search_request1 $pTable_Prefixe"."DVD.IDDVD, Titre, Duree, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie $realisateur_search_request1 $acteur_search_request2 $realisateur_search_request2";
break;
case 2 :
$requete_choixRecherche="SELECT $realisateur_search_request1 $pTable_Prefixe"."DVD.IDDVD, Titre, Duree, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie $acteur_search_request1 $acteur_search_request2 $realisateur_search_request2";
}
if ($dvd!="") $requete_filtre = " AND Titre LIKE '%$dvd%'";
if ($acteur!="") $requete_filtre = $requete_filtre." AND NomPrenomActeur LIKE '%$acteur%'";
if ($realisateur!="") $requete_filtre = $requete_filtre." AND NomPrenomRealisateur LIKE '%$realisateur%'";
if ($categorie!="") $requete_filtre = " AND NomCategorie LIKE '%$categorie%'";
switch ($choixTri)
{
case 0 :
$requete_choixTri=" ORDER BY Titre";
break;
case 1 :
$requete_choixTri=" ORDER BY NomPrenomActeur";
break;
case 2 :
$requete_choixTri=" ORDER BY NomPrenomRealisateur";
break;
case 3 :
$requete_choixTri=" ORDER BY Duree";
break;
case 4 :
$requete_choixTri=" ORDER BY NomCategorie";
}
if ($ordreTri==0) $requete_ordreTri=" ASC";
else $requete_ordreTri=" DESC";
$requete=$requete_choixRecherche.$requete_PartiePrincipale.$requete_filtre.$requete_choixTri.$requete_ordreTri;
$nombre_limite=$NombreEnregistrementsLimiteAdmin;
if (!$debut)
{
$debut=0;
$request = ExecRequete ($requete, BASE);
$Record_count=mysql_num_rows($request);
}
if ($debut >= $nombre_limite)
{
$valideprev=1;
$debutprecedent=$debut-$nombre_limite;
}
else $valideprev=0;
if (($debut+$nombre_limite) > $Record_count) $validenext=0;
else
{
$validenext=1;
$debutsuivant=$debut+$nombre_limite;
}
$requete_limite=$requete." LIMIT $debut, $nombre_limite";
$request = ExecRequete ($requete_limite, BASE);
switch ($Record_count)
{
case 0 :
$Record_count_text = "Il n'y a aucun enregistrement correspondant à votre recherche";
break;
case 1 :
$Record_count_text = "Il y a <I>$Record_count </I> enregistrement correspondant à votre recherche";
break;
default :
$Record_count_text = "Il y a <I>$Record_count </I> enregistrements correspondant à votre recherche";
}
$font_begin="<font color='#FF0A3B' face='Arial, Helvetica, sans-serif' size='2'>";
$font_end="</font>";
$ligne_numerotation="<td bgcolor='$color_frame' width='9%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> Numérotation</b></font></td>";
$ligne_IDDVD="<td bgcolor='$color_frame' width='5%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> ID DVD</b></font></td>";
$ligne_titre="<td bgcolor='$color_frame' width='40%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> Titre du film</b></font></td>";
$ligne_duree="<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> Durée</b></font></td>";
$ligne_categorie="<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> Catégorie</b></font></td>";
if ($acteur!="") $ligne_acteur="<td bgcolor='$color_frame' width='13%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> Acteur</b></font></td>";
if ($realisateur!="") $ligne_realisateur="<td bgcolor='$color_frame' width='13%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'> Réalisateur</b></font></td>";
switch ($choixRecherche)
{
case 0 :
$entete=$ligne_numerotation.$ligne_IDDVD.$ligne_titre.$ligne_duree.$ligne_categorie.$ligne_acteur.$ligne_realisateur;
break;
case 1 :
$entete=$ligne_numerotation.$ligne_acteur.$ligne_IDDVD.$ligne_titre.$ligne_duree.$ligne_categorie.$ligne_realisateur;
break;
case 2 :
$entete=$ligne_numerotation.$ligne_realisateur.$ligne_IDDVD.$ligne_titre.$ligne_duree.$ligne_categorie.$ligne_acteur;
}
$pages_tot=$Record_count/$nombre_limite;
if ($pages_tot > floor($pages_tot)) $pages_tot=floor($pages_tot)+1;
$page_actuelle=floor($debut/$nombre_limite)+1;
echo " <table width='100%' border=0 cellspacing=1 cellpadding=1>
<TR>
<TD vAlign=top><BR><B>$Record_count_text</B>
</TD>
<td align='right'>
<table border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='right'><b>"; if ($pages_tot > 1) echo "$page_actuelle/$pages_tot"; echo "</b></td>
<td align='right'>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>
<form name=precedents action='index.php?sousPage=recherches.php'>";
if ($valideprev == 1)
{
echo "<input type=hidden name=sousPage value='recherches.php'>
<input type=hidden name=debut value=$debutprecedent>
<input type=hidden name=condition value='true'>
<input type=hidden name=Record_count value=$Record_count>
<input type=hidden name=choixRecherche value=$choixRecherche>
<input type=hidden name=dvd value=$dvd>
<input type=hidden name=acteur value=$acteur>
<input type=hidden name=realisateur value=$realisateur>
<input type=hidden name=categorie value=$categorie>
<input type=hidden name=duree_min_heures value=$duree_min_heures>
<input type=hidden name=duree_min_minutes value=$duree_min_minutes>
<input type=hidden name=duree_max_heures value=$duree_max_heures>
<input type=hidden name=duree_max_minutes value=$duree_max_minutes>
<input type=hidden name=choixTri value=$choixTri>
<input type=hidden name=ordreTri value=$ordreTri>
<input type=image border='0' src='images/prev.gif'>";
}
else
{
if ($pages_tot > 1) echo "<img border='0' src='images/prevdis.gif'>";
}
echo "</form></td>
<td>
<form name=suivants action='index.php?sousPage=recherches.php'>";
if ($validenext == 1)
{
echo "<input type=hidden name=sousPage value='recherches.php'>
<input type=hidden name=debut value=$debutsuivant>
<input type=hidden name=condition value='true'>
<input type=hidden name=Record_count value=$Record_count>
<input type=hidden name=choixRecherche value=$choixRecherche>
<input type=hidden name=dvd value=$dvd>
<input type=hidden name=acteur value=$acteur>
<input type=hidden name=realisateur value=$realisateur>
<input type=hidden name=categorie value=$categorie>
<input type=hidden name=duree_min_heures value=$duree_min_heures>
<input type=hidden name=duree_min_minutes value=$duree_min_minutes>
<input type=hidden name=duree_max_heures value=$duree_max_heures>
<input type=hidden name=duree_max_minutes value=$duree_max_minutes>
<input type=hidden name=choixTri value=$choixTri>
<input type=hidden name=ordreTri value=$ordreTri>
<input type=image border='0' src='images/next.gif'>";
}
else
{
if ($pages_tot > 1) echo "<img border='0' src='images/nextdis.gif'>";
}
echo "</form></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</TR>
</table>";
if($Record_count!=0)
{
echo "
<table width='100%' border=0 cellspacing=1 cellpadding=1>
<tr>
$entete
</tr>
<tr><td colspan=7><hr></td></tr>";
$font_begin="<font color='#FF0A3B' face='Arial, Helvetica, sans-serif' size='2'>";
$font_end="</font>";
$DVD_count=$debut;
while ($rowList = mysql_fetch_array ($request))
{
$href_begin ="";
$href_end ="";
$DVD_count++;
switch ($choixRecherche)
{
case 0 :
$listing_numerotation="<td width='9%'>$font_begin <B>$DVD_count</B> $font_end</td>";
$listing_IDDVD="<td width='5%'><font color='#000000' face='Arial, Helvetica, sans-serif' size='2'>$rowList[0] $font_end</td>";
$rowList[1]=nbsp($rowList[1]);
$listing_titre="<td width='40%'>$font_begin <a href='index.php?IDDVD=$rowList[0]&sousPage=ficheDVD.php'>$rowList[1]</a>$font_end</td>";
$listing_duree="<td width='10%'>$font_begin $rowList[2] $font_end</td>";
$rowList[3]=nbsp($rowList[3]);
$listing_categorie="<td width='10%'>$font_begin <a href='index.php?IDCategorie=$rowList[4]&sousPage=categories.php'>$rowList[3]</a> $font_end</td>";
if ($acteur!="")
{
$rowList[5]=nbsp($rowList[5]);
if ($realisateur!="") $listing_acteur="<td width='13%'>$font_begin <a href='index.php?IDActeur=$rowList[7]&sousPage=acteurs.php'>$rowList[5]</a>$font_end</td>";
else $listing_acteur="<td width='13%'>$font_begin <a href='index.php?IDActeur=$rowList[6]&sousPage=acteurs.php'>$rowList[5]</a>$font_end</td>";
}
if ($realisateur!="")
{
if ($acteur!="") { $rowList[6]=nbsp($rowList[6]); $listing_realisateur="<td width='13%'>$font_begin <a href='index.php?IDRealisateur=$rowList[8]&sousPage=realisateurs.php'>$rowList[6]</a>$font_end</td>";}
else { $rowList[5]=nbsp($rowList[5]); $listing_realisateur="<td width='13%'>$font_begin <a href='index.php?IDRealisateur=$rowList[6]&sousPage=realisateurs.php'>$rowList[5]</a>$font_end</td>";}
}
$listing=$listing_numerotation.$listing_IDDVD.$listing_titre.$listing_duree.$listing_categorie.$listing_acteur.$listing_realisateur;
break;
case 1 :
$listing_numerotation="<td width='9%'>$font_begin <B>$DVD_count</B> $font_end</td>";
$listing_IDDVD="<td width='5%'><font color='#000000' face='Arial, Helvetica, sans-serif' size='2'>$rowList[1] $font_end</td>";
$rowList[2]=nbsp($rowList[2]);
$listing_titre="<td width='40%'>$font_begin <a href='index.php?IDDVD=$rowList[1]&sousPage=ficheDVD.php'>$rowList[2]</a>$font_end</td>";
$listing_duree="<td width='10%'>$font_begin $rowList[3] $font_end</td>";
$rowList[4]=nbsp($rowList[4]);
$listing_categorie="<td width='10%'>$font_begin <a href='index.php?IDCategorie=$rowList[5]&sousPage=categories.php'>$rowList[4]</a> $font_end</td>";
if ($acteur!="")
{
$rowList[0]=nbsp($rowList[0]);
if ($realisateur!="") $listing_acteur="<td width='13%'>$font_begin <a href='index.php?IDActeur=$rowList[7]&sousPage=acteurs.php'>$rowList[0]</a>$font_end</td>";
else $listing_acteur="<td width='13%'>$font_begin <a href='index.php?IDActeur=$rowList[6]&sousPage=acteurs.php'>$rowList[0]</a>$font_end</td>";
}
if ($realisateur!="") { $rowList[6]=nbsp($rowList[6]); $listing_realisateur="<td width='13%'>$font_begin <a href='index.php?IDRealisateur=$rowList[8]&sousPage=realisateurs.php'>$rowList[6]</a>$font_end</td>";}
$listing=$listing_numerotation.$listing_acteur.$listing_IDDVD.$listing_titre.$listing_duree.$listing_categorie.$listing_realisateur;
break;
case 2 :
$listing_numerotation="<td width='9%'>$font_begin <B>$DVD_count</B> $font_end</td>";
$listing_IDDVD="<td width='5%'><font color='#000000' face='Arial, Helvetica, sans-serif' size='2'>$rowList[1] $font_end</td>";
$rowList[2]=nbsp($rowList[2]);
$listing_titre="<td width='40%'>$font_begin <a href='index.php?IDDVD=$rowList[1]&sousPage=ficheDVD.php'>$rowList[2]</a>$font_end</td>";
$listing_duree="<td width='10%'>$font_begin $rowList[3] $font_end</td>";
$rowList[4]=nbsp($rowList[4]);
$listing_categorie="<td width='10%'>$font_begin <a href='index.php?IDCategorie=$rowList[5]&sousPage=categories.php'>$rowList[4]</a> $font_end</td>";
if ($acteur!="") { $rowList[6]=nbsp($rowList[6]); $listing_acteur="<td width='13%'>$font_begin <a href='index.php?IDActeur=$rowList[7]&sousPage=acteurs.php'>$rowList[6]</a>$font_end</td>";}
if ($realisateur!="")
{
$rowList[0]=nbsp($rowList[0]);
if ($acteur!="") $listing_realisateur="<td width='13%'>$font_begin <a href='index.php?IDRealisateur=$rowList[8]&sousPage=realisateurs.php'>$rowList[0]</a>$font_end</td>";
else $listing_realisateur="<td width='13%'>$font_begin <a href='index.php?IDRealisateur=$rowList[6]&sousPage=realisateurs.php'>$rowList[0]</a>$font_end</td>";
}
$listing=$listing_numerotation.$listing_realisateur.$listing_IDDVD.$listing_titre.$listing_duree.$listing_categorie.$listing_acteur;
}
echo " <tr>
$listing
</tr>";
}
if ($Record_count!=0) echo "</table>";
echo "<hr>";
}
}
}
else
{
$connexion = Connexion (NOM, PASSE, BASE, SERVEUR);
// Liste de toutes les catégories
$resultat=ExecRequete("SELECT NomCategorie FROM $pTable_Prefixe"."Categories ORDER BY NomCategorie ASC", BASE);
$nbLignes=mysql_num_rows($resultat);
for ($i=0; $i<$nbLignes; $i++)
{
$temp=mysql_fetch_object($resultat);
$ListeCategories[$i]=$temp->NomCategorie;
}
echo "<h3>Vous pouvez afficher tous les acteurs, ou tous les réalisateurs, en mettant '%' dans le champ correspondant, mais nottez que certaines recherches risquent d'afficher plusieurs fois le même DVD !! Vous pouvez également atteindre directement une fiche de DVD avec son identifiant unique (IDDVD).</h3>";
$form = new Formulaire ("POST", "index.php?sousPage=recherches.php");
$form->debutTable();
$listSearch1 = array ("DVD", "acteur", "réalisateur");
$form->champRadio ("Vous cherchez un : ", "choixRecherche", "0", $listSearch1);
$form->finTable();
$form->debutTable();
$form->champTexte ("ID DVD", "IDDVD", "", 4, 10);
$form->champTexte ("Titre du DVD", "dvd", "", 60, 100);
$form->champTexte ("Nom et/ou prénom d'un acteur", "acteur", "", 40, 50);
$form->champTexte ("Nom et/ou prénom d'un réalisateur", "realisateur", "", 40, 50);
$form->champListe("Catégorie", "categorie", "", 1, $ListeCategories);
$form->finTable();
$listeHeures = array ("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23");
$listeMinutes = array ("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "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", "59");
$form->debutTable("HORIZONTAL", 1);
$form->champListe("Durée min.", "duree_min_heures", "00", 1, $listeHeures);
$form->champListe("", "duree_min_minutes", "00", 1, $listeMinutes);
$form->finTable();
$form->debutTable("HORIZONTAL", 1);
$form->champListe("Durée max.", "duree_max_heures", "23", 1, $listeHeures);
$form->champListe("", "duree_max_minutes", "59", 1, $listeMinutes);
$form->finTable();
$form->debutTable();
$listSearch2 = array ("DVDs", "acteurs", "réalisateurs", "durée", "catégorie");
$form->champRadio ("Trier par : ", "choixTri", "0", $listSearch2);
$form->finTable();
$form->debutTable();
$listSearch3 = array ("croissant", "décroissant");
$form->champRadio ("Ordre du tri : ", "ordreTri", "0", $listSearch3);
$form->finTable();
$form->debutTable("HORIZONTAL", 1);
$form->champValider ("Lancer la recherche", "search");
$form->champValider ("Effacer", "erase");
$form->champCache ("condition", "true");
$form->finTable();
$form->fin();
}
?>