/**
  * Returns the property aspect items relating to a reference.
  *
  * @param string $enquiryId
  * The unique external Enquiry identifier.
  *
  * @return mixed
  * An array of Model_Referencing_PropertyAspects_PropertyAspectItem objects,
  * or null if none found.
  */
 public function getAspects($enquiryId)
 {
     //Convert the external enquiry identifier to internal.
     $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry();
     $id = $enquiryDatasource->getInternalIdentifier($enquiryId);
     $select = $this->select();
     $select->where('enquiry_id = ? ', $id);
     $rows = $this->fetchAll($select);
     $returnVal = null;
     if (count($rows) != 0) {
         $returnVal = array();
         foreach ($rows as $currentRow) {
             $aspectItem = new Model_Referencing_PropertyAspects_PropertyAspectItem();
             $aspectItem->referenceId = $id;
             $aspectItem->propertyAspectId = $currentRow->property_aspect_id;
             $aspectItem->value = $currentRow->value;
             $returnVal[] = $aspectItem;
         }
     }
     return $returnVal;
 }
 /**
  * Unsubscribes a reference from any further marketing.
  * 
  * @param string $enquiryId
  * The external enquiry identifier.
  * 
  * @return boolean
  * True on successful update, false otherwise.
  */
 public function unsubscribe($enquiryId)
 {
     $enquiry = new Datasource_ReferencingLegacy_Enquiry();
     $enquiryId = $enquiry->getInternalIdentifier($enquiryId);
     if (empty($enquiryId)) {
         return false;
     }
     //Update.
     $data = array('is_allowed' => 0);
     $where = $this->quoteInto('enquiry_id = ? AND data_protection_id = 1', $enquiryId);
     if ($this->update($data, $where) > 0) {
         $isPhonePostChanged = true;
     } else {
         $isPhonePostChanged = false;
     }
     $where = $this->getAdapter()->quoteInto('enquiry_id = ? AND data_protection_id = 3', $enquiryId);
     if ($this->update($data, $where) > 0) {
         $isSmsEmailChanged = true;
     } else {
         $isSmsEmailChanged = false;
     }
     $where = $this->getAdapter()->quoteInto('enquiry_id = ? AND data_protection_id = 4', $enquiryId);
     if ($this->update($data, $where) > 0) {
         $isNonDigitalPreferencehanged = true;
     } else {
         $isNonDigitalPreferencehanged = false;
     }
     $where = $this->getAdapter()->quoteInto('enquiry_id = ? AND data_protection_id = 5', $enquiryId);
     if ($this->update($data, $where) > 0) {
         $isDigitalPreferencehanged = true;
     } else {
         $isDigitalPreferencehanged = false;
     }
     //Insertion was successful. Make a note of this in the data protection
     //audit table.
     $audit = new Datasource_ReferencingLegacy_DataProtectionAudits();
     $audit->unsubscribeFromTenantMailer($enquiryId, $isPhonePostChanged, $isSmsEmailChanged, $isNonDigitalPreferencehanged, $isDigitalPreferencehanged);
     return true;
 }
