public function noteUtilisateur($trajet, $utilisateur) { //Recupération des infos trajets $database = UsineBDD::getUsine()->connection(); $info_t = Trajet::getInformationTrajet($trajet)[0]; $conducteur = Utilisateur::getUtilisateurId(); $note = intval($_POST['note']); $isPassagerTrajet = false; //On vérifie que le passager fait partie du trajet foreach (Reservation::getUtilisateurReservation($trajet) as $array => $reservation) { if ($reservation['id_membre'] == $utilisateur) { $isPassagerTrajet = true; } } if ($utilisateur == $conducteur) { $this->_erreurs[] = "Vous ne pouvez pas noter votre propre trajet"; } else { if (!Trajet::isTrajetValide($info_t['id'])) { $this->_erreurs[] = "Vous ne pouvez pas noter un trajet non validé"; } else { if (self::isNoteExisteU($info_t['id'], $utilisateur)) { $this->_erreurs[] = "Vous avez dejà noté cette personne sur ce trajet"; } else { if (!$isPassagerTrajet) { $this->_erreurs[] = "Le passager ne fait pas partie de ce trajet"; } else { if ($note <= 0 || $note > 5) { $this->_erreurs[] = "Votre note doit être compris en 1 et 5"; } else { $sql = "INSERT INTO note VALUES('',:idm,:idn,:idt,:n)"; $requete = $database->prepare($sql); $requete->execute(array(':idm' => $info_t['id_conducteur'], ':idn' => $utilisateur, ':idt' => $info_t['id'], ':n' => $note)); $_confirm = "Vous avez bien noté le passager"; } } } } } }
$html .= '<div class="liste_reservation"> <table class="pure-table pure-table-bordered"><thead> <tr> <th> Reservation </th> <th> Nombre de place prise</th> <th> Note </th></tr> </thead>'; foreach ($reservations as $array => $reservation) { //Notation $notation = array(5 => 'Amazing!', 4 => 'Super bon', 3 => 'Ca peut aller', 2 => 'Peut mieux faire', 1 => 'Ca fait mal'); $notation_select = '<form method="POST" action="/Controller/ProfilController.php?context=trajets&id_trajet=' . $info_trajet['id'] . '&id_u=' . $reservation['id_membre'] . '"><select name="note">'; foreach ($notation as $note => $description) { $notation_select .= '<option value="' . $note . '">' . $note . '-' . $description . '</option>'; } $notation_select .= '</select> <button type="submit" class="button-success pure-button" name="confirmation_note"><i class="fa fa-thumbs-up"></i> Note</button></form></form>'; $notation_r = Trajet::isTrajetValide($info_trajet['id']) ? $notation_select : 'Vous ne pouvez pas noter un trajet non valide'; $notation_r = Note::isNoteExisteU($info_trajet['id'], $reservation['id_membre']) ? 'Vous avez noté cette personne' : $notation_r; $html .= '<tbody><tr> <td><a href="/Controller/ProfilController.php?context=profil&id_membre=' . $reservation['id_membre'] . '">' . Utilisateur::getUsername($reservation['id_membre']) . ' <a href="/Controller/MessageController.php?context=envoie&id_membre=' . $reservation['id_membre'] . '"><img src="/image/mail.png" alt="Message"/></a></td>'; $html .= '<td>' . Reservation::getNombrePlaceReserve($info_trajet['id'], $reservation['id_membre']) . '</td>'; $html .= '<td>' . $notation_r . '</td></tr>'; } if (!Trajet::isTrajetValide($info_trajet['id'])) { $html .= '<tr> <td colspan="4"><a class="button-validation pure-button" href="/Controller/ProfilController.php?context=trajets&id_trajet=' . $info_trajet['id'] . '&validation_trajet=1"> Validation du trajet </a></td> </tr>'; $html .= '<tr> <td colspan="4"> <a class="button-warning pure-button" href="/Controller/ProfilController.php?context=trajets&id_trajet=' . $info_trajet['id'] . '&annulation_trajet=1"> Annuler le trajet </a></tr>'; } else { $html .= '<tr> <td colspan="4"> Trajet Validé </td></tr>'; } $html .= '</tbody></table> </div>'; } elseif (count($reservations) == 0 && count($info_trajet) != 0) { $html .= '<div class="erreur"><p> Il n\' y a aucune réservation sur ce trajet </p></div>'; } } elseif (isset($_GET['id_trajet']) && !empty(trim($_GET['id_trajet'])) && !Trajet::trajetExiste($_GET['id_trajet'])) { $html .= "<p> Ce trajet n'existe plus !</p>"; } else { $trajets = Trajet::getAllTrajetConducteur(); if (count($trajets) != 0) { foreach ($trajets as $array => $trajet) {
echo $error; } } } $html = '<div class="liste_reservation_L">'; if (count($reservations) != 0) { $html .= '<table class="pure-table pure-table-bordered"><thead><tr><th> Conducteur </th> <th> Trajet </th> <th> Date </th> <th>Prix </th> <th> Nombre de place prise </th> <th> Note </th></tr></thead><tbody>'; foreach ($reservations as $array => $reservation) { $info_trajet = Trajet::getInformationTrajet($reservation['id_trajet'])[0]; $notation = array(5 => 'Amazing!', 4 => 'Super bon', 3 => 'Ca peut aller', 2 => 'Peut mieux faire', 1 => 'Ca fait mal'); $notation_select = '<form method="POST" action="/Controller/ProfilController.php?context=reservations&id_trajet=' . $info_trajet['id'] . '"><select name="note">'; foreach ($notation as $note => $description) { $notation_select .= '<option value="' . $note . '">' . $note . '-' . $description . '</option>'; } $notation_select .= '</select> <button type="submit" class="button-success pure-button" name="confirmation_note"><i class="fa fa-thumbs-up"></i> Note</button></form>'; $notation_r = Trajet::isTrajetValide($reservation['id_trajet']) ? $notation_select : 'Vous ne pouvez pas noter un trajet non valide'; $notation_r = Note::isNoteExiste($info_trajet['id']) ? 'Vous avez noté cette personne' : $notation_r; $date = date('d-n-Y H:i', $info_trajet['timestamp_trajet']); $html .= '<tr><td><a href="/Controller/ProfilController.php?context=profil&id_membre=' . $info_trajet['id_conducteur'] . '">' . Utilisateur::getUsername($info_trajet['id_conducteur']) . '<a href="/Controller/MessageController.php?context=envoie&id_membre=' . $info_trajet['id_conducteur'] . '"><img src="/image/mail.png" alt="Message"/></a></td>'; $html .= '<td>' . ucfirst($info_trajet['ville_depart']) . ' - ' . ucfirst($info_trajet['ville_arrive']) . '</td>'; $html .= '<td>' . $date . '</td>'; $html .= '<td>' . $info_trajet['prix'] . '</td>'; $html .= '<td>' . $reservation['nb_place'] . '</td>'; $html .= '<td>' . $notation_r . '</td></tr>'; } $html .= '</tbody></table>'; } else { $html .= '<div class="erreur"><p> Vous n\'avez pas de réservations pour le moment</p></div>'; } $html .= '</div>'; echo $html;