Exemple #1
0
 public function validationTrajet($id_trajet)
 {
     $database = UsineBDD::getUsine()->connection();
     $info_trajet = self::getInformationTrajet($id_trajet)[0];
     if (Utilisateur::getUtilisateurId() == $info_trajet['id_conducteur'] && $info_trajet['validation'] == 0) {
         $passagers = Reservation::getUtilisateurReservation($id_trajet);
         $prix_g = 0;
         foreach ($passagers as $array => $passager) {
             $prix = $info_trajet['prix'] * Reservation::getNombrePlaceReserve($info_trajet['id'], $passager['id_membre']);
             $prix_g += $prix;
             Utilisateur::retirerSolde($prix, $passager['id_membre']);
             Utilisateur::ajouterSolde($prix, $info_trajet['id_conducteur']);
         }
         $sql_update_trajet = "UPDATE trajet SET validation = 1 WHERE id=:idt";
         $requete_update = $database->prepare($sql_update_trajet);
         $requete_update->execute(array(':idt' => $id_trajet));
         Utilisateur::ajoutTrajetV();
         $this->confirmation = "Le trajet a bien été validé! " . $prix_g . "€ ont été ajouté sur votre compte";
     }
 }
Exemple #2
0
    $info_trajet = Trajet::getInformationTrajet($_GET['id_trajet'])[0];
    $reservations = Reservation::getUtilisateurReservation($info_trajet['id']);
    if (count($reservations) != 0 && count($info_trajet) != 0) {
        $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 {