Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('note', 'textarea', array('label' => 'Message'))->add('attachment', 'file', array('constraints' => array(new Assert\File(array('maxSize' => UploadableFileConstraintParameters::getMaxUploadFileSize(), 'mimeTypes' => UploadableFileConstraintParameters::getAllowedMimeTypes(), 'mimeTypesMessage' => UploadableFileConstraintParameters::getInvalidMimeTypeMessage())))))->add('add', 'submit', array('label' => 'Send Message'));
 }
 /**
  * Upload declaration action
  *
  * @return void
  */
 public function uploadDeclarationAction()
 {
     $isPopup = $this->getSymfonyRequest()->query->get('isPopup');
     $application = $this->getIrisAgentContext()->getReferencingApplicationClient()->getReferencingApplication(array('referencingApplicationUuId' => $this->getSymfonyRequest()->query->get('uuid')));
     $form = $this->getFormFactory()->create(new UploadDeclarationType());
     $redirectUrl = sprintf('/iris-referencing/upload-declaration?uuid=%s', $application->getReferencingApplicationUuId());
     if ($isPopup) {
         $redirectUrl .= '&isPopup=1';
     }
     if ($this->getSymfonyRequest()->isMethod('POST')) {
         $form->handleRequest($this->getSymfonyRequest());
         if ($form->isValid()) {
             /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $declarationFile */
             $declarationFile = $form->get('declaration')->getData();
             $fileName = sprintf('Signed-Declaration-%s-%s.%s', $application->getReferenceNumber(), date('dmYHis'), strtolower($declarationFile->getClientOriginalExtension()));
             try {
                 $this->getIrisAgentContext()->getReferencingApplicationClient()->uploadDocument(array('referencingApplicationUuId' => $application->getReferencingApplicationUuId(), 'fileName' => $fileName, 'description' => 'Signed Declaration', 'file' => $declarationFile->getPathname(), 'categoryId' => DocumentCategoryOptions::MISCELLANEOUS));
             } catch (DefaultException $e) {
                 $this->_helper->redirector->gotoUrlAndExit(sprintf('%s&isSuccess=%d', $redirectUrl, 0));
                 return;
             }
             $this->_helper->redirector->gotoUrlAndExit(sprintf('%s&isSuccess=%d', $redirectUrl, 1));
             return;
         }
     }
     if ($isPopup) {
         // Turn off layout and renderer
         $this->_helper->viewRenderer->setNoRender();
         $this->_helper->getHelper('layout')->disableLayout();
     }
     $this->renderTwigView('/iris-referencing/upload-declaration.html.twig', array('application' => $application, 'isPopup' => $isPopup, 'form' => $form->createView(), 'isSuccess' => $this->getSymfonyRequest()->get('isSuccess', null), 'maxUploadFileSize' => UploadableFileConstraintParameters::getMaxUploadFileSize()));
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('declaration', 'file', array('constraints' => array(new Assert\NotBlank(array('message' => 'Please provide a signed declaration document to upload')), new Assert\File(array('maxSize' => UploadableFileConstraintParameters::getMaxUploadFileSize(), 'mimeTypes' => UploadableFileConstraintParameters::getAllowedMimeTypes(), 'mimeTypesMessage' => UploadableFileConstraintParameters::getInvalidMimeTypeMessage())))));
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('fileItem', 'file', array('label' => false, 'required' => false, 'constraints' => array(new Assert\File(array('maxSize' => UploadableFileConstraintParameters::getMaxUploadFileSize(), 'mimeTypes' => UploadableFileConstraintParameters::getAllowedMimeTypes(), 'mimeTypesMessage' => UploadableFileConstraintParameters::getInvalidMimeTypeMessage())))))->add('deleteFile', 'submit', array('label' => false, 'attr' => array('class' => 'deleteFile')));
 }