예제 #1
0
 /**
  * Change status
  * @param Request $request
  * @param AdvertisingPackage $ap
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function statusChangeAction(Request $request, AdvertisingPackage $ap)
 {
     $em = $this->getDoctrine()->getManager();
     $session = $request->getSession();
     try {
         $newStatus = $ap->getStatus() ? 0 : 1;
         $ap->setStatus($newStatus);
         $em->persist($ap);
         $em->flush();
         $session->getFlashBag()->add('msgSuccess', $this->get('translator')->trans('change_status_success'));
     } catch (\Exception $e) {
         $session->getFlashBag()->add('msgSuccess', $this->get('translator')->trans('change_status_error'));
     }
     return $this->redirect($this->generateUrl('admin_accommodation_advertising_packages', array('id' => $ap->getAccommodation()->getId())));
 }
예제 #2
0
 public function step7Action(Request $request, Accommodation $accommodation)
 {
     $em = $this->getDoctrine()->getManager();
     $advertisingPackage = new AdvertisingPackage();
     $typesLocation = $em->getRepository('AppBundle:AdvertisingPackageType')->findBy(array('type' => array('country', 'region', 'subregion', 'city')));
     $typeHome = $em->getRepository('AppBundle:AdvertisingPackageType')->findOneBy(array('type' => 'home'));
     $form = $this->createForm(new AdvertisingPackageType($typesLocation), $advertisingPackage);
     $form->handleRequest($request);
     if ($form->isValid()) {
         if ($request->request->get('home')) {
             $ap = new AdvertisingPackage();
             $ap->setStatus(0);
             $ap->setType($typeHome);
             $ap->setAccommodation($accommodation);
             $em->persist($ap);
             $em->flush();
         }
         $advertisingPackage->setAccommodation($accommodation);
         $advertisingPackage->setStatus(0);
         $em->persist($advertisingPackage);
         $em->flush();
         return $this->redirect($this->generateUrl('app_profile'));
     }
     return $this->render('AppBundle:Profile/Steps:step7.html.twig', array('accommodation' => $accommodation, 'form' => $form->createView(), 'typeHome' => $typeHome));
 }