public function indexAction()
 {
     $agentSchemeNumber = $this->getRequest()->getParam('asn');
     $agents = new Manager_Core_Agent();
     $agent = $agents->getAgent($agentSchemeNumber);
     $this->view->tradingName = $agent->name;
     $this->view->schemeNumber = $agent->agentSchemeNumber;
     $this->view->commissionRate = $agent->commissionRate * 100;
     $this->view->newBusinessCommissionRate = $agent->newBusinessCommissionRate * 100;
     Zend_Debug::dump($agent->contact);
     foreach ($agent->contact as $contactDetails) {
         if ($contactDetails->category == Model_Core_Agent_ContactMapCategory::OFFICE) {
             // @todo Commented out to allow tests to run - repair
             /*
             $this->view->contactAddress1 = '';
             if ($contactDetails->flatNumber) $this->view->contactAddressLine1 .= $contactDetails->flatNumber . ' ';
             if ($contactDetails->houseNumber) $this->view->contactAddressLine1 .= $contactDetails->houseNumber . ' ';
             if ($contactDetails->houseName) $this->view->contactAddressLine1 .= $contactDetails->houseName . ' ';
             if ($contactDetails->addressLine1)
             {
                 $this->view->contactAddressLine1 .= $contactDetails->addressLine1 . ' ';
                 $this->view->contactAddressLine2 = $contactDetails->addressLine2;
             } else {
                 $this->view->contactAddressLine1 .= $contactDetails->addressLine2 . ' ';
             }
             */
             $this->view->contactTown = $contactDetails->address->town;
             $this->view->contactPostcode = $contactDetails->address->postCode;
         }
     }
     Zend_Debug::dump($agent);
 }
 /**
  * Popup box for agent search
  */
 public function agentSearchAction()
 {
     $this->_helper->layout->disableLayout();
     if ($this->getRequest()->isPost()) {
         // Perform search and show results
         $postData = $this->getRequest()->getPost();
         $agentSearchResults = array();
         $agents = new Manager_Core_Agent();
         if (isset($postData['agentnumber'])) {
             // We have an agent scheme number so this should be easy
             try {
                 $agent = $agents->getAgent($postData['agentnumber']);
             } catch (Exception $e) {
                 // TODO: Handle - Failed to find a match
             }
             $agentSearchResults[] = array('schemeNumber' => $agent->getSchemeNumber(), 'hNumber' => $agent->getHNumber(), 'name' => $agent->getName());
         }
         $this->view->agents = $agentSearchResults;
         /*array(
          		array('schemeNumber'	=>	 '1501062', 'hNumber'	=>	'7292',	'name'	=>	'Ash Property Management Ltd'),
          		array('schemeNumber'	=>	 '1403587', 'hNumber'	=>	'5437',	'name'	=>	'Belvoir Property Management'),
          		array('schemeNumber'	=>	 '1403454', 'hNumber'	=>	'5128',	'name'	=>	'Chance Option Developments Ltd'),
          		array('schemeNumber'	=>	 '1322742', 'hNumber'	=>	'5101',	'name'	=>	'Hodgson Elkington LLP')
         		);*/
         $this->render('agent-search-results');
     } else {
         // Show the search form
         $searchForm = new AgentAdminSuite_Form_AgentSearch();
         if ($this->getRequest()->isPost()) {
             $searchForm->isValid($_POST);
         }
         $this->view->form = $searchForm;
     }
 }
 public function init()
 {
     $this->_params = Zend_Registry::get('params');
     // If the user isn't logged in - force them onto the login action
     $this->_auth = Zend_Auth::getInstance();
     $this->_auth->setStorage(new Zend_Auth_Storage_Session('hl_connect'));
     $this->_hasAuth = $this->_auth->hasIdentity();
     if ($this->_hasAuth) {
         // Set private class vars, including complete agent object
         $this->_agentSchemeNumber = $this->_auth->getStorage()->read()->agentschemeno;
         $this->_agentId = $this->_auth->getStorage()->read()->agentid;
         $this->_level = $this->_auth->getStorage()->read()->level;
         $this->_fsastatusabbr = $this->_auth->getStorage()->read()->fsastatusabbr;
         $this->_agentrealname = $this->_auth->getStorage()->read()->realname;
         $this->_agentUserName = $this->_auth->getStorage()->read()->username;
         $this->_agentsRateID = $this->_auth->getStorage()->read()->agentsRateID;
         // Pass IRIS detection flag to controller
         $this->_isAgentInIris = $this->_auth->getStorage()->read()->isInIris;
         $this->_canPerformReferencing = $this->_auth->getStorage()->read()->canPerformReferencing;
         if ($this->_isAgentInIris) {
             // Pass IRIS agent branch UUID too
             $this->_irisAgentBranchUuid = $this->_auth->getStorage()->read()->agentBranchUuid;
         }
         $agentManager = new Manager_Core_Agent();
         $this->_agentObj = $agentManager->getAgent($this->_agentSchemeNumber);
     }
     if ($this->context == 'web') {
         $this->initWeb();
     }
 }
