Ejemplo n.º 1
0
 /**
  * Creates a form to delete a Lodging entity.
  *
  * @param Lodging $lodging The Lodging entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Lodging $lodging)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('admin_lodging_delete', array('id' => $lodging->getId())))->setMethod('DELETE')->getForm();
 }
Ejemplo n.º 2
0
 /**
  * @Route("/lodging/{id}/{weeks}/{package}", defaults={"package" = "0"}, name="lodging_by_id", options={"expose"=true})
  * @ParamConverter("id", class="\TS\CYABundle\Entity\Lodging")
  * @Method("GET")
  *
  * @param Lodging $lodging
  * @param $weeks
  * @param Package $package
  * @return JsonResponse
  */
 public function lodgingByIdAction(Lodging $lodging, $weeks, $package)
 {
     $priceLodging = $weeks * $lodging->getPricePerWeek();
     if ($package) {
         $em = $this->getDoctrine()->getManager();
         $package = $em->getRepository('TSCYABundle:Package')->find($package);
         foreach ($package->getPackageLodging() as $item) {
             $idLodging = $item->getLodging()->getId();
             if ($idLodging === $lodging->getId()) {
                 $priceLodging = $item->getLodgingPrice();
                 break;
             }
         }
         if (!($priceLodging > 0)) {
             $priceLodging = $package->getSemanas() * $lodging->getPricePerWeek();
         }
     }
     return new JsonResponse(number_format($priceLodging, 2, '.', ','));
 }