public function searchAction(Request $request, $page = 1)
 {
     $depart = $request->query->get('depart');
     $arrive = $request->query->get('arrive');
     $date = $request->query->get('date');
     $criteria = array('idDepart' => $depart, 'idArrive' => $arrive, 'horaire' => $date);
     $maxPerPage = $this->container->getParameter('max_per_page');
     $listOffres = $this->getDoctrine()->getRepository('CovoiturageFrontendBundle:Voyage')->searchVoyages($criteria, $page, $maxPerPage);
     $voyagesCount = $this->getDoctrine()->getRepository('CovoiturageFrontendBundle:Voyage')->countVoyagesSearch($criteria);
     $pagination = array('page' => $page, 'route' => 'covoiturage_frontend_search', 'pages_count' => ceil($voyagesCount / $maxPerPage), 'route_params' => array('page' => $page, 'depart' => $depart, 'arrive' => $arrive, 'date' => $date));
     $user = $this->getUser();
     $userReservationHelper = new UserReservation($user, $listOffres, $this->getDoctrine());
     $userReservations = $userReservationHelper->setUserReservations();
     return $this->render('CovoiturageFrontendBundle:Voyage:search.html.twig', array('list_voyages' => $listOffres, 'pagination' => $pagination, 'user_reservations' => $userReservations, 'count_voyages' => $voyagesCount, 'depart' => $depart, 'arrive' => $arrive, 'date_form' => $date));
 }
 public function voyagesAction($page)
 {
     $user = $this->getUser();
     if (!$user) {
         return $this->redirect($this->generateUrl('covoiturage_frontend_homepage'));
     }
     $maxPerPage = $this->container->getParameter('max_per_page');
     $userlistVoyages = $this->getDoctrine()->getRepository('CovoiturageFrontendBundle:Voyage')->getUserList($user->getId(), $page, $maxPerPage);
     $userVoyagesCount = $this->getDoctrine()->getRepository('CovoiturageFrontendBundle:Voyage')->countUserVoyages($user->getId());
     $pagination = array('page' => $page, 'route' => 'covoiturage_frontend_voyage_user', 'pages_count' => ceil($userVoyagesCount / $maxPerPage), 'route_params' => array('page' => $page));
     $user = $this->getUser();
     $userReservationHelper = new UserReservation($user, $userlistVoyages, $this->getDoctrine());
     $userReservations = $userReservationHelper->setUserReservations();
     return $this->render('CovoiturageFrontendBundle:User:mes_voyages.html.twig', array('list_voyages' => $userlistVoyages, 'pagination' => $pagination, 'user_reservations' => $userReservations));
 }
 public function listAction($page)
 {
     $maxPerPage = $this->container->getParameter('max_per_page');
     $listVoyages = $this->getDoctrine()->getRepository('CovoiturageFrontendBundle:Voyage')->getList($page, $maxPerPage);
     $voyagesCount = $this->getDoctrine()->getRepository('CovoiturageFrontendBundle:Voyage')->countVoyages();
     $pagination = array('page' => $page, 'route' => 'covoiturage_frontend_voyage_list', 'pages_count' => ceil($voyagesCount / $maxPerPage), 'route_params' => array('page' => $page));
     $user = $this->getUser();
     $userReservationHelper = new UserReservation($user, $listVoyages, $this->getDoctrine());
     $userReservations = $userReservationHelper->setUserReservations();
     return $this->render('CovoiturageFrontendBundle:Voyage:list.html.twig', array('list_voyages' => $listVoyages, 'pagination' => $pagination, 'user_reservations' => $userReservations));
 }