/** * Is account owner sign all document signatures for application * * @param AccountOwnerInterface $accountOwner * @param ClientAccount $account * @return bool */ public function isOwnerSignApplication(AccountOwnerInterface $accountOwner, ClientAccount $account) { return $this->manager->isOwnerSignApplication($accountOwner, $account); }
public function applicationSignCallbackAction(Request $request) { $applicationId = $request->get('application_id'); $envelopeId = $request->get('envelope_id'); $signatures = $this->signatureManager->findDocumentSignaturesByEnvelopeId($envelopeId); if (!count($signatures)) { throw $this->createNotFoundException('Signature does not exist.'); } $event = $request->get('event'); switch ($event) { case 'exception': $error = 'An error has occurred. Please try again later.'; break; case 'id_check_faild': $error = 'An error has occurred: recipient failed an ID check.'; break; case 'session_timeout': $error = 'An error has occurred: session times out.'; break; default: $error = null; break; } $isCompleted = false; $status = $this->electronicSignature->updateDocumentSignaturesStatusByEnvelopeId($envelopeId, $signatures); switch ($status) { case Envelope::STATUS_SIGNED: case Envelope::STATUS_COMPLETED: $message = 'You have successfully signed your document.<br/>Please close this tab and return to the original tab.'; $isCompleted = true; $this->getDocusignDocumentByEnvelopeIdAndSignatures($envelopeId, $signatures); break; case Envelope::STATUS_DECLINED: $message = 'Signing declined.'; break; case Envelope::STATUS_SENT: case Envelope::STATUS_PROCESSING: $message = 'Signing in process.'; if ($applicationId) { $account = $this->em->getRepository('WealthbotClientBundle:ClientAccount')->find($applicationId); if ($account && $account->isJointType()) { $primaryApplicant = $account->getPrimaryApplicant(); $secondaryApplicant = $account->getSecondaryApplicant(); if ($this->signatureManager->isOwnerSignApplication($primaryApplicant, $account) && !$this->signatureManager->isOwnerSignApplication($secondaryApplicant, $account)) { $ria = $account->getClient()->getRia(); // Send email to secondary applicant $mailer = $this->get('wealthbot.mailer'); $mailer->sendDocusignJointAccountOwnerEmail($secondaryApplicant, $ria); } } } break; case Envelope::STATUS_VOIDED: $message = null; $error = 'Envelope has been voted.'; break; case Envelope::STATUS_DELETED: $message = null; $error = 'Envelope has been voted.'; break; case Envelope::STATUS_TIMED_OUT: $message = null; $error = 'Timed out. Please try again later.'; break; default: $message = 'Signing in process.'; break; } if (null !== $error) { return $this->render('WealthbotSignatureBundle:Default:application_sign_error.html.twig', array('message' => $error)); } $params = array('envelope_id' => $envelopeId, 'application_id' => $applicationId ? $applicationId : '', 'signature_id' => count($signatures) == 1 ? $signatures[0]->getId() : '', 'is_completed' => $isCompleted, 'message' => $message); return $this->render('WealthbotSignatureBundle:Default:application_sign.html.twig', $params); }