public function createSecondCurtainPriceBand()
 {
     $curtainPriceBand = new CurtainPriceBand();
     $curtainPriceBand->setName("I");
     $this->em->persist($curtainPriceBand);
     $this->em->flush();
     return $curtainPriceBand;
 }
 public function updateAction()
 {
     if ($this->getRequest()->get('save_new') != null) {
         $curtainPriceBand = new CurtainPriceBand();
         $curtainPriceBand->setName($this->getRequest()->get('name_new'));
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($curtainPriceBand);
         $em->flush();
     } else {
         if ($this->getRequest()->get('submit_all') != null) {
             $repository = $this->getDoctrine()->getRepository('ElmetSiteBundle:CurtainPriceBand');
             $curtainPriceBands = $repository->findAll();
             foreach ($curtainPriceBands as $curtainPriceBand) {
                 $curtainPriceBand->setName($this->getRequest()->get('all:name_' . $curtainPriceBand->getId()));
                 $em = $this->getDoctrine()->getEntityManager();
                 $em->merge($curtainPriceBand);
             }
             $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:CurtainPriceBand');
                 $curtainPriceBand = $repository->findOneById($id);
                 $curtainPriceBand->setName($this->getRequest()->get('single:name_' . $id));
                 $em = $this->getDoctrine()->getEntityManager();
                 $em->merge($curtainPriceBand);
                 $em->flush();
             }
         }
     }
     return $this->viewAction();
 }