Example #4
0
 public function isValid($formData = array())
 {
     // Call original isValid() first before doing further validation checks
     //    $isValid=parent::isValid($formData);
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect'));
     // Get ASN from auth object
     $agentSchemeNumber = $auth->getStorage()->read()->agentschemeno;
     if ($formData['question1'] === 'yes') {
         $this->getElement('claiminfo')->setRequired(true);
     } else {
         $this->getElement('claiminfo')->setRequired(false);
     }
     if (isset($formData['email_address']) && trim($formData['email_address']) != '') {
         // The agent manager can throw execptions, for web use we need to treat them as invalid and return false
         $agentManager = new Manager_Core_Agent();
         $agentObj = $agentManager->getAgent($agentSchemeNumber);
         // Get referencing email address (Cat 2)
         $ref_email_address = $agentManager->getEmailAddressByCategory(2);
         // Referencing email address is not allowed
         if ($formData['email_address'] === $ref_email_address) {
             $this->getElement('email_address')->addError('Please provide Landlord email address.');
             $isValid = false;
         }
         // Confirmed email address filed value should be same as email address field value
         if (isset($formData['confirm_email_address']) && trim($formData['confirm_email_address']) != '') {
             if ($formData['email_address'] !== $formData['confirm_email_address']) {
                 $this->getElement('confirm_email_address')->addError('Invalid confirmed email address.');
                 $isValid = false;
             }
         }
     }
     //    return $isValid;
     return parent::isValid($formData);
 }
 public function salesperson($asn, $size = 'small')
 {
     // First get agent and agent's salesperson ID
     $agentManager = new Manager_Core_Agent();
     $agent = $agentManager->getAgent($asn);
     // Look up salesperson by ID
     $salesPersonManager = new Manager_Core_Salesperson();
     $salesperson = $salesPersonManager->getSalesperson($agent->salespersonId);
     // Convert date answer into since string
     foreach ($salesperson->questionAnswers as $key => $questionAnswer) {
         // Look out for date-only answer, needs to be converted into
         // an "x ago" friendly string
         if (preg_match('/^\\d{4}-\\d\\d-\\d\\d$/', $questionAnswer->answer) > 0) {
             $salesperson->questionAnswers[$key]->answer = $this->_dateToSinceString($questionAnswer->answer);
         }
     }
     return $this->view->partial('partials/salesperson.phtml', array('agent' => $agent, 'salesperson' => $salesperson, 'size' => $size));
 }
Example #6
0
 /**
  * Returns an active MOTD that is applicable to the agent user.
  *
  * If no MOTDs are applicable to the agent user, then this method will
  * return null.
  *
  * @param integer $agentId
  * Identifies the agent user.
  *
  * @param integer $agentSchemeNumber
  * Identifies the agent user's scheme number.
  *
  * @return mixed
  * Returns a MOTD, if an applicable one can be found from the list of active
  * MOTDs. Otherwise will return null.
  */
 function getMotd($agentId, $agentSchemeNumber)
 {
     // First identify if any active MOTDs
     if (empty($this->_allActiveMotds)) {
         return null;
     }
     // Determine the agent user type (basic or master)
     $agentUser = new Manager_Core_Agent_User($agentId);
     $agentUserType = $agentUser->getUserRole();
     // Determine the agent type (standard, premier or premier-plus)
     $agentManager = new Manager_Core_Agent($agentSchemeNumber);
     $agent = $agentManager->getAgent();
     $agentType = $agent->premierStatus;
     $isMotdRequired = false;
     foreach ($this->_allActiveMotds as $currentMotd) {
         //Identify if the MOTD applies to the agent user type.
         $agentUserTypesList = $currentMotd->getAgentUserTypes();
         $agentUserTypes = explode(',', $agentUserTypesList);
         if (!in_array($agentUserType, $agentUserTypes)) {
             continue;
         }
         //Identify if the MOTD applies to the agent type.
         $agentTypesList = $currentMotd->getAgentTypes();
         $agentTypes = explode(',', $agentTypesList);
         if (!in_array($agentType, $agentTypes)) {
             continue;
         }
         //Identify if the agent user has viewed the MOTD already.
         if ($this->_motdAcceptanceLoggerDatasource->checkMotdAccepted($currentMotd->getId(), $agentId)) {
             continue;
         }
         //If here then the _currentMotd should be displayed to the user.
         $isMotdRequired = true;
         break;
     }
     if ($isMotdRequired) {
         $returnVal = $currentMotd;
     } else {
         $returnVal = null;
     }
     return $returnVal;
 }
