/** * Get name * * @return string */ public function getName() { return parent::getName(); }
public function createAccountAction(Request $request) { if (!$request->isMethod("post") || !$request->isXmlHttpRequest()) { throw $this->createNotFoundException('Page not found.'); } $client = $this->getUser(); if (!$client || !$client->hasRole('ROLE_CLIENT')) { return $this->getJsonResponse(array('status' => 'error', 'message' => 'Client does not exist.')); } /** @var \Doctrine\ORM\EntityManager $em */ $em = $this->get('doctrine.orm.entity_manager'); $adm = $this->get('wealthbot_docusign.account_docusign.manager'); $group = $request->get('group'); $allowedGroups = AccountGroup::getGroupChoices(); if (!in_array($group, $allowedGroups)) { throw new HttpException(400, 'Invalid group type'); } $groupTypeId = null; $groupType = null; $clientAccount = new ClientAccount(); if ($group === AccountGroup::GROUP_DEPOSIT_MONEY || $group === AccountGroup::GROUP_FINANCIAL_INSTITUTION) { $groupType = $this->getAccountGroupType(); $clientAccount->setGroupType($groupType); } $form = $this->createForm(new TypedClientAccountFormType($em, $client, $groupType, $group), $clientAccount); $formHandler = new ClientAccountFormHandler($form, $request, $adm, $this->getAccountOwners(), $this->getIsConsolidateAccount()); $process = $formHandler->process(); if ($process) { $this->removeAccountGroup(); $this->removeAccountType(); $this->removeAccountGroupType(); $this->removeAccountOwners(); /** @var ClientAccount $clientAccount */ $clientAccount = $form->getData(); if ($group == 'employer_retirement') { $responseData = $this->processEmployerRetirementAccountForm($clientAccount); } else { $responseData = $this->processAccountForm(); $isType = $clientAccount->getGroupName() === AccountGroup::GROUP_DEPOSIT_MONEY; $systemAccounts = $em->getRepository('WealthbotClientBundle:SystemAccount')->findByClientIdAndType($client->getId(), $clientAccount->getSystemType()); $responseData['in_right_box'] = $isType || count($systemAccounts) < 1 ? false : true; $responseData['transfer_url'] = $this->generateUrl('rx_client_dashboard_select_system_account', array('account_id' => $clientAccount->getId())); } $this->removeIsConsolidateAccount(); $this->removeAccountStep(); return $this->getJsonResponse($responseData); } $message = $this->getTitleMessageForAccountForm($group, $groupType); return $this->getJsonResponse(array('status' => 'error', 'form' => $this->renderView('WealthbotClientBundle:Profile:_client_accounts_form.html.twig', array('form' => $form->createView(), 'group' => $group, 'hide_submit_button' => true, 'title_message' => $message)))); }