/** * Terms and conditions * * @return void */ public function termsAndConditionsAction() { $form = $this->getFormFactory()->create(new RootStepType(new TermsAndConditionsType()), $this->getAgentProgressiveStore()->fetch(self::MODEL_APPLICATION_CLASS)); /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\ReferencingApplication $applicationFromFormData */ $applicationFromFormData = $this->getReferencingModelFromFormData($form->getData()); $isAgentReturningFromNotification = false; if ($applicationFromFormData) { $isAgentReturningFromNotification = $this->getIsAgentReturningFromNotification($applicationFromFormData->getReferencingApplicationUuId()); } if ($this->getSymfonyRequest()->isMethod('POST')) { $form->submit($this->getSymfonyRequest()); $this->getFormFlow()->setForm($form); if ($form->get('back')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getBackUrl()); } if ($form->isValid()) { $object = null; try { $object = $this->getAgentProgressiveStore()->store($form->getData()); } catch (ValidationException $e) { $this->getFormValidationErrorBinder()->bind($form, $e); } /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\ReferencingApplication $application */ $application = $this->getAgentProgressiveStore()->getPrototypeByClass(self::MODEL_APPLICATION_CLASS); /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingCase\Model\ReferencingCase $case */ $case = $this->getAgentProgressiveStore()->getPrototypeByClass(self::MODEL_CASE_CLASS); $submitSuccess = false; $isSubmittingApplicationOnly = false; // If we have the correct number of applicants, submit the case try { // If awaiting agent review then submit application if (7 == $application->getStatus()) { $submitSuccess = $this->getContainer()->get('iris.referencing.application.submission.application_submitter')->submit($application->getReferencingApplicationUuId()); $isSubmittingApplicationOnly = true; } else { // Submit case $submitSuccess = $this->getContainer()->get('iris.referencing.application.submission.case_submitter')->submit($case->getReferencingCaseUuId()); } } catch (DefaultException $e) { // If we're unable to submit the case, try submitting the application (i.e. continuation of a second tenant) // 1012 is the "Referencing case is already submitted" error from IRIS if (1012 == $e->getCode()) { $submitSuccess = $this->getContainer()->get('iris.referencing.application.submission.application_submitter')->submit($application->getReferencingApplicationUuId(), '/iris-referencing/submission-error?errorCode={error_code}'); $isSubmittingApplicationOnly = true; } } // Something went wrong if (!$submitSuccess) { $this->_helper->redirector->gotoUrlAndExit(sprintf('/iris-referencing/failed-to-submit-application?uuid=%s', $application->getReferencingApplicationUuId())); } // Do we need to collect another tenant? $difference = $this->getContainer()->get('iris.referencing.application.application_counter')->getApplicantCountDifference($application->getReferencingApplicationUuId(), $case->getNumberOfTenants()); // If the difference is greater than zero, then we need to collect more tenants if ($difference > 0 && !$isSubmittingApplicationOnly) { // Clear and add existing prototypes $this->getAgentProgressiveStore()->clearPrototypes()->initialisePrototypes()->storePrototypes(); // Forward to add tenant controller $this->_helper->redirector->gotoUrlAndExit(sprintf('/iris-add-tenant?uuid=%s&difference=%d&numberOfTenants=%d', $case->getReferencingCaseUuId(), $difference, $case->getNumberOfTenants())); } if ($object) { if ($form->get('next')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getNextUrl()); } } } } $declarationOwnership = new DeclarationOwnership(); $canDisplayDeclaration = $declarationOwnership->canDisplayDeclaration($this->_agentSchemeNumber); $this->renderTwigView('/iris-new-reference/generic-step.html.twig', array('bodyTitle' => 'Terms and Conditions', 'formTheme' => 'terms-and-conditions-widgets.html.twig', 'isAgentReturningFromNotification' => $isAgentReturningFromNotification, 'form' => $form->createView(), 'canDisplayDeclaration' => $canDisplayDeclaration)); }
/** * Terms and conditions * * @return void */ public function termsAndConditionsAction() { $form = $this->getFormFactory()->create(new RootStepType(new TermsAndConditionsType()), $this->getAgentGuarantorProgressiveStore()->fetch(self::MODEL_APPLICATION_CLASS)); /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\ReferencingApplication $applicationFromFormData */ $applicationFromFormData = $this->getReferencingModelFromFormData($form->getData()); $isAgentReturningFromNotification = false; if ($applicationFromFormData) { $isAgentReturningFromNotification = $this->getIsAgentReturningFromNotification($applicationFromFormData->getReferencingApplicationUuId()); } if ($this->getSymfonyRequest()->isMethod('POST')) { $form->submit($this->getSymfonyRequest()); $this->getFormFlow()->setForm($form); if ($form->get('back')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getBackUrl()); } if ($form->isValid()) { $object = null; try { $object = $this->getAgentGuarantorProgressiveStore()->store($form->getData()); } catch (ValidationException $e) { $this->getFormValidationErrorBinder()->bind($form, $e); } /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\ReferencingApplication $application */ $application = $this->getAgentGuarantorProgressiveStore()->getPrototypeByClass(self::MODEL_APPLICATION_CLASS); // If we have the correct number of applicants, submit the application $submitSuccess = $this->getContainer()->get('iris.referencing.application.submission.application_submitter')->submit($application->getReferencingApplicationUuId(), '/iris-referencing/submission-error?errorCode={error_code}'); // Something went wrong if (!$submitSuccess) { $this->_helper->redirector->gotoUrlAndExit(sprintf('/iris-referencing/failed-to-submit-application?uuid=%s', $application->getReferencingApplicationUuId())); } if ($object) { if ($form->get('next')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getNextUrl()); } } } } $declarationOwnership = new DeclarationOwnership(); $canDisplayDeclaration = $declarationOwnership->canDisplayDeclaration($this->_agentSchemeNumber); $this->renderTwigView('/iris-add-guarantor/generic-step.html.twig', array('bodyTitle' => 'Terms and Conditions', 'formTheme' => 'terms-and-conditions-guarantor-widgets.html.twig', 'isAgentReturningFromNotification' => $isAgentReturningFromNotification, 'form' => $form->createView(), 'canDisplayDeclaration' => $canDisplayDeclaration)); }
/** * Terms and conditions * * @return void */ public function termsAndConditionsAction() { $form = $this->getFormFactory()->create(new RootStepType(new TermsAndConditionsType()), $this->getSystemProgressiveStore()->fetch(self::MODEL_APPLICATION_CLASS)); if ($this->getSymfonyRequest()->isMethod('POST')) { $form->submit($this->getSymfonyRequest()); $this->getFormFlow()->setForm($form); if ($form->get('back')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getBackUrl()); } if ($form->isValid()) { $object = null; try { /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\ReferencingApplication $object */ $object = $this->getSystemProgressiveStore()->store($form->getData()); } catch (ValidationException $e) { $this->getFormValidationErrorBinder()->bind($form, $e); } if ($object) { // Perform submission $this->getIrisSystemContext()->getSystemApplicationClient()->submitApplication(array('referencingApplicationUuId' => $object->getReferencingApplicationUuId())); if ($form->get('next')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getNextUrl()); } } } } $sysAppclientContext = $this->getIrisSystemContext()->getSystemApplicationClient(); $declarationOwnership = new DeclarationOwnership(); $agentSchemeNumber = $declarationOwnership->getAgentSchemeNumberByLinkRef($sysAppclientContext, $this->authSession->linkRef); $canDisplayDeclaration = $declarationOwnership->canDisplayDeclaration($agentSchemeNumber); $this->renderTwigView('/iris-continue-reference/generic-step.html.twig', array('bodyTitle' => 'Terms and Conditions', 'formTheme' => 'form/continue-terms-and-conditions-widgets.html.twig', 'form' => $form->createView(), 'canDisplayDeclaration' => $canDisplayDeclaration)); }
/** * Terms and conditions * * @return void */ public function termsAndConditionsAction() { $form = $this->getFormFactory()->create(new RootStepType(new TermsAndConditionsType()), $this->getSystemProgressiveStore()->fetch(self::MODEL_APPLICATION_CLASS)); if ($this->getSymfonyRequest()->isMethod('POST')) { $form->submit($this->getSymfonyRequest()); $this->getFormFlow()->setForm($form); if ($form->get('back')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getBackUrl()); } if ($form->isValid()) { $paymentStatusResponse = null; $application = $this->getSystemProgressiveStore()->getPrototypeByClass(self::MODEL_APPLICATION_CLASS); try { /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\PaymentStatus $paymentStatusResponse */ $paymentStatusResponse = $this->getIrisSystemContext()->getSystemApplicationClient()->paymentStatus(array('applicationUuId' => $application->getReferencingApplicationUuId())); } catch (ValidationException $e) { $this->getFormValidationErrorBinder()->bind($form, $e); } if ($paymentStatusResponse) { if ($form->get('next')->isClicked()) { $paymentStatus = $paymentStatusResponse->getPaymentStatus(); // note: Don't like the id numbers, should be strings if (2 == $paymentStatus || 4 == $paymentStatus || 5 == $paymentStatus) { // Payment complete, move straight to submission $this->getIrisSystemContext()->getSystemApplicationClient()->submitApplication(array('referencingApplicationUuId' => $application->getReferencingApplicationUuId())); $this->_helper->redirector->gotoUrlAndExit($this->params->homelet->domain . $this->getFormFlow()->getNextUrl()); } else { // Payment pending, create an order $paymentOrderResponse = null; try { /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\PaymentOrder $paymentOrderResponse */ $paymentOrderResponse = $this->getIrisSystemContext()->getSystemApplicationClient()->paymentOrder(array('applicationUuId' => $application->getReferencingApplicationUuId(), 'paymentTypes' => array(1), 'redirectOnSuccessUrl' => $this->params->homelet->domain . $this->getFormFlow()->getNextUrl())); } catch (ValidationException $e) { $this->getFormValidationErrorBinder()->bind($form, $e); } if ($paymentOrderResponse) { $this->_helper->redirector->gotoUrlAndExit($paymentOrderResponse->getPaymentPortalStartUrl()); } } } } } } $sysAppclientContext = $this->getIrisSystemContext()->getSystemApplicationClient(); $declarationOwnership = new DeclarationOwnership(); $agentSchemeNumber = $declarationOwnership->getAgentSchemeNumberByLinkRef($sysAppclientContext, $this->authSession->linkRef); $canDisplayDeclaration = $declarationOwnership->canDisplayDeclaration($agentSchemeNumber); $this->renderTwigView('/iris-complete-reference/generic-step.html.twig', array('bodyTitle' => 'Terms and Conditions', 'formTheme' => 'form/complete-terms-and-conditions-widgets.html.twig', 'form' => $form->createView(), 'canDisplayDeclaration' => $canDisplayDeclaration)); }