Example #7
0
 /**
  * Opens a PDF from local storage, populates it with agent details (if
  * needed) and outputs it to either browser or by e-mail.
  *
  * @param string $formName The name of the PDF form, or 'all' for all by e-mail.
  * @param mixed $asn Agent scheme number of agent whose details are to be inserted.
  * @param int $agentUserId Optional user ID - needed for e-mailing forms.
  * @param string $destination Optional output mechanism, if set should be 'browser' or not 'browser'.
  * @param mixed $refno Optional reference number, for a special case PDF that requires applicant data injection.
  */
 public function populateAndOuput($formName, $asn, $agentUserId = null, $destination = 'browser', $refno = null)
 {
     $attachmentList = array();
     switch ($formName) {
         // Forms that require agent details to be injected
         case 'Agent-Company':
         case 'Agent-Guarantor':
         case 'Agent-Individual':
         case 'Agent-Student-guarantor':
         case 'Agent-Unemployed-guarantor':
             // Instantiate agent manager and fetch agent details
             $agentManager = new Manager_Core_Agent();
             $agent = $agentManager->getAgent($asn);
             // Shove agent details through form
             $this->setForm($formName);
             $this->agentPopulate($agent);
             // For "Print Guarantor Form" from ref summary screen:
             if (!is_null($refno)) {
                 // Fetch reference by refno using the Referencing MUNT Manager class
                 $refMuntManager = new Manager_ReferencingLegacy_Munt();
                 $reference = $refMuntManager->getReference($refno);
                 // For safety, ensure reference belongs to this ASN before injecting applicant details
                 if ($reference->customer->customerId == $asn) {
                     $this->applicantPopulate($reference);
                 }
             }
             if ($destination == 'browser') {
                 $this->output('browser');
             } else {
                 $attachmentList[$formName] = $this->output('file');
             }
             break;
             // Forms that are a pass-through
         // Forms that are a pass-through
         case 'Tenant-Declaration':
         case 'Guarantor-Declaration':
             $this->setForm($formName);
             if ($destination == 'browser') {
                 $this->output('browser');
             } else {
                 $attachmentList[$formName] = $this->output('file');
             }
             break;
             // Send all forms - by e-mail only
         // Send all forms - by e-mail only
         case 'all':
             // Instantiate agent manager and fetch agent details
             $agentManager = new Manager_Core_Agent();
             $agent = $agentManager->getAgent($asn);
             // Generate those needing agent data merged in
             foreach (array('Agent-Company', 'Agent-Guarantor', 'Agent-Individual', 'Agent-Student-guarantor', 'Agent-Unemployed-guarantor') as $thisFormName) {
                 $this->setForm($thisFormName);
                 $this->agentPopulate($agent);
                 $attachmentList[$thisFormName] = $this->output('file');
             }
             // Generate straight throughs
             foreach (array('Tenant-Declaration', 'Guarantor-Declaration') as $thisFormName) {
                 $this->setForm($thisFormName);
                 $attachmentList[$thisFormName] = $this->output('file');
             }
             break;
     }
     // If there are attachments, this is/these are to be sent by e-mail
     if (count($attachmentList) > 0) {
         // Instantiate agent user manager to get name and e-mail address
         $agentUserManager = new Manager_Core_Agent_User();
         $agentUser = $agentUserManager->getUser($agentUserId);
         // Generate e-mail
         $mailer = new Application_Core_Mail();
         $mailer->setTo($agentUser->email->emailAddress, $agentUser->name);
         // TODO: Parameterise:
         $mailer->setFrom('*****@*****.**', 'HomeLet Referencing');
         $mailer->setSubject('HomeLet Referencing Application Form');
         $mailer->setBodyText('Please find your HomeLet referencing application forms attached.');
         foreach ($attachmentList as $name => $location) {
             $mailer->addAttachment($location, "{$name}.pdf");
         }
         $mailer->send();
         // Garbage collection
         $this->garbageCollect($attachmentList);
     }
 }
