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;
 }