예제 #1
0
 public function signAction($signature_id)
 {
     $signature = $this->signatureManager->findActiveDocumentSignature($signature_id);
     if (!$signature) {
         throw $this->createNotFoundException();
     }
     $source = $this->signatureManager->getSourceObject($signature);
     $account = $source->getClientAccount();
     $primaryApplicant = $account->getPrimaryApplicant();
     try {
         if (null === $signature->getDocusignEnvelopeId()) {
             $this->electronicSignature->sendEnvelopeForDraftSignature($signature);
         }
         if ($primaryApplicant->getObjectToSave() instanceof ClientAdditionalContact) {
             $existOwnerSignature = $this->signatureManager->findOneOwnerSignatureByDocumentSignatureIdAndContactId($signature->getId(), $primaryApplicant->getId());
         } else {
             $existOwnerSignature = $this->signatureManager->findOneOwnerSignatureByDocumentSignatureIdAndClientId($signature->getId(), $primaryApplicant->getId());
         }
         $error = $this->getAccountSigningErrorMessage($signature, $existOwnerSignature);
         if (null !== $error) {
             return $this->render('WealthbotSignatureBundle:Default:application_sign_error.html.twig', array('message' => '<strong>Error:</strong> ' . $error));
         }
         $envelopeId = $signature->getDocusignEnvelopeId();
         if ($primaryApplicant instanceof AccountOwnerInterface) {
             $recipient = new AccountOwnerRecipientAdapter($primaryApplicant);
             $returnUrl = $this->generateUrl('wealthbot_docusign_application_sign_callback', array('envelope_id' => $envelopeId), true);
             $embeddedUrl = $this->api->getEmbeddedSigningUrl($envelopeId, $recipient, $returnUrl);
             if ($embeddedUrl) {
                 return $this->render('WealthbotSignatureBundle:Default:application_sign_iframe.html.twig', array('url' => $embeddedUrl));
             }
         }
     } catch (\Exception $e) {
         return $this->render('WealthbotSignatureBundle:Default:application_sign_error.html.twig', array('message' => $e->getMessage()));
     }
     return $this->render('WealthbotSignatureBundle:Default:application_sign_error.html.twig', array('message' => 'An error has occurred. Please try again later.'));
 }