Esempio n. 3
0
 /**
  * Retrieves all occupation details against a specific Enquiry.
  *
  * @param string $enquiryId
  * The unique external Enquiry identifier.
  *
  * @return mixed
  * An array of Model_Referencing_Occupation objects, or null if no
  * occuapations are found.
  *
  * @todo
  * Occupation referee details are not yet captured and stored.
  */
 public function getAllByEnquiry($enquiryId)
 {
     $returnArray = array();
     //First check if the reference subject is a student or unemployed - neither of these
     //occupations are stored in the employment table.
     $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry();
     $legacyEmploymentType = $enquiryDatasource->getLegacyEmploymentType($enquiryId);
     if ($enquiryDatasource->getIdentifierType($enquiryId) == Model_Referencing_ReferenceKeyTypes::EXTERNAL) {
         $referenceId = $enquiryDatasource->getInternalIdentifier($enquiryId);
     } else {
         $referenceId = $enquiryId;
     }
     if ($legacyEmploymentType == 'Unemployed') {
         $occupation = new Model_Referencing_Occupation();
         $occupation->referenceId = $referenceId;
         $occupation->importance = Model_Referencing_OccupationImportance::FIRST;
         $occupation->chronology = Model_Referencing_OccupationChronology::CURRENT;
         $occupation->type = Model_Referencing_OccupationTypes::UNEMPLOYMENT;
         $occupation->isPermanent = true;
         $occupation->income = new Zend_Currency(array('precision' => 0, 'value' => 0));
         //Referees and referencing are not applicable for this occupation status.
         $occupation->refereeDetails = null;
         $occupation->referencingDetails = null;
         $returnArray[] = $occupation;
     } else {
         if ($legacyEmploymentType == 'Student') {
             $occupation = new Model_Referencing_Occupation();
             $occupation->referenceId = $referenceId;
             $occupation->importance = Model_Referencing_OccupationImportance::FIRST;
             $occupation->chronology = Model_Referencing_OccupationChronology::CURRENT;
             $occupation->type = Model_Referencing_OccupationTypes::STUDENT;
             $occupation->isPermanent = true;
             $occupation->income = new Zend_Currency(array('precision' => 0, 'value' => 0));
             //Referees and referencing are not applicable for this occupation status.
             $occupation->refereeDetails = null;
             $occupation->referencingDetails = null;
             $returnArray[] = $occupation;
         }
     }
     //Now identify the occupations recorded in the employment table.
     $select = $this->select();
     $select->where('enquiryRefno = ? ', (string) $enquiryId);
     $occupationsArray = $this->fetchAll($select);
     if (!empty($occupationsArray)) {
         foreach ($occupationsArray as $occupationRow) {
             $occupation = new Model_Referencing_Occupation();
             $occupation->id = $occupationRow->refno;
             $occupation->referenceId = $referenceId;
             $occupation->importance = $this->_getOccupationimportance($occupationRow->Jobstatus);
             $occupation->chronology = $this->_getOccupationalChronology($occupationRow->Jobstatus);
             //The $occupationRow->type refers to the occupational confirmation type, i.e. the
             //person or means by which the reference will be provided. Therefore it needs to be
             //translated into a type.
             $occupation->type = $this->_getOccupationType($occupationRow->type);
             if ($occupationRow->permanent == 'Yes') {
                 $occupation->isPermanent = true;
             } else {
                 $occupation->isPermanent = false;
             }
             if (!empty($occupationRow->salary)) {
                 $occupation->income = new Zend_Currency(array('precision' => 0, 'value' => $occupationRow->salary));
             }
             if ($occupationRow->startdate != '0000-00-00') {
                 $occupation->startDate = new Zend_Date($occupationRow->startdate, Zend_Date::ISO_8601);
             }
             if ($occupationRow->complete == 1) {
                 $occupation->isComplete = true;
             } else {
                 $occupation->isComplete = false;
             }
             //Assign the occupation variables, if applicable.
             $variables = array();
             if ($occupationRow->enddate != '0000-00-00') {
                 $endDate = new Zend_Date($occupationRow->enddate, Zend_Date::ISO_8601);
                 $variables[Model_Referencing_OccupationVariables::ENDDATE] = $endDate;
             }
             $position = $occupationRow->positionheld;
             if (!empty($position)) {
                 $variables[Model_Referencing_OccupationVariables::POSITION] = $position;
             }
             $payrollNo = $occupationRow->payrollno;
             if (!empty($payrollNo)) {
                 $variables[Model_Referencing_OccupationVariables::PAYROLL_NUMBER] = $payrollNo;
                 $variables[Model_Referencing_OccupationVariables::PENSION_NUMBER] = $payrollNo;
             }
             if (!empty($variables)) {
                 $occupation->variables = $variables;
             }
             //Add the referee details and reference details.
             $occupationalReferees = new Datasource_ReferencingLegacy_OccupationalReferees();
             $occupation->refereeDetails = $occupationalReferees->getOccupationalReferee($occupationRow->refno);
             $occupationalReferences = new Datasource_ReferencingLegacy_OccupationalReferences();
             $occupation->referencingDetails = $occupationalReferences->getByEnquiry($enquiryId, $occupation->chronology, $occupation->importance);
             $returnArray[] = $occupation;
         }
     }
     return $returnArray;
 }