Example #8
0
 /**
  * Fetch the list of external news categories an agent is subscribing to.
  *
  * @param bool $filter Turn on/off filter by whether the agent wants to see
  * news, and whether the agency-level setting allows the viewing of news
  * (which takes precedence).
  *
  * @return array Array of news visibility (true for visible or false for
  * invisible), and news category ID => news category name tuples.
  */
 public function getUserExternalNewsPreferences($filter = true)
 {
     // Check we have an ASN and user ID set
     if (is_null($this->_agentSchemeNumber) || is_null($this->_userId)) {
         throw new Zend_Exception('ASN and/or user ID not specified');
     }
     // Fetch an agent user's details if need be
     if (is_null($this->_userObject)) {
         $this->getUser();
     }
     $returnVal = array();
     // Does this user want to see external news?
     if ($this->_userObject->enableExternalNews || !$filter) {
         // Invoke the agent manager
         $agentManager = new Manager_Core_Agent($this->_agentSchemeNumber);
         $agent = $agentManager->getAgent();
         // Does this agency allow seeing external news?
         if ($agent->enableExternalNews || !$filter) {
             // Use the external news category datasource to get the news category list for this agent user
             $externalNewsCategoryDatasource = new Datasource_Cms_ExternalNews_CategoriesAgentsMap();
             $returnVal = $externalNewsCategoryDatasource->getNewsPreferences($this->_userId);
         }
     }
     return array($this->_userObject->enableExternalNews, $returnVal);
 }
