protected function success() { /** @var User $owner */ $owner = $this->getDocumentsOwner(); $documents = $this->getExistDocuments($owner); $data = $this->form->getData(); foreach ($data as $key => $file) { if ($file instanceof UploadedFile) { if (isset($documents[$key])) { $document = $documents[$key]; } else { $document = new Document(); $documents[$key] = $document; } $document->setFile($file); $document->setType($key); $document->upload(); $this->addDocumentForOwner($owner, $document); if ($key == Document::TYPE_ADV || $key == Document::TYPE_INVESTMENT_MANAGEMENT_AGREEMENT) { $this->sendEmailMessages($owner, $key); } } } $this->em->persist($owner); $this->em->flush(); }
public function success() { $emailService = $this->getOption('email_service'); if (!$emailService instanceof MailerInterface) { throw new \InvalidArgumentException(sprintf('Option email_service must be instance of Wealthbot\\MailerBundle\\Mailer\\MailerInterface')); } /** @var RiaCompanyInformation $riaCompanyInformation */ $riaCompanyInformation = $this->form->getData(); /** @var User $ria */ $ria = $riaCompanyInformation->getRia(); $documents = $this->getExistDocuments($ria); $documentFormData = $this->form->get('documents')->getData(); if ($documentFormData) { foreach ($documentFormData as $key => $file) { if ($file instanceof UploadedFile) { if (isset($documents[$key])) { $document = $documents[$key]; } else { $document = new Document(); $documents[$key] = $document; } $document->setFile($file); $document->setType($key); $document->upload(); $this->addDocumentForOwner($ria, $document); if ($key == Document::TYPE_ADV || $key == Document::TYPE_INVESTMENT_MANAGEMENT_AGREEMENT) { $this->sendEmailMessages($ria, $key, $emailService); } } } } $this->em->persist($ria); $this->em->persist($riaCompanyInformation); $this->em->flush(); }
protected function success() { $user = $this->getOption('user'); if (!$user instanceof User) { throw new \InvalidArgumentException(sprintf('Option user must be instance of %s', get_class(new User()))); } /** @var RiaCompanyInformation $data */ $data = $this->form->getData(); $existDocuments = $this->getExistDocuments($user); $documentFiles = $this->form->get('documents')->getData(); foreach ($documentFiles as $key => $file) { if (isset($existDocuments[$key])) { $document = $existDocuments[$key]; } else { $document = new Document(); $existDocuments[$key] = $document; } $document->setFile($file); $document->setType($key); $document->setOwnerId($user->getId()); $document->upload(); if (!$user->getUserDocuments()->contains($document)) { $user->addUserDocument($document); } } $data->setRia($user); $this->em->persist($data); $this->em->persist($user); $this->em->flush(); }
public function createDocument($fileName, $path, $type, $ref) { $document = new Document(); copy(__DIR__ . '/../../Resources/public/pdf/' . $fileName, $path . '/' . $fileName); $document->setMimeType('application/pdf'); $document->setOriginalName($fileName); $document->setFilename($fileName); $document->setType($type); $this->addReference($ref, $document); return $document; }
public function uploadDocumentsAction(Request $request) { $this->checkAccess(Acl::PERMISSION_EDIT); $em = $this->get('doctrine.orm.entity_manager'); $documentManager = $this->get('wealthbot_user.document_manager'); /** @var User $superAdmin */ $superAdmin = $this->get('wealthbot.manager.user')->getAdmin(); $form = $this->createForm(new DocumentFormType()); $formHandler = new DocumentFormHandler($form, $request, $em, $this->get('wealthbot.mailer'), array('user' => $superAdmin)); if ($request->isMethod('post')) { $process = $formHandler->process(); if (!$process) { return $this->getJsonResponse(array('status' => 'error', 'content' => $this->renderView('WealthbotAdminBundle:GeneralSettings:_document_form.html.twig', array('form' => $form->createView())))); } } $documentTypes = array(); foreach (Document::getAdminTypeChoices() as $key) { $type = str_replace('_', ' ', $key); if ($type == 'adv') { $type = 'ADV'; } $documentTypes[$key] = ucwords($type); } if ($request->isXmlHttpRequest()) { return $this->getJsonResponse(array('status' => 'success', 'content' => $this->renderView('WealthbotAdminBundle:GeneralSettings:_documents.html.twig', array('form' => $form->createView(), 'documents' => $documentManager->getUserDocuments($superAdmin->getId()), 'types' => $documentTypes)))); } return $this->render('WealthbotAdminBundle:GeneralSettings:_documents.html.twig', array('form' => $form->createView(), 'documents' => $documentManager->getUserDocuments($superAdmin->getId()), 'types' => $documentTypes)); }
/** * Create new document signature * * @param int $sourceId * @param string $type * @param string|null $envelopeId * @param string $status * @return DocumentSignature */ public function createDocumentSignature($sourceId, $type, $envelopeId = null, $status = Envelope::STATUS_CREATED) { $document = new Document(); $document->setType(Document::TYPE_APPLICATION); $signature = new DocumentSignature(); $signature->setSourceId($sourceId); $signature->setDocument($document); $signature->setDocusignEnvelopeId($envelopeId); $signature->setType($type); $signature->setStatus($status); $signature->setActive(true); return $signature; }
/** * Get archive file by hash * * @param string $hash * @return string */ private function getArchiveFileByHash($hash) { return Document::getUploadRootDir() . '/' . $hash . '.zip'; }