Ejemplo n.º 1
0
 public function updateAction()
 {
     if ($this->getRequest()->get('save_new') != null) {
         $curtainPriceBandRepository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainPriceBand');
         $curtainPriceBand = $curtainPriceBandRepository->findOneById($this->getRequest()->get('curtainpriceband_current'));
         $curtainPrice = new CurtainPrice();
         $curtainPrice->setCurtainPriceBand($curtainPriceBand);
         $curtainPrice->setSize($this->getRequest()->get('size_new'));
         $curtainPrice->setType($this->getRequest()->get('type_new'));
         $curtainPrice->setPrice($this->getRequest()->get('price_new'));
         if ($this->getRequest()->get('curtaineyeletpriceband_new') != "empty") {
             $curtainEyeletPriceBandRepository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainEyeletPriceBand');
             $curtainEyeletPriceBand = $curtainEyeletPriceBandRepository->findOneById($this->getRequest()->get('curtaineyeletpriceband_new'));
             $curtainPrice->setCurtainEyeletPriceBand($curtainEyeletPriceBand);
         }
         $curtainSizes = $this->getCurtainSizes();
         $size = $this->getRequest()->get('size_new');
         $curtainPrice->setHeight($curtainSizes[$size]->getHeight());
         $curtainPrice->setWidth($curtainSizes[$size]->getWidth());
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($curtainPrice);
         $em->flush();
     } else {
         if ($this->getRequest()->get('submit_all') != null) {
             $em = $this->getDoctrine()->getEntityManager();
             $query = $em->createQuery('SELECT cp FROM ElmetSiteBundle:CurtainPrice cp
                                     JOIN cp.curtain_price_band cpb
                                     WHERE cpb.id = :id');
             $query->setParameter('id', $this->getRequest()->get('curtainpriceband_current'));
             $curtainPrices = $query->getResult();
             foreach ($curtainPrices as $curtainPrice) {
                 $curtainPrice->setPrice($this->getRequest()->get('all:price_' . $curtainPrice->getId()));
                 $em->merge($curtainPrice);
             }
             $em->flush();
         } else {
             $params = $this->getRequest()->request->all();
             $keys = array_keys($params);
             $id = 0;
             foreach ($keys as $key) {
                 $param = $params[$key];
                 if ($param == 'Save') {
                     $index = stripos($key, '_');
                     $id = substr($key, $index + 1);
                 }
             }
             if ($id != 0) {
                 $repository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainPrice');
                 $curtainPrice = $repository->findOneById($id);
                 $curtainPrice->setPrice($this->getRequest()->get('single:price_' . $id));
                 $em = $this->getDoctrine()->getEntityManager();
                 $em->merge($curtainPrice);
                 $em->flush();
             }
         }
     }
     return $this->viewAction($this->getRequest()->get('curtainpriceband_current'));
 }
Ejemplo n.º 2
0
 public function createSecondPrice()
 {
     $curtainPriceBand = $this->cpbRepository->findOneById(2);
     $curtainPrice = new CurtainPrice();
     $curtainPrice->setCurtainPriceBand($curtainPriceBand);
     $curtainPrice->setSize("3ft x 3ft");
     $curtainPrice->setType("CaravanWindow");
     $curtainPrice->setPrice(130.95);
     $curtainPrice->setWidth(3.0);
     $curtainPrice->setHeight(3.0);
     $this->em->persist($curtainPrice);
     $this->em->flush();
     return $curtainPrice;
 }