protected function _privateLandlordTerms() { $session = new Zend_Session_Namespace('referencing_global'); $session->currentFlowItem = Model_Referencing_DataEntry_FlowItems::TERMS; $termsForm = new LandlordsReferencing_Form_Terms(); $request = $this->getRequest(); $data = $request->getPost(); $referenceManager = new Manager_Referencing_Reference(); $reference = $referenceManager->getReference($session->referenceId); //Check if the terms were previously agreed by the tenant. If yes, disable the controls and require the PLL to agree to the terms only. $progressManager = new Manager_Referencing_Progress(); $progressItem = $progressManager->findSpecificProgressItem($reference->progress, Model_Referencing_ProgressItemVariables::TERMS_AGREED); if (!empty($progressItem) && $progressItem->itemState == Model_Referencing_ProgressItemStates::COMPLETE) { if ($request->isPost()) { $termsForm->setClearValidators(true); if ($termsForm->isValid($data)) { //Capture the data. if ($data['terms_agreed'] == 'Yes') { //Push to munt now that all data is completed and the PLL has agreed to //the terms. $this->_pushToMunt($reference); $this->_despatchToNext(); return; } } else { $previouslyLoaded = "var previouslyLoaded = true;\n"; $this->view->headScript()->appendScript($previouslyLoaded, $type = 'text/javascript'); } } // Get the declaration version $declarationVersion = $this->_getDeclarationVersion(); //Check or uncheck tbe DPA controls according to the reference subject's preferences. $dpaManager = new Manager_Core_DataProtection(); $dpaItems = $dpaManager->getItems($session->referenceId, Model_Core_DataProtection_ItemEntityTypes::REFERENCING); foreach ($dpaItems as $item) { if ($item->isAllowed) { $isChecked = true; } else { $isChecked = false; } $element = null; switch ($item->constraintTypeId) { case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_NONDIGITAL_MEANS: $element = $termsForm->consent_nondigital_marketing; $element->setChecked(3 == $declarationVersion ? !$isChecked : $isChecked); $element->setAttrib('disabled', 'disabled'); break; case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_DIGITAL_MEANS: $element = $termsForm->consent_digital_marketing; // If this is declaration version 3, invert preference $element->setChecked($isChecked); $element->setAttrib('disabled', 'disabled'); break; default: throw new Zend_Exception(); } } $termsForm->consent_information_stored->setChecked(true); $termsForm->consent_information_stored->setAttrib('disabled', 'disabled'); $termsForm->consent_referee->setChecked(true); $termsForm->consent_referee->setAttrib('disabled', 'disabled'); } else { //Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = "terms";'); //If here then the PLL has logged the reference without emailing a link to the tenant. if ($termsForm->isValid($data)) { //Capture the data. if ($data['terms_agreed'] == 'Yes') { $this->_storeDataProtections(); $this->_pushToMunt($reference); $this->_despatchToNext(); return; } } else { $previouslyLoaded = "var previouslyLoaded = true;\n"; $this->view->headScript()->appendScript($previouslyLoaded, $type = 'text/javascript'); } } $termsForm->populate($termsForm->getValues()); //Set this to whatever you want the progress bar to how in percents $this->view->fractionComplete = 95; $this->view->form = $termsForm; }
/** * Validate a form page's values via AJAX * * @return void */ public function validatePageAction() { $return = array(); $session = new Zend_Session_Namespace('referencing_global'); $postData = $this->getRequest()->getParams(); $page = $postData['page']; switch ($page) { case 'register': $ajaxForm = new LandlordsReferencing_Form_Register(); break; case 'login': $ajaxForm = new LandlordsReferencing_Form_Login(); break; case 'property-lease': $ajaxForm = new LandlordsReferencing_Form_PropertyLease(); break; case 'product-selection': $ajaxForm = new LandlordsReferencing_Form_ProductSelection(); break; case 'prospective-landlord': $ajaxForm = new LandlordsReferencing_Form_ProspectiveLandlord(); break; case 'reference-subject': $ajaxForm = new LandlordsReferencing_Form_ReferenceSubject(); break; case 'current-landlord': $ajaxForm = new LandlordsReferencing_Form_CurrentLandlord(); break; case 'current-occupation': case 'future-occupation': $ajaxForm = new LandlordsReferencing_Form_Occupation(); break; case 'first-residence': case 'second-residence': case 'third-residence': $ajaxForm = new LandlordsReferencing_Form_Residence(); break; case 'terms': $ajaxForm = new LandlordsReferencing_Form_Terms(); break; default: return; } $valid = $ajaxForm->isValid($postData); if (!$valid) { $errorMessages = $ajaxForm->getMessagesFlattened(); // We need to strip out some complex messages that the end user won't care about if (isset($errorMessages['email_address'])) { if (isset($errorMessages['email_address']['hostnameUnknownTld'])) { unset($errorMessages['email_address']['hostnameUnknownTld']); } if (isset($errorMessages['email_address']['hostnameLocalNameNotAllowed'])) { unset($errorMessages['email_address']['hostnameLocalNameNotAllowed']); } } $return['errorJs'] = $errorMessages; $return['errorCount'] = count($errorMessages); $return['errorHtml'] = $this->view->partial('partials/error-list.phtml', array('errors' => $errorMessages)); $return['postData'] = $postData; } else { $return['errorJs'] = ''; $return['errorCount'] = ''; $return['errorHtml'] = ''; $return['postData'] = $postData; } echo Zend_Json::encode($return); }