Example #9
0
 /**
  * Policies must not be added to REF only status accounts, or agents
  * with an 'onhold' status. This method checks the ASN against the FSA status
  * and the agent status, and if either are impermissable then the default
  * ASN is returned.
  *
  * @param mixed $asn Agent scheme number to be filtered.
  * @return mixed Filtered agent scheme number.
  */
 public static function filterAsn($asn)
 {
     $params = Zend_Registry::get('params');
     $asn = preg_replace('/\\D/', '', $asn);
     //Test FSA status associated with incoming ASN
     if (self::getFsaStatusCodeStatic($asn) == 'REF') {
         $asn = $params->homelet->defaultAgent;
     } else {
         //Test to ensure that the agent is not onhold.
         $agentManager = new Manager_Core_Agent();
         $agent = $agentManager->getAgent($asn);
         if ($agent->status == Model_Core_Agent_Status::ON_HOLD || $agent->status == Model_Core_Agent_Status::CANCELLED) {
             $asn = $params->homelet->defaultAgent;
         }
     }
     return $asn;
 }
 /**
  * Helper function to populate the zend form elements with database data
  *
  * @param Zend_Form $pageForm form definition for this step
  * @param int $stepNum current step number
  *
  * @return void
  */
 private function _formStepCommonPopulate($pageForm, $stepNum)
 {
     $pageSession = new Zend_Session_Namespace('online_claims');
     // First of all check that this form should be viewable and the user isn't trying to skip ahead
     $this->view->stepNum = $stepNum;
     $this->view->stepMax = $this->_stepMax;
     // Check to see if the user is trying to skip ahead in the claim
     $tooFarAhead = false;
     $lastCompleted = 1;
     if ((!isset($pageSession->completed) || is_null($pageSession->completed)) && $stepNum != 1) {
         $tooFarAhead = true;
         $lastCompleted = 1;
     } elseif ($stepNum > 1) {
         // Check to see if any pages previous to the one the user's trying to get to are incomplete
         $tooFarAhead = false;
         for ($i = 1; $i < $stepNum; $i++) {
             if (!isset($pageSession->completed[$i]) || !$pageSession->completed[$i]) {
                 $tooFarAhead = true;
                 $lastCompleted = $i;
                 break;
             }
         }
     }
     if ($tooFarAhead) {
         // Drop user onto page that needs completing
         $response = $this->getResponse();
         $response->setRedirect('/rentguaranteeclaims/step' . $lastCompleted);
         $response->sendResponse();
         return false;
     }
     $formData = array();
     $agentManager = new Manager_Core_Agent();
     $agentDetails = $agentManager->getAgent($this->_agentSchemeNumber);
     // Populate the agents details
     $formData['agent_schemenumber'] = $this->_agentSchemeNumber;
     $formData['agent_name'] = $agentDetails->getName();
     $formData['agent_postcode'] = $agentDetails->contact[0]->address->getPostCode();
     $formData['agent_housename'] = $agentDetails->contact[0]->address->getHouseName();
     $agentStreet = $agentDetails->contact[0]->address->getAddressLine1();
     if ($agentStreet) {
         $agentStreet .= $agentStreet . ', ';
     }
     $agentStreet .= $agentDetails->contact[0]->address->getAddressLine2();
     $formData['agent_street'] = $agentStreet;
     $formData['agent_town'] = $agentDetails->contact[0]->address->getTown();
     $phones = $agentDetails->contact[0]->phoneNumbers->getTelephone();
     $formData['agent_telephone'] = $phones['telephone1'];
     $formData['agent_email'] = $agentManager->getEmailAddressByCategory(Model_Core_Agent_EmailMapCategory::GENERAL);
     $agentManager = new Manager_Core_Agent();
     $statusAbr = $agentManager->getFsaStatusCode($this->_agentSchemeNumber);
     $formData['agent_ar_by_barbon'] = in_array($statusAbr, array('NAR', 'AR')) == true ? 'Yes' : 'No';
     $formData['agent_dir_by_fca'] = in_array($statusAbr, array('DIR')) == true ? 'Yes' : 'No';
     if (isset($pageSession->ClaimReferenceNumber)) {
         // Only populate from DB if we are in session and have a reference number
         $claimReferenceNumber = $pageSession->ClaimReferenceNumber;
         // Populate $formData with data from model, if available
         $claimManager = new Manager_Insurance_RentGuaranteeClaim_Claim();
         $claim = $claimManager->getClaim($claimReferenceNumber, $this->_agentSchemeNumber);
         // Override agents data with data from claim if available
         if ($claim->getAgentHousename() != '') {
             $formData['agent_housename'] = $claim->getAgentHousename();
         }
         if ($claim->getAgentStreet() != '') {
             $formData['agent_street'] = $claim->getAgentStreet();
         }
         if ($claim->getAgentTown() != '') {
             $formData['agent_town'] = $claim->getAgentTown();
         }
         if ($claim->getAgentPostcode() != '') {
             $formData['agent_postcode'] = $claim->getAgentPostcode();
         }
         if ($claim->getAgentTelephone() != '') {
             $formData['agent_telephone'] = $claim->getAgentTelephone();
         }
         if ($claim->getAgentEmail() != '') {
             $formData['agent_email'] = $claim->getAgentEmail();
         }
         switch ($stepNum) {
             case 1:
                 // You and your Landlord section
                 $formData['agent_contact_name'] = $claim->getAgentContactName();
                 $formData['landlord1_name'] = $claim->getLandlord1Name();
                 $formData['landlord_company_name'] = $claim->getLandlordCompanyName();
                 $formData['landlord_postcode'] = $claim->getLandlordPostcode();
                 $formData['landlord_address_id'] = $claim->getLandlordAddressId();
                 $formData['landlord_address'] = $claim->getLandlordAddressId();
                 $formData['landlord_housename'] = $claim->getLandlordHouseName();
                 $formData['landlord_street'] = $claim->getLandlordStreet();
                 $formData['landlord_city'] = $claim->getLandlordCity();
                 $formData['landlord_town'] = $claim->getLandlordTown();
                 $formData['landlord_telephone'] = $claim->getLandlordTelephone();
                 $formData['landlord_email'] = $claim->getLandlordEmail();
                 $pageForm->isValid($formData);
                 break;
             case 2:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] || isset($pageSession->identifier[$stepNum]) && $pageSession->identifier[$stepNum]) {
                     //set step2 identifier
                     $pageSession->identifier[$stepNum] = true;
                     // get tenant and property details
                     $formData['housing_act_adherence'] = $claim->getHousingActAdherence();
                     $formData['tenancy_start_date'] = $claim->getTenancyStartDate();
                     $formData['tenancy_end_date'] = $claim->getTenancyEndDate();
                     $formData['original_cover_start_date'] = $claim->getOriginalCoverStartDate();
                     $formData['monthly_rent'] = $claim->getMonthlyRent();
                     $formData['tenancy_address_id'] = $claim->getTenancyAddressId();
                     $formData['tenancy_postcode'] = $claim->getTenancyPostcode();
                     $formData['tenancy_housename'] = $claim->getTenancyHouseName();
                     $formData['tenancy_street'] = $claim->getTenancyStreet();
                     $formData['tenancy_town'] = $claim->getTenancyTown();
                     $formData['tenancy_city'] = $claim->getTenancyCity();
                     $formData['tenancy_postcode'] = $claim->getTenancyPostcode();
                     $formData['tenancy_address'] = $claim->getTenancyAddress();
                     $formData['tenancy_housename'] = $claim->getTenancyHouseName();
                     $formData['tenancy_street'] = $claim->getTenancyStreet();
                     $formData['tenancy_town'] = $claim->getTenancyTown();
                     $formData['tenancy_city'] = $claim->getTenancyCity();
                     $formData['deposit_amount'] = $claim->getDepositAmount();
                     $formData['rent_arrears'] = $claim->getRentArrears();
                     $formData['tenant_vacated'] = $claim->getTenantVacated();
                     $formData['tenant_vacated_date'] = $claim->getTenantVacatedDate();
                     $formData['first_arrear_date'] = $claim->getFirstArrearDate();
                     $formData['deposit_received_date'] = $claim->getDepositReceivedDate();
                     $formData['recent_complaints'] = $claim->getRecentComplaints();
                     $formData['recent_complaints_further_details'] = $claim->getRecentComplaintsDetails();
                     $formData['policy_number'] = $claim->getPolicyNumber();
                     $formData['grounds_for_claim'] = $claim->getGroundsForClaim();
                     $formData['grounds_for_claim_further_details'] = $claim->getGroundsForClaimDetails();
                     $formData['arrears_at_vacant_possession'] = $claim->getArrearsAtVacantPossession();
                     $formData['tenantsforwarding_address_id'] = $claim->getTenantsForwardingAddressId();
                     $formData['tenantsforwarding_housename'] = $claim->getTenantsForwardingHouseName();
                     $formData['tenantsforwarding_street'] = $claim->getTenantsForwardingStreet();
                     $formData['tenantsforwarding_town'] = $claim->getTenantsForwardingTown();
                     $formData['tenantsforwarding_city'] = $claim->getTenantsForwardingCity();
                     $formData['tenantsforwarding_postcode'] = $claim->getTenantsForwardingPostcode();
                     $formData['tenant_occupation_confirmed_by_tel'] = $claim->getTenantsOccupationOfPropertyConfirmedByTel();
                     $formData['tenant_occupation_confirmed_by_tel_dateofcontact'] = $claim->getTenantsOccupationOfPropertyConfirmedByTelDate();
                     $formData['tenant_occupation_confirmed_by_tel_tenantname'] = $claim->getTenantsOccupationOfPropertyConfirmedByTelContact();
                     $formData['tenant_occupation_confirmed_by_email'] = $claim->getTenantsOccupationOfPropertyConfirmedByEmail();
                     $formData['tenant_occupation_confirmed_by_email_dateofcontact'] = $claim->getTenantsOccupationOfPropertyConfirmedByEmailDate();
                     $formData['tenant_occupation_confirmed_by_email_tenantname'] = $claim->getTenantsOccupationOfPropertyConfirmedByEmailContact();
                     $formData['tenant_occupation_confirmed_by_visit'] = $claim->getTenantsOccupationOfPropertyConfirmedByVisit();
                     $formData['tenant_occupation_confirmed_by_visit_dateofvisit'] = $claim->getTenantsOccupationOfPropertyConfirmedByVisitDate();
                     $formData['tenant_occupation_confirmed_by_visit_individualattending'] = $claim->getTenantsOccupationOfPropertyConfirmedByVisitIndividual();
                     $formData['tenant_occupation_confirmed_by_visit_tenantname'] = $claim->getTenantsOccupationOfPropertyConfirmedByVisitContact();
                     $formData['section21_served'] = $claim->getS21NoticeServed();
                     $formData['section21_expiry'] = $claim->getS21NoticeExpiry();
                     $formData['section21_moneydepositreceived'] = $claim->getS21NoticeMoneyDepositReceived();
                     $formData['section21_money_held_under_tds_deposit_scheme'] = $claim->getS21NoticeMoneyDepositHeldUnderTdsScheme();
                     $formData['section21_tds_complied_with'] = $claim->getS21NoticeTdsCompliedWith();
                     $formData['section21_tds_prescribed_information_to_tenant'] = $claim->getS21NoticeTdsPrescribedToTenant();
                     $formData['section21_landlord_deposit_in_property_form'] = $claim->getS21NoticeLandlordDepositInPropertyForm();
                     $formData['section21_returned_at_notice_serve_date'] = $claim->getS21NoticePropertyReturnedAtNoticeServeDate();
                     $formData['section8_served'] = $claim->getS8NoticeServed();
                     $formData['section8_expiry'] = $claim->getS8NoticeExpiry();
                     $formData['section8_demand_letter_sent'] = $claim->getS8NoticeDemandLetterSent();
                     $formData['section8_over18_occupants'] = $claim->getS8NoticeOver18Occupants();
                     // get guarantor details
                     $guarantorManager = new Manager_Insurance_RentGuaranteeClaim_Guarantor();
                     $getGuarantorInfo = $guarantorManager->getGuarantors($claimReferenceNumber);
                     $formData['total_guarantors'] = count($getGuarantorInfo);
                     $formData['totalguarantors'] = count($getGuarantorInfo);
                     $createDynamicGuarantorElement = 1;
                     foreach ($getGuarantorInfo as $setGuarantorInfo) {
                         Application_Core_FormUtils::createManualAddressInput($pageForm, 'guarantor_housename_' . $createDynamicGuarantorElement, 'guarantor_street_' . $createDynamicGuarantorElement, 'guarantor_town_' . $createDynamicGuarantorElement, 'guarantor_city_' . $createDynamicGuarantorElement);
                         $formData['guarantor_name_' . $createDynamicGuarantorElement] = $setGuarantorInfo['guarantor_name'];
                         $formData['guarantor_hometelno_' . $createDynamicGuarantorElement] = $setGuarantorInfo['hometelno'];
                         $formData['guarantor_worktelno_' . $createDynamicGuarantorElement] = $setGuarantorInfo['worktelno'];
                         $formData['guarantor_mobiletelno_' . $createDynamicGuarantorElement] = $setGuarantorInfo['mobiletelno'];
                         $formData['guarantor_email_' . $createDynamicGuarantorElement] = $setGuarantorInfo['email'];
                         $formData['guarantors_dob_' . $createDynamicGuarantorElement] = date('d/m/Y', strtotime($setGuarantorInfo['dob']));
                         $formData['guarantor_homeletrefno_' . $createDynamicGuarantorElement] = $setGuarantorInfo['homeletrefno'];
                         $formData['guarantor_housename_' . $createDynamicGuarantorElement] = $setGuarantorInfo['house_name'];
                         $formData['guarantor_street_' . $createDynamicGuarantorElement] = $setGuarantorInfo['street'];
                         $formData['guarantor_town_' . $createDynamicGuarantorElement] = $setGuarantorInfo['town'];
                         $formData['guarantor_city_' . $createDynamicGuarantorElement] = $setGuarantorInfo['city'];
                         $formData['guarantor_postcode_' . $createDynamicGuarantorElement] = $setGuarantorInfo['postcode'];
                         $formData['guarantor_address_' . $createDynamicGuarantorElement] = $setGuarantorInfo['address_id'];
                         $createDynamicGuarantorElement++;
                     }
                     // get tenant details
                     $tenantManager = new Manager_Insurance_RentGuaranteeClaim_Tenant();
                     $getTenantInfo = $tenantManager->getTenants($claimReferenceNumber);
                     $formData['total_tenants'] = count($getTenantInfo);
                     $formData['totaltenants'] = count($getTenantInfo);
                     $createDynamicTenantElement = 1;
                     foreach ($getTenantInfo as $setTenantInfo) {
                         $formData['tenant_name_' . $createDynamicTenantElement] = $setTenantInfo['tenant_name'];
                         $formData['tenant_hometelno_' . $createDynamicTenantElement] = $setTenantInfo['tenant_hometelno'];
                         $formData['tenant_worktelno_' . $createDynamicTenantElement] = $setTenantInfo['tenant_worktelno'];
                         $formData['tenant_mobiletelno_' . $createDynamicTenantElement] = $setTenantInfo['tenant_mobiletelno'];
                         $formData['tenant_email_' . $createDynamicTenantElement] = $setTenantInfo['tenant_email'];
                         $formData['tenants_dob_' . $createDynamicTenantElement] = date('d/m/Y', strtotime($setTenantInfo['tenant_dob']));
                         $formData['rg_policy_ref_' . $createDynamicTenantElement] = $setTenantInfo['rg_policy_ref'];
                         $createDynamicTenantElement++;
                     }
                     $pageForm->isValid($formData);
                 }
                 break;
             case 3:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] || isset($pageSession->identifier[$stepNum]) && $pageSession->identifier[$stepNum]) {
                     //set step3 identifier
                     $pageSession->identifier[$stepNum] = true;
                     $formData['additional_information'] = $claim->getAdditionalInfo();
                     $formData['dd_accountname'] = $claim->getClaimPaymentBankAccountName();
                     $formData['bank_account_number'] = $claim->getClaimPaymentBankAccountNumber();
                     $formData['bank_sortcode_number'] = $claim->getClaimPaymentBankAccountSortCode();
                 }
                 break;
             case 4:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] || isset($pageSession->identifier[$stepNum]) && $pageSession->identifier[$stepNum]) {
                     $pageSession->identifier[$stepNum] = true;
                     $formData['doc_confirmation_agent_name'] = $claim->getDocConfirmationAgentName();
                     $formData['landlord_proprietor_of_property'] = $claim->getLandlordIsPropertyProprietor();
                     $formData['chk_confirm'] = $claim->getAuthorityConfirmed();
                     $formData['dec_confirm'] = $claim->getDeclarationConfirmed();
                     $formData['hd_type'] = $claim->getSubmittedToKeyHouse();
                 }
                 break;
         }
     } else {
         // Not in session but there are some defaults we need to set for step 1
         // TODO: Write the javascript better so we don't need to do fudges like this
         $this->view->headScript()->appendScript("var sharersAllowed = 0;");
     }
     $pageForm->populate($formData);
     $this->view->sidebar = $this->view->partial('partials/rent-guarantee-claim-sidebar.phtml', array('stepNum' => $stepNum, 'stepMax' => $this->_stepMax));
     return true;
 }
