@ -36,4 +35,81 @@ function checkVoiture($db, $mail, $matricule){
$result = pg_query_params($db, "SELECT matricule From Voiture WHERE mail = $1 AND matricule = $2;", array($mail, $matricule));
$result = pg_query_params($db, "SELECT matricule From Voiture WHERE mail = $1 AND matricule = $2;", array($mail, $matricule));
$row = pg_fetch_array($result);
$row = pg_fetch_array($result);
return !strcmp($matricule, $row[0]);
return !strcmp($matricule, $row[0]);
}
}
function getTrajetsProposes($db, $mail){
$result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
return $row[0];
}
return 0;
}
function getTrajetsReserves($db, $mail){
$result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND etatres != 'Annulée' AND estAnnule = false AND datedepart >= current_date;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
return $row[0];
}
return 0;
}
function getMessagesNonLus($db, $mail){
$result = pg_query_params($db, "SELECT COUNT(*) from Message WHERE mailRecepteur = $1 AND estLu = FALSE;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
$login = $row[0];
return $login;
}
}
function getAvisNonLus($db, $mail){
global $db;
$result = pg_query_params($db, "SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
$login = $row[0];
return $login;
}
}
//Récupérer la liste des voitures concernant un utilisateur
function getListeVoitures($db, $mail){
$result = pg_query_params($db, "SELECT * FROM Voiture WHERE mail = $1;", array($mail));
$result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
return $row[0];
}
return 0;
}
function getTrajetsReserves($db, $mail){
$result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND etatres != 'Annulée' AND estAnnule = false AND datedepart >= current_date;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
return $row[0];
}
return 0;
}
function getMessagesNonLus($db, $mail){
$result = pg_query_params($db, "SELECT COUNT(*) from Message WHERE mailRecepteur = $1 AND estLu = FALSE;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
$login = $row[0];
return $login;
}
}
function getAvisNonLus($db, $mail){
global $db;
$result = pg_query_params($db, "SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;", array($mail));
if ($result) {
$row = pg_fetch_array($result);
$login = $row[0];
return $login;
}
}
//Si on est pas connecté redirection vers la page de connexion