Example #1
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->bulletinInfoTitle = $options['bulletinInfoTitle'];
     if (null == $this->bulletinInfoTitle) {
         $builder->add('bulletinInfoTitle', EntityType::class, array('label' => 'BulletinInfoContent.bulletinInfoTitle.label', 'class' => 'AcfDataBundle:BulletinInfoTitle', 'query_builder' => function (BulletinInfoTitleRepository $btr) {
             return $btr->createQueryBuilder('bt')->orderBy('bt.title', 'ASC');
         }, 'choice_label' => 'title', 'multiple' => false, 'by_reference' => true, 'required' => true));
     } else {
         $btId = $this->bulletinInfoTitle->getId();
         $builder->add('bulletinInfoTitle', EntityidType::class, array('label' => 'BulletinInfoContent.bulletinInfoTitle.label', 'class' => 'AcfDataBundle:BulletinInfoTitle', 'query_builder' => function (BulletinInfoTitleRepository $btr) use($btId) {
             return $btr->createQueryBuilder('bt')->where('bt.id = :id')->setParameter('id', $btId)->orderBy('bt.title', 'ASC');
         }, 'choice_label' => 'id', 'multiple' => false, 'by_reference' => true, 'required' => true));
     }
     $builder->add('title', TextType::class, array('label' => 'BulletinInfoContent.title.label'));
     $builder->add('content', TextareaType::class, array('label' => 'BulletinInfoContent.content.label', 'required' => false));
     $builder->add('theme', TextType::class, array('label' => 'BulletinInfoContent.theme.label', 'required' => false));
     $builder->add('jort', TextType::class, array('label' => 'BulletinInfoContent.jort.label', 'required' => false));
     $builder->add('txtNum', TextType::class, array('label' => 'BulletinInfoContent.txtNum.label', 'required' => false));
     $builder->add('artTxt', TextType::class, array('label' => 'BulletinInfoContent.artTxt.label', 'required' => false));
     $builder->add('dtTxt', TextType::class, array('label' => 'BulletinInfoContent.dtTxt.label', 'required' => false));
     $builder->add('artCode', TextType::class, array('label' => 'BulletinInfoContent.artCode.label', 'required' => false));
     $builder->add('companyType', TextType::class, array('label' => 'BulletinInfoContent.companyType.label', 'required' => false));
     $builder->add('dtApplication', TextType::class, array('label' => 'BulletinInfoContent.dtApplication.label', 'required' => false));
 }
 /**
  *
  * @param string $uid
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function editPostAction($uid)
 {
     if (!$this->hasRole('ROLE_SUPERADMIN')) {
         return $this->redirect($this->generateUrl('_admin_homepage'));
     }
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         $urlFrom = $this->generateUrl('_admin_bulletinInfo_list');
     }
     $em = $this->getEntityManager();
     try {
         $bulletinInfo = $em->getRepository('AcfDataBundle:BulletinInfo')->find($uid);
         if (null == $bulletinInfo) {
             $this->flashMsgSession('warning', $this->translate('BulletinInfo.edit.notfound'));
         } else {
             $bulletinInfoUpdateDtStartForm = $this->createForm(BulletinInfoUpdateDtStartTForm::class, $bulletinInfo);
             $bulletinInfoUpdateDescriptionForm = $this->createForm(BulletinInfoUpdateDescriptionTForm::class, $bulletinInfo);
             $bulletinInfoUpdateNumForm = $this->createForm(BulletinInfoUpdateNumTForm::class, $bulletinInfo);
             $bulletinInfoTitle = new BulletinInfoTitle();
             $bulletinInfoTitle->setBulletinInfo($bulletinInfo);
             $bulletinInfoTitleNewForm = $this->createForm(BulletinInfoTitleNewTForm::class, $bulletinInfoTitle, array('bulletinInfo' => $bulletinInfo));
             $this->gvars['tabActive'] = $this->getSession()->get('tabActive', 2);
             $this->getSession()->remove('tabActive');
             $this->gvars['stabActive'] = $this->getSession()->get('stabActive', 1);
             $this->getSession()->remove('stabActive');
             $request = $this->getRequest();
             $reqData = $request->request->all();
             if (isset($reqData['BulletinInfoUpdateDtStartForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $bulletinInfoUpdateDtStartForm->handleRequest($request);
                 if ($bulletinInfoUpdateDtStartForm->isValid()) {
                     $em->persist($bulletinInfo);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('BulletinInfo.edit.success', array('%bulletinInfo%' => $bulletinInfo->getNum())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($bulletinInfo);
                     $this->flashMsgSession('error', $this->translate('BulletinInfo.edit.failure', array('%bulletinInfo%' => $bulletinInfo->getNum())));
                 }
             } elseif (isset($reqData['BulletinInfoUpdateNumForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $bulletinInfoUpdateNumForm->handleRequest($request);
                 if ($bulletinInfoUpdateNumForm->isValid()) {
                     $em->persist($bulletinInfo);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('BulletinInfo.edit.success', array('%bulletinInfo%' => $bulletinInfo->getNum())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($bulletinInfo);
                     $this->flashMsgSession('error', $this->translate('BulletinInfo.edit.failure', array('%bulletinInfo%' => $bulletinInfo->getNum())));
                 }
             } elseif (isset($reqData['BulletinInfoUpdateDescriptionForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $bulletinInfoUpdateDescriptionForm->handleRequest($request);
                 if ($bulletinInfoUpdateDescriptionForm->isValid()) {
                     $em->persist($bulletinInfo);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('BulletinInfo.edit.success', array('%bulletinInfo%' => $bulletinInfo->getNum())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($bulletinInfo);
                     $this->flashMsgSession('error', $this->translate('BulletinInfo.edit.failure', array('%bulletinInfo%' => $bulletinInfo->getNum())));
                 }
             } elseif (isset($reqData['BulletinInfoTitleNewForm'])) {
                 $this->gvars['tabActive'] = 3;
                 $this->getSession()->set('tabActive', 3);
                 $bulletinInfoTitleNewForm->handleRequest($request);
                 if ($bulletinInfoTitleNewForm->isValid()) {
                     $em->persist($bulletinInfoTitle);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('BulletinInfoTitle.add.success', array('%bulletinInfoTitle%' => $bulletinInfoTitle->getTitle())));
                     $this->gvars['stabActive'] = 2;
                     $this->getSession()->set('stabActive', 2);
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($bulletinInfo);
                     $this->flashMsgSession('error', $this->translate('BulletinInfoTitle.add.failure'));
                 }
             }
             $this->gvars['bulletinInfo'] = $bulletinInfo;
             $this->gvars['BulletinInfoUpdateDtStartForm'] = $bulletinInfoUpdateDtStartForm->createView();
             $this->gvars['BulletinInfoUpdateDescriptionForm'] = $bulletinInfoUpdateDescriptionForm->createView();
             $this->gvars['BulletinInfoUpdateNumForm'] = $bulletinInfoUpdateNumForm->createView();
             $this->gvars['BulletinInfoTitleNewForm'] = $bulletinInfoTitleNewForm->createView();
             $this->gvars['pagetitle'] = $this->translate('pagetitle.bulletinInfo.edit', array('%bulletinInfo%' => $bulletinInfo->getNum()));
             $this->gvars['pagetitle_txt'] = $this->translate('pagetitle.bulletinInfo.edit.txt', array('%bulletinInfo%' => $bulletinInfo->getNum()));
             return $this->renderResponse('AcfAdminBundle:BulletinInfo:edit.html.twig', $this->gvars);
         }
     } catch (\Exception $e) {
         $logger = $this->getLogger();
         $logger->addCritical($e->getLine() . ' ' . $e->getMessage() . ' ' . $e->getTraceAsString());
     }
     return $this->redirect($urlFrom);
 }
 /**
  * Get Query for All Entities
  *
  * @param BulletinInfoTitle $bt
  *
  * @return \Doctrine\ORM\Query
  */
 public function getAllByBulletinInfoTitleQuery(BulletinInfoTitle $bt)
 {
     $qb = $this->createQueryBuilder('bc')->join('bc.bulletinInfoTitle', 'bt')->join('bt.bulletinInfo', 'bi')->where('bt.id = :id')->orderBy('bc.dtCrea', 'ASC')->setParameter('id', $bt->getId());
     $query = $qb->getQuery();
     return $query;
 }