Example #11
0
 public function attemptLogin($loginForm)
 {
     $request = $this->getRequest();
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect'));
     // We have post data from the login form - so attempt a login
     if ($loginForm->isValid($request->getPost())) {
         // The forms passed validation so we now need to check the identity of the user
         $adapter = $this->_getAuthAdapter($loginForm->getValues());
         $result = $auth->authenticate($adapter);
         if (!$result->isValid()) {
             // Invalid credentials
             $loginForm->setDescription('Invalid credentials provided');
             return false;
         } else {
             // Valid credentials - store the details we need from the database and move the user to the index page
             $storage = $auth->getStorage();
             $resultRowObject = $adapter->getResultRowObject(array('agentid', 'username', 'realname', 'level', 'agentschemeno', 'STATUS', 'LASTLOGINDATE'));
             // Rewrite LASTLOGINDATE to lastlogindate
             $resultRowObject->lastlogindate = $resultRowObject->LASTLOGINDATE;
             unset($resultRowObject->LASTLOGINDATE);
             // Get correct status name from ID
             $agentuser = new Datasource_Core_Agent_UserAccounts();
             $user = $agentuser->getUser($resultRowObject->agentid);
             $userstatus = new Model_Core_Agent_UserStatus();
             $resultRowObject->status = strtolower($userstatus->toString($user->status));
             unset($resultRowObject->STATUS);
             $agentManager = new Manager_Core_Agent();
             try {
                 $resultRowObject->fsastatusabbr = $agentManager->getFsaStatusCode($resultRowObject->agentschemeno);
                 $agent = $agentManager->getAgent($resultRowObject->agentschemeno);
                 $resultRowObject->agentAccountStatus = $agent->status;
             } catch (Exception $e) {
                 // FSA Server is down so we can't currently log agent in
                 $auth->clearIdentity();
                 return false;
             }
             // 'level' is not mapped in the DB to the correct framework
             // constants, do so now.
             // TODO: Fix this so it's not having to mess with
             // translating raw legacy DB values
             switch ($resultRowObject->level) {
                 case 1:
                     $resultRowObject->level = Model_Core_Agent_UserRole::BASIC;
                     break;
                 case 3:
                     $resultRowObject->level = Model_Core_Agent_UserRole::MASTER;
                     break;
             }
             // Detect if agent exists in IRIS
             // If the agent has decommission_in_hrt_at set in newagents then this means agent exists in IRIS
             $resultRowObject->isInIris = false;
             if ($agent->decommissionInHrtAt) {
                 $resultRowObject->isInIris = true;
             }
             // If this is an IRIS agent, try to authenticate them
             if ($resultRowObject->isInIris) {
                 /** @var \Iris\Authentication\Authentication $irisAuthentication */
                 $irisAuthentication = \Zend_Registry::get('iris_container')->get('iris.authentication');
                 $authenticationParams = $loginForm->getValues();
                 $authenticateAgent = $irisAuthentication->authenticateAgent($authenticationParams['agentschemeno'], $authenticationParams['username'], $authenticationParams['password']);
                 if (false === $authenticateAgent) {
                     $auth->clearIdentity();
                     $loginForm->setDescription('Failed to login to referencing system');
                     return false;
                 }
                 $resultRowObject->agentBranchUuid = $authenticateAgent->getAgentBranchUuid();
                 $resultRowObject->canPerformReferencing = true;
                 if ($agent->hasProductAvailabilityMapping) {
                     // Determine if this agent can use referencing
                     /** @var \Guzzle\Common\Collection $products */
                     $products = \Zend_Registry::get('iris_container')->get('iris.product')->getProducts(1, 1);
                     // If the product count is greater than zero then the agent can perform referencing
                     $resultRowObject->canPerformReferencing = $products->count() > 0;
                 }
             }
             $resultRowObject->agentsRateID = $agent->agentsRateID;
             $storage->write($resultRowObject);
             return true;
         }
     }
 }