Ejemplo n.º 1
0
 /**
  * Records a TAT notification email in the datasource.
  *
  * Will not record a TAT notification if a TAT is not applicable for
  * the reference.
  *
  * @param string $enquiryId
  * Identifies the reference. Can be either the IRN or the ERN.
  *
  * @param string $content
  * The email content that was sent to the reference subject.
  *
  * @return void
  */
 public function logTatNotification($enquiryId, $content)
 {
     //Ensure no logging of non-applicable references.
     $tatManager = new Manager_Referencing_Tat($enquiryId);
     if ($tatManager->isTatApplicable()) {
         $tatNotification = new Model_Referencing_TatNotification();
         $tatNotification->enquiryId = $tatManager->_reference->externalId;
         $tatNotification->sendDate = Zend_Date::now();
         $tatNotification->content = $content;
         $tatNotifications = new Datasource_Referencing_TatNotification();
         $tatNotifications->insertNotification($tatNotification);
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns a TAT object encapsulating details of the Enquiry.
  *
  * @param void
  * The unique Enquiry identifier (internal or external). May be integer or string.
  *
  * @return mixed
  * Returns a Model_Referencing_Tat object holds details of the reference,
  * or null if not found.
  */
 public function getTat()
 {
     $tat = new Model_Referencing_Tat();
     //Set the isInvitationSent attribute.
     $tatDatasource = new Datasource_Referencing_TatInvitation();
     $tat->isInvitationSent = $tatDatasource->getIsTatInvitationSent($this->_reference->externalId);
     //Set the referenceSubject attribute.
     $referenceSubject = $this->_reference->referenceSubject;
     $tat->referenceSubject = $referenceSubject;
     //Set the propertyLease attribute.
     $tat->propertyLease = $this->_reference->propertyLease;
     //Arrive at the Enquiry state by a cascade: Start by assuming the Enquiry state is complete.
     $tat->enquiryStatus = Model_Referencing_TatStates::REFERENCE_COMPLETE;
     //Next identify if the state should be changed to 'In Progress' based on the
     //current Enquiry conclusion
     switch ($this->_reference->status->state) {
         case Model_Referencing_ReferenceStates::INPROGRESS:
         case Model_Referencing_ReferenceStates::INCOMPLETE:
             $tat->enquiryStatus = Model_Referencing_TatStates::REFERENCE_INPROGRESS;
             break;
     }
     $progressItem = Manager_Referencing_Progress::findSpecificProgressItem($this->_reference->progress, Model_Referencing_ProgressItemVariables::FINISHED);
     //Finally, override the conclusion if the progress result is not complete.
     if ($progressItem->itemState != Model_Referencing_ProgressItemStates::COMPLETE) {
         //The progress object also has to indicate complete - this will allow us to detect
         //references that have been reopened.
         $tat->enquiryStatus = Model_Referencing_TatStates::REFERENCE_INPROGRESS;
     }
     //Set the occupation attributes.
     foreach ($referenceSubject->occupations as $occupation) {
         //Set the occupation reference status.
         if (empty($occupation->referencingDetails)) {
             $isReferencedString = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
         } else {
             if ($occupation->isComplete) {
                 $isReferencedString = Model_Referencing_TatStates::REFERENCE_ITEM_COMPLETE;
             } else {
                 $isReferencedString = Model_Referencing_TatStates::REFERENCE_ITEM_INPROGRESS;
             }
         }
         //Now identify which occupation we are dealing with.
         if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) {
             $tat->futureOccupationReferenceStatus = $isReferencedString;
         } else {
             if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) {
                 if ($occupation->importance == Model_Referencing_OccupationImportance::FIRST) {
                     $tat->currentOccupationReferenceStatus = $isReferencedString;
                 } else {
                     $tat->secondOccupationReferenceStatus = $isReferencedString;
                 }
             }
         }
     }
     //Some of the occupation attributes may not be applicable. Set them to N/A as appropriate.
     if (empty($tat->currentOccupationReferenceStatus)) {
         $tat->currentOccupationReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     }
     if (empty($tat->secondOccupationReferenceStatus)) {
         $tat->secondOccupationReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     }
     if (empty($tat->futureOccupationReferenceStatus)) {
         $tat->futureOccupationReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     }
     //Set the landlord attribute.
     $residenceManager = new Manager_Referencing_Residence();
     $currentResidence = $residenceManager->findSpecificResidence($this->_reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
     if ($currentResidence->status != Model_Referencing_ResidenceStatus::TENANT) {
         $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     } else {
         if (empty($currentResidence->referencingDetails)) {
             $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_INPROGRESS;
         } else {
             if ($currentResidence->referencingDetails->submissionType == null) {
                 $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_INPROGRESS;
             } else {
                 $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_COMPLETE;
             }
         }
     }
     //Set the missing information attribute.
     /*
             $productName = $enquiry->productSelection->product->name;
             $flowManager = Manager_Referencing_DataEntry_Flow_FlowFactory::createFlowManager($productName);
     		$missingInformationManager = new Manager_Referencing_DataEntry_MissingInformation_Despatcher();
     		$missingInfoList = array();
     		do {
     
     	$missingInfoSubList = $missingInformationManager->getMissingInformation($enquiry->externalId, $flowManager->currentFlowItem);
     	if(!empty($missingInfoSubList)) {
     
     		foreach($missingInfoSubList as $subListItem) {
     
     			$missingInfoList[] = $subListItem;
     		}
     	}
     }
     while($flowManager->moveToNext($enquiryId));
     $tat->missingInformation = $missingInfoList;
     */
     //Use the legacy missing information manager until the new one is fully operational.
     $missingInformationManager = new Manager_Referencing_DataEntry_MissingInformation_Legacy();
     $tat->missingInformation = $missingInformationManager->getMissingInformation($this->_reference);
     //Set the tat notifications.
     $tatNotifications = new Datasource_Referencing_TatNotification();
     $tat->tatNotifications = $tatNotifications->getByEnquiry($this->_reference->externalId);
     return $tat;
 }