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);
 }
 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();
     }
 }
 public function run()
 {
     $month = Zend_Registry::get('invoice_month');
     $year = Zend_Registry::get('invoice_year');
     $invoice = new Datasource_Core_Agent_Invoice();
     $email_status = new Datasource_Core_Agent_InvoiceEmailStatus();
     $agent_manager = new Manager_Core_Agent();
     // Get agent details that already invoiced for the reporting month
     $agents = $invoice->getAgentDetailsForInvoicing($month . "_" . $year);
     if ($agents) {
         foreach ($agents as $agent) {
             if ($agent['invoicesend'] === 'email' || $agent['invoicesend'] === 'both') {
                 if ($agent['email_address']) {
                     //if ($agent_manager->sendEmailNotification($agent['agentSchemeNo'], $agent['email_address'], $month, $year)) {
                     if ($agent['id']) {
                         if (!$agent['emailSent']) {
                             $agent_manager->sendEmailNotification($agent['agentSchemeNo'], $agent['email_address'], $month, $year);
                             $email_status->updateInvoiceEmailStatus($agent['agentSchemeNo']);
                         }
                     } else {
                         $agent_manager->sendEmailNotification($agent['agentSchemeNo'], $agent['email_address'], $month, $year);
                         $email_status->insertInvoiceEmailStatus($agent['agentSchemeNo'], $month, $year);
                     }
                     //}
                 }
             }
         }
     } else {
         echo "No agents to process\n";
     }
 }
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);
 }
 /**
  * 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 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 #7
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 #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
 /**
  * This will convert all the new data into the old lagacy tables
  * @param
  * @return
  * @author John Burrin
  * @since 1.3
  *
  * Munten ergo sum
  */
 public function convertLegacy($refNo)
 {
     // fetch quote premiums
     $premiums = $this->quote($refNo);
     // Fetch the Landlords details
     $landlord = new Manager_Insurance_Portfolio_LegacyCustomer();
     $landlordDetails = $landlord->fetchByRefNo($refNo);
     // Fetch all the properties
     $propertyManager = new Manager_Insurance_Portfolio_Property();
     $propertyObject = new Model_Insurance_Portfolio_Property();
     $propertyObject = $propertyManager->fetchAllProperties($refNo);
     // populate the legacy portfoliostat table
     $legacyPortfolioStat = new Model_Insurance_Portfolio_LegacyPortfolio();
     $legacyPortfolioStat->agentSchemeNo = 1403796;
     // $legacyPortfolioStat->csuId = "";
     $legacyPortfolioStat->customerRefNo = "";
     $legacyPortfolioStat->date = date("Y-m-d");
     $legacyPortfolioStat->email = $landlordDetails['email_address'];
     $legacyPortfolioStat->heardFrom = "";
     $legacyPortfolioStat->hpc = "";
     $legacyPortfolioStat->name = $landlordDetails['first_name'] . " " . $landlordDetails['last_name'];
     $legacyPortfolioStat->numOfHouse = count($propertyObject);
     $legacyPortfolioStat->policyNumber = "";
     $legacyPortfolioStat->quote = $premiums['premiums']['UserQuoteAnnualPremium'];
     $legacyPortfolioStat->referred = "";
     $legacyPortfolioStat->refNo = $refNo;
     $legacyPortfolioStat->telephone = $landlordDetails['telephone1'];
     // Set up datasources to the risk areas
     $dsBuildingsRiskArea = new Datasource_Insurance_RiskAreas_Buildings();
     $dsContentsRiskArea = new Datasource_Insurance_RiskAreas_LandlordsContents();
     //Save the portfoliostat data
     $legacyPortfolioManager = new Manager_Insurance_Portfolio_LegacyPortfolio();
     $legacyPortfolioManager->save($legacyPortfolioStat);
     $idd = new Datasource_Insurance_IddSupport();
     if (!$idd->isIddSupport($legacyPortfolioStat->refNo)) {
         $inserArray = array();
         $insertArray['policynumber'] = $legacyPortfolioStat->refNo;
         $insertArray['agentschemeno'] = $legacyPortfolioStat->agentSchemeNo;
         $insertArray['csuid'] = 0;
         $fsaAgentStatusDatasource = new Datasource_Fsa_AgentStatus();
         $fsaStatus = $fsaAgentStatusDatasource->getAgentFsaStatus($legacyPortfolioStat->agentSchemeNo);
         if (isset($fsaStatus['status_abbr'])) {
             $insertArray['FSA_status'] = $fsaStatus['status_abbr'];
         } else {
             $insertArray['FSA_status'] = "";
         }
         $insertArray['origsaleid'] = 9;
         $insertArray['callerid'] = 2;
         $idd->setIddSupport($insertArray);
     }
     // Setup an agent manager
     $agent = new Manager_Core_Agent();
     // get polict options
     $ds_rates = new Datasource_Insurance_Portfolio_PortfolioRates();
     $rates = $ds_rates->fetchRates();
     $optionsString = $this->_getPolicyOptions();
     // Save the property data into the legacy portfolio table
     $legacyPropertyManager = new Manager_Insurance_Portfolio_LegacyProperty();
     foreach ($propertyObject as $property) {
         // Create a new Model_Insurance_Portfolio_LegacyProperty Object
         $legacyPropertyObject = new Model_Insurance_Portfolio_LegacyProperty();
         $legacyPropertyObject->amountsCovered = $this->_getAmountsCovered($property);
         $legacyPropertyObject->discount = "";
         $legacyPropertyObject->excessId = "";
         $legacyPropertyObject->ipt = "";
         $legacyPropertyObject->optionDiscounts = "";
         $legacyPropertyObject->optionPremiums = "";
         $legacyPropertyObject->policyNumber = $refNo;
         $legacyPropertyObject->policyOptions = $optionsString;
         $legacyPropertyObject->premium = "";
         $legacyPropertyObject->propAddress1 = $property->address1;
         $legacyPropertyObject->propAddress3 = $property->address2;
         $legacyPropertyObject->propAddress5 = $property->address3;
         $legacyPropertyObject->propPostcode = $property->postcode;
         $legacyPropertyObject->quote = 0.0;
         $legacyPropertyObject->rateSetId = $agent->getRatesetIDByASN($refNo);
         $legacyPropertyObject->riskArea = $dsContentsRiskArea->getCurrentRate($property['postcode']);
         $legacyPropertyObject->riskAreaB = $dsBuildingsRiskArea->getCurrentRate($property['postcode']);
         $legacyPropertyObject->surcharge = "";
         $legacyPropertyManager->save($legacyPropertyObject);
     }
 }
 /**
  * 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;
 }
 /**
  * This function is to catch inbound links and session the get params and bounce on to the step 1
  */
 public function referAction()
 {
     // Check to see if we have a referrer code - if we do store it in a session variable
     if ($this->getRequest()->getParam('referrer') != '') {
         $session->referrer = $this->getRequest()->getParam('referrer');
     } elseif (!isset($session->referrer)) {
         // no passed parameter so default
         $session->referrer = "direct";
     }
     // Check to see if we have a agentSchemeNumber code - if we do store it in a session variable
     if ($this->getRequest()->getParam('agentschemeno') != '') {
         $session->agentSchemeNumber = Manager_Core_Agent::filterAsn($this->getRequest()->getParam('agentschemeno'));
     }
     // Check to see if we have a origin code - if we do store it in a session variable
     if ($this->getRequest()->getParam('origin') != '') {
         $session->origin = $this->getRequest()->getParam('origin');
     }
     // Check to see if we have a csuid - if we do store it in a session variable - Sorry Phil
     if ($this->getRequest()->getParam('csu') != '') {
         $session->csu = $this->getRequest()->getParam('csu');
     } elseif (!isset($session->csu)) {
         // no passed parameter so default it to our web user 87
         $session->csu = "87";
     }
     $this->_helper->getHelper('layout')->disableLayout();
     // It shouldn't be rendered with a view script either
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->redirector->gotoUrl('/tenants/insurance-quote-b/step1');
 }
 /**
  * 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)
 {
     $this->view->stepNum = $stepNum;
     $this->view->stepMax = $this->_stepMax;
     // Check to see if the user is trying to skip ahead in the quote
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     $tooFarAhead = false;
     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
         $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step' . $lastCompleted);
         return false;
     }
     if ($stepNum > 1) {
         // Before we do ANYTHING we need to check to see if the email address entered matches a customer record
         // we already have - if it does we need to ask them to login before they proceed.
         $customerReferenceNumber = $this->_customerReferenceNumber;
         $customerManager = new Manager_Core_Customer();
         $legacyCustomer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $customerReferenceNumber);
         $emailAddress = $legacyCustomer->getEmailAddress();
         $customer = $customerManager->getCustomerByEmailAddress($emailAddress);
         if ($customer) {
             // There is already a customer entry for this email address - so we need to see if they are logged in
             // if not we need to force them to login
             $auth = Zend_Auth::getInstance();
             $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
             if ($auth->hasIdentity()) {
                 $loggedInEmail = $auth->getStorage()->read()->email_address;
                 if ($loggedInEmail != $customer->getEmailAddress()) {
                     // They are logged in but not who they should be to do this quote
                     $this->_helper->redirector->gotoUrl('/account/login?refer=landlords-insurance&step=' . $stepNum);
                     return false;
                 }
             } else {
                 // TODO: Check that removing the login redirection will not break other processes
                 // They aren't logged in and need to
                 /*$this->_helper->redirector->gotoUrl('/account/login?refer=landlords-insurance&step='. $stepNum);
                 		return false;*/
             }
         }
     }
     $formData = array();
     // If step 1 and not in session (so producing a quick quote) - we need to pre-populate
     // a few bits if the customer is already logged into the site
     if ($stepNum == 1 && !isset($pageSession->CustomerRefNo)) {
         $auth = Zend_Auth::getInstance();
         $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
         if ($auth->hasIdentity()) {
             // Customer is logged in and starting a new quote - so we need to pre-populate the customers details from stored details
             $customerID = $auth->getStorage()->read()->id;
             $customerManager = new Manager_Core_Customer();
             $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerID);
             $formData['title'] = $customer->getTitle();
             $formData['first_name'] = $customer->getFirstName();
             $formData['last_name'] = $customer->getLastName();
             $formData['phone_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE1);
             $formData['mobile_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE2);
             $formData['email_address'] = $customer->getEmailAddress();
             $formData['date_of_birth_at'] = $customer->getDateOfBirthAt();
             $pageForm->populate($formData);
         }
     }
     if (isset($this->_quoteID) && $this->_quoteID > 0) {
         $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($this->_quoteID);
         $premiums = $quoteManager->calculatePremiums();
         if ($premiums != '') {
             $this->view->premiums = array('annual' => $premiums['totalGrossAnnualPremium'] + $premiums['totalGrossAnnualIPT'], 'monthly' => $premiums['totalGrossMonthlyPremium'] + $premiums['totalGrossMonthlyIPT']);
             $this->view->premiumsFull = $premiums;
         }
         $fees = $quoteManager->getFees();
         $this->view->fees = $fees;
         switch ($stepNum) {
             case 1:
                 $customerManager = new Manager_Core_Customer();
                 $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $quoteManager->getLegacyCustomerReference());
                 // Populate the customer details
                 $titleOptions = LandlordsInsuranceQuote_Form_Subforms_PersonalDetails::$titles;
                 if (in_array($customer->getTitle(), $titleOptions)) {
                     $formData['title'] = $customer->getTitle();
                 } else {
                     $formData['title'] = "Other";
                     $formData['other_title'] = $customer->getTitle();
                 }
                 $formData['first_name'] = $customer->getFirstName();
                 $formData['last_name'] = $customer->getLastName();
                 $formData['phone_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE1);
                 $formData['mobile_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE2);
                 $formData['email_address'] = $customer->getEmailAddress();
                 $dob = $customer->getDateOfBirthAt();
                 if (null != $dob && '0000-00-00' != $dob) {
                     $formData['date_of_birth_at'] = Application_Core_Utilities::mysqlDateToUk($dob);
                 }
                 // Populate the correspondence address details
                 $formData['cor_address_line1'] = $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE1);
                 $formData['cor_address_line2'] = $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE2);
                 $formData['cor_address_line3'] = $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE3);
                 $formData['cor_address_postcode'] = $customer->getPostcode();
                 $formData['country'] = $customer->getCountry();
                 // Populate the insured property address details
                 $properties = $quoteManager->getProperties();
                 if (count($properties) > 0) {
                     $formData['ins_address_line1'] = $properties[0]['line_1'];
                     $formData['ins_address_line2'] = $properties[0]['line_2'];
                     $formData['ins_address_line3'] = $properties[0]['town'];
                     $formData['ins_address_postcode'] = $properties[0]['postcode'];
                     $formData['owned_for'] = $properties[0]['ownership_length_id'];
                     $formData['no_claims'] = $properties[0]['no_claims_years_id'];
                     $formData['tenants_type'] = $properties[0]['tenant_type_id'];
                     $formData['have_letting_agent'] = $quoteManager->getAgentSchemeNumber() != Manager_Core_Agent::filterAsn($quoteManager->getAgentSchemeNumber()) ? 'yes' : 'no';
                     $formData['through_letting_agent'] = $properties[0]['letting_agent_managed'] ? 'yes' : 'no';
                     // Check to see if this postcode is in a flood risk area - if it is then populate the exclude flood cover data
                     // Populating this will also cause the question to be shown on the front end
                     $landlordsRiskAreas = new Datasource_Insurance_LandlordsPlus_RiskAreas();
                     $riskAreas = $landlordsRiskAreas->getByPostcode($properties[0]['postcode']);
                     if ($riskAreas['floodArea'] == '600') {
                         $formData['exclude_flood_cover'] = $properties[0]['exclude_flood_cover'] ? 'no' : 'yes';
                         // Backwards true/false stuff - I'm sooo sorry :(
                     }
                 }
                 // Populate agent details if one has been chosen
                 $agentSchemeNumber = Manager_Core_Agent::filterAsn($quoteManager->getAgentSchemeNumber());
                 $defaultASN = $this->_params->homelet->defaultAgent;
                 if ($formData['have_letting_agent'] == 'yes') {
                     $agents = new Datasource_Core_Agents();
                     $agent = $agents->getAgent($agentSchemeNumber);
                     $formData['letting_agent_name'] = $agent->name;
                     $formData['letting_agent_town'] = $agent->town;
                     $formData['letting_agent_asn'] = $agent->agentSchemeNumber;
                     // Fix for Redmine Ref. #10511:
                     $agentDropdown = $pageForm->subform_lettingagent->letting_agent;
                     $agentDropdown->setMultiOptions(array($agent->agentSchemeNumber => $agent->name . ', ' . $agent->town));
                     $formData['letting_agent'] = $agent->agentSchemeNumber;
                 }
                 // Load the policy start date
                 $startDate = $quoteManager->getStartDate();
                 if ($startDate != '' && $startDate != '0000-00-00') {
                     $formData['policy_start'] = substr($startDate, 8, 2) . '/' . substr($startDate, 5, 2) . '/' . substr($startDate, 0, 4);
                 }
                 // If step1 has been marked complete - we can assume they said yes to the IDD question
                 $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) {
                     $formData['idd'] = true;
                 }
                 // Data Protection section
                 $customerReferenceNumber = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
                 $dpaManager = new Manager_Core_DataProtection();
                 $dpaItems = $dpaManager->getItems($customerReferenceNumber, Model_Core_DataProtection_ItemEntityTypes::INSURANCE);
                 foreach ($dpaItems as $currentItem) {
                     switch ($currentItem->constraintTypeId) {
                         case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_PHONEANDPOST:
                             if ($currentItem->isAllowed) {
                                 $formData['dpa_phone_post'] = 0;
                             } else {
                                 $formData['dpa_phone_post'] = 1;
                             }
                             break;
                         case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_SMSANDEMAIL:
                             if ($currentItem->isAllowed) {
                                 $formData['dpa_sms_email'] = 0;
                                 // For Redmine Ref #8003, "Updated marketing preference questions on online quotes"
                             } else {
                                 $formData['dpa_sms_email'] = 1;
                                 // For Redmine Ref #8003, "Updated marketing preference questions on online quotes"
                             }
                             break;
                         case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_THIRDPARTY:
                             if ($currentItem->isAllowed) {
                                 $formData['dpa_resale'] = 1;
                             } else {
                                 $formData['dpa_resale'] = 0;
                             }
                             break;
                     }
                 }
             case 2:
                 // If step2 has been marked complete - we can assume they said no to the questions unless
                 // they've been set in the quote manager
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) {
                     $formData['need_building_insurance'] = 'no';
                     $formData['need_contents_insurance'] = 'no';
                 }
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER)) {
                     $formData['need_building_insurance'] = 'yes';
                     $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER);
                     $formData['building_built'] = $productMeta['build_year'];
                     $formData['building_bedrooms'] = $productMeta['bedroom_quantity'];
                     $formData['building_type'] = $productMeta['building_type'];
                     $formData['building_insurance_excess'] = $productMeta['excess'];
                     $formData['building_accidental_damage'] = $productMeta['accidental_damage'];
                     $quote = $quoteManager->getModel();
                     if ((int) $productMeta['rebuild_value'] > 0) {
                         // There's a manually entered rebuild value - need to work out if it is because they
                         // chose £500k+ - or if it's because we don't have a dsi
                         $premiums = $quoteManager->calculatePremiums();
                         if ($premiums['calculatedDSIValue'] > 0) {
                             $formData['override_dsi'] = 1;
                         }
                         $formData['building_value'] = $productMeta['rebuild_value'];
                     }
                 }
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::UNFURNISHED_CONTENTS_COVER)) {
                     $formData['need_contents_insurance'] = 'yes';
                     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
                         $formData['property_furnished'] = 'yes';
                         $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER);
                         $formData['contents_amount'] = $productMeta['cover_amount'];
                         $formData['contents_excess'] = $productMeta['excess'];
                         $formData['contents_accidental_damage'] = $productMeta['accidental_damage'];
                     } else {
                         $formData['property_furnished'] = 'no';
                     }
                 }
                 break;
             case 3:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) {
                     $formData['need_emergency_assistance'] = 'no';
                     $formData['need_prestige_rent_guarantee'] = 'no';
                     $formData['need_legal_expenses'] = 'no';
                     $formData['need_boiler_heating'] = 'no';
                 }
                 // If we have contents/buildings cover then EAS is already included for free so we can hide the form
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
                     // Change the subforms view script to one that just says it's already included for free
                     // yeah yeah.. this aint pretty :(
                     $emergencyAssistanceForm = $pageForm->getSubForm('subform_emergencyassistance');
                     $emergencyAssistanceForm->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/emergency-assistance-free.phtml'))));
                     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BOILER_HEATING)) {
                         $formData['need_boiler_heating'] = 'yes';
                     }
                 } else {
                     // We can allow stand-alone EAS - so we hide the boiler and heating section
                     // yes... this is waaay too complex... I know :(
                     $pageForm->removeSubForm('subform_boilerheating');
                     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::EMERGENCY_ASSISTANCE)) {
                         $formData['need_emergency_assistance'] = 'yes';
                     }
                 }
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE)) {
                     $formData['need_prestige_rent_guarantee'] = 'yes';
                     $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE);
                     $formData['rent_amount'] = $productMeta['monthly_rent'];
                 } elseif ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::LEGAL_EXPENSES)) {
                     $formData['need_legal_expenses'] = 'yes';
                 }
                 break;
             case 4:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) {
                     // Load underwriting answers from the database as they've already been answered
                     $answersManager = new Manager_Insurance_Answers();
                     $quote = $quoteManager->getModel();
                     $policyNumber = $quote->legacyID;
                     $customerReferenceNumber = $quote->legacyCustomerID;
                     $answers = $answersManager->getUnderwritingAnswers($policyNumber);
                     foreach ($answers as $answer) {
                         switch ($answer->getQuestionNumber()) {
                             case '53':
                                 $formData['declaration1'] = $answer->getAnswer();
                                 break;
                             case '54':
                                 $formData['declaration2'] = $answer->getAnswer();
                                 break;
                             case '55':
                                 $formData['declaration2b'] = $answer->getAnswer();
                                 break;
                             case '56':
                                 $formData['declaration2c'] = $answer->getAnswer();
                                 break;
                             case '57':
                                 $formData['declaration2d'] = $answer->getAnswer();
                                 break;
                             case '58':
                                 $formData['declaration3'] = $answer->getAnswer();
                                 break;
                             case '59':
                                 $formData['declaration4'] = $answer->getAnswer();
                                 break;
                             case '60':
                                 $formData['declaration6'] = $answer->getAnswer();
                                 break;
                             case '61':
                                 $formData['declaration7'] = $answer->getAnswer();
                                 break;
                             case '62':
                                 $formData['declaration8'] = $answer->getAnswer();
                                 break;
                             case '63':
                                 $formData['declaration9'] = $answer->getAnswer();
                                 break;
                             case '64':
                                 $formData['declaration10'] = $answer->getAnswer();
                                 break;
                         }
                     }
                     // Also need to see if they said yes or no to bank interest on the propery…
                     $bankInterestManager = new Manager_Insurance_LegacyBankInterest();
                     $bankInterestArray = $bankInterestManager->getAllInterests($policyNumber, $customerReferenceNumber);
                     $model = array();
                     if (!empty($bankInterestArray)) {
                         $formData['declaration11'] = 'yes';
                     } else {
                         $formData['declaration11'] = 'no';
                     }
                     // They must have agreed to the declaration or they wouldn't have been able to continue
                     $formData['declaration_confirmation'] = 'yes';
                 }
                 break;
             case 5:
                 // Payment Selection section
                 if (isset($pageSession->paymentSelectionDetails) && is_array($pageSession->paymentSelectionDetails)) {
                     $formData = $pageSession->paymentSelectionDetails;
                 }
                 break;
         }
     }
     $pageForm->populate($formData);
     return true;
 }
 /**
  * Handles display, validation and sending of company application form
  */
 public function companyApplicationAction()
 {
     // Instantiate form
     $pageForm = new Connect_Form_ReferencingCompanyApplication();
     $request = $this->getRequest();
     if ($request->isPost()) {
         // We have post data from the company app form - so attempt
         //   validation
         if ($pageForm->isValid($request->getPost())) {
             // Form valid!
             // Format text data ready for e-mail
             $agentManager = new Manager_Core_Agent($this->_agentSchemeNumber);
             $address = $agentManager->getPhysicalAddressByCategory(Model_Core_Agent_ContactMapCategory::OFFICE);
             $agentAddress = $address->toString();
             switch ($request->getParam('how_rg_offered')) {
                 case 1:
                     $howOffered = "Free of charge";
                     break;
                 case 2:
                     $howOffered = "Included in Management Fees";
                     break;
                 case 3:
                     $howOffered = "Separate charge for Rent Guarantee to the landlord";
                     break;
                 case 4:
                     $howOffered = "Referening Only";
                     break;
             }
             switch ($request->getParam('property_managed')) {
                 case 1:
                     $howManaged = "Let Only";
                     break;
                 case 2:
                     $howManaged = "Managed";
                     break;
                 case 3:
                     $howManaged = "Rent Collect";
                     break;
             }
             //Convert the product id into a product name
             $cleanData = $pageForm->getValues();
             $productManager = new Manager_Referencing_Product();
             $product = $productManager->getById($cleanData['subform_product']['product']);
             $productName = empty($product->name) ? '' : $product->name;
             $message = 'Agent Scheme Number: ' . $this->_agentSchemeNumber . "\n" . 'Agent Name: ' . $this->_agentObj->name . "\n" . 'Agent address: ' . $agentAddress . "\n\n" . 'Product: ' . $product->name . "\n" . "\nProperty To Let:\n" . 'Address: ' . $request->getParam('property_address') . "\n" . 'Postcode: ' . $request->getParam('property_postcode') . "\n" . 'Managed Property: ' . $howManaged . "\n" . 'How is Rent Guarantee offered to the landlord: ' . $howOffered . "\n" . 'Total Rent: ' . $request->getParam('tenant_renttotal') . "\n" . 'Rent Share: ' . $request->getParam('tenant_rentshare') . "\n" . 'Tenancy Term: ' . $request->getParam('tenant_term') . "\n" . 'Start Date: ' . $request->getParam('tenant_startdate') . "\n" . 'Total Reference Count: ' . $request->getParam('tenant_number') . "\n" . "\nLandlord Details: \n" . 'First Name: ' . $request->getParam('landlord_firstname') . "\n" . 'Last Name: ' . $request->getParam('landlord_lastname') . "\n" . 'Address: ' . $request->getParam('landlord_address') . "\n" . 'Postcode: ' . $request->getParam('landlord_postcode') . "\n" . 'Telno: ' . $request->getParam('landlord_landlinenumber') . "\n" . 'Mobile: ' . $request->getParam('landlord_mobilenumber') . "\n" . "\nCompany Details: \n" . 'Company Name: ' . $request->getParam('company_name') . "\n" . 'Trading Name: ' . $request->getParam('company_tradingname') . "\n" . 'Registered Number: ' . $request->getParam('company_registration') . "\n" . 'Incorporation Date: ' . $request->getParam('company_incorporation') . "\n" . 'Contact Name: ' . $request->getParam('company_contactname') . "\n" . 'Telno: ' . $request->getParam('company_phone') . "\n" . "\nCompany Registered Address: \n" . 'Address: ' . $request->getParam('registered_address') . "\n" . 'Postcode: ' . $request->getParam('registered_postcode') . "\n" . 'Period at Address: ' . $request->getParam('registered_years') . " years, " . $request->getParam('registered_months') . " months\n" . "\nCompany Trading Address: \n" . 'Address: ' . $request->getParam('trading_address') . "\n" . 'Postcode: ' . $request->getParam('trading_postcode') . "\n" . 'Period at Address: ' . $request->getParam('trading_years') . " years, " . $request->getParam('trading_months') . " months\n" . "\nAdditional Info: \n" . $request->getParam('additional_info') . "\n" . "\nCompany Signature Details: \n" . 'Name: ' . $request->getParam('representive_name') . "\n" . 'Position: ' . $request->getParam('representive_position') . "\n" . 'Date: ' . $request->getParam('application_date') . "\n";
             // Instantiate mailer manager
             $mailManager = new Application_Core_Mail();
             $mailManager->setTo($this->_params->connect->companyapps->emailToAddress, $this->_params->connect->companyapps->emailToName)->setFrom($this->_params->connect->companyapps->emailFromAddress, $this->_params->connect->companyapps->emailFromName)->setSubject($this->_params->connect->companyapps->emailSubject)->setBodyText($message);
             // Check for uploaded file and persist it if so
             list($fileResult, $fileData) = $this->_uploadPersistentCompanyApplicationFile();
             if ($fileResult === true) {
                 $this->view->fileUploaded = $fileData;
                 // If there's a file, attach it
                 if (isset($fileData['pathToFile'])) {
                     $mailManager->addAttachment($fileData['pathToFile'], $fileData['originalName']);
                 }
                 $mailManager->send();
                 // Clean up uploaded file
                 $this->_deleteCompanyApplicationFile();
                 // Show user confirmation that form submission has been successful
                 $this->_helper->viewRenderer('company-confirmation');
             } else {
                 $this->_helper->flashmessages->addMessage('Problem(s) uploading file:');
                 $this->_helper->flashmessages->addMessage($fileData);
             }
         } else {
             // Tell user there are problems
             $this->_helper->flashmessages->addMessage('Problem(s) in form data:');
             $this->_helper->flashmessages->addMessage($pageForm->getMessagesFlattened(true));
             // Check for uploaded file and persist it if so
             list($fileResult, $fileData) = $this->_uploadPersistentCompanyApplicationFile();
             if ($fileResult === true) {
                 $this->view->fileUploaded = $fileData;
             } else {
                 $this->_helper->flashmessages->addMessage('Problem(s) uploading file:');
                 $this->_helper->flashmessages->addMessage($fileData);
             }
         }
     } else {
         // Form first shown, set a couple of default values
         $pageForm->subform_additional->getElement('additional_info')->setValue('Use this space to provide any additional information that may help us when processing your application.');
         $pageForm->subform_declaration->getElement('application_date')->setValue(date('d/m/Y'));
         // Ensure any previously uploaded file is deleted
         $this->_deleteCompanyApplicationFile();
     }
     $this->view->flashMessages = $this->_helper->flashmessages->getCurrentMessages();
     $this->view->form = $pageForm;
 }
Example #14
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;
 }
Example #15
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);
     }
 }
 public function init()
 {
     $session = new Zend_Session_Namespace('homelet_global');
     Zend_Layout::startMvc();
     // Use the CMS layout
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . '/modules/cms/layouts/scripts/');
     // Extra form css for portfolio
     $this->view->headLink()->setStylesheet('/assets/portfolio-insurance-quote/css/portfolio-insurance-quote.css');
     $this->view->headScript()->appendFile('/assets/common/js/insurance-forms.js');
     $this->view->headScript()->appendFile('/assets/portfolio-insurance-quote/js/portfolio_form.js');
     $this->view->pageTitle = 'Portfolio Insurance Quote';
     $this->url = trim($this->getRequest()->getRequestUri(), '/');
     $menuData = array('selected' => 'landlords', 'url' => $this->url);
     // Check to see if we have a referrer code - if we do store it in a session variable
     if ($this->getRequest()->getParam('referrer') != '') {
         $session->referrer = Manager_Core_Agent::filterAsn($this->getRequest()->getParam('referrer'));
     } elseif (!isset($session->referrer)) {
         // no passed parameter so default it to our default account
         $session->referrer = "1403796";
     }
     // Check to see if we have a csuid - if we do store it in a session variable - Sorry Phil
     if ($this->getRequest()->getParam('csu') != '') {
         $session->csu = $this->getRequest()->getParam('csu');
     } elseif (!isset($session->csu)) {
         // no passed parameter so default it to our web user 87
         $session->csu = "87";
     }
     // Check to see if we have a origin - if we do store it in a session variable - Sorry Phil
     if ($this->getRequest()->getParam('origin') != '') {
         $session->csu = $this->getRequest()->getParam('origin');
     } elseif (!isset($session->origin)) {
         // no passed parameter so default it to internet 0
         $session->origin = "0";
     }
     // This could be quite yucky - I'm just trying to work out how to get the menu structure to work
     $mainMenu = $this->view->partial('partials/homelet-mainmenu.phtml', $menuData);
     $subMenu = $this->view->partial('partials/homelet-submenu.phtml', $menuData);
     $layout = Zend_Layout::getMvcInstance();
     $layout->getView()->mainMenu = $mainMenu;
     $layout->getView()->subMenu = $subMenu;
     if (isset($menuData['selected'])) {
         $layout->getView()->styling = $menuData['selected'];
     }
     // Load the site link urls from the parameters and push them into the layout
     $params = Zend_Registry::get('params');
     $layout->getView()->urls = $params->url->toArray();
     // Load session data into private variables
     $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote');
     if (isset($pageSession->CustomerRefNo)) {
         $this->_customerReferenceNumber = $pageSession->CustomerRefNo;
     }
     if (isset($pageSession->PolicyNumber)) {
         $this->_policyNumber = $pageSession->PolicyNumber;
     }
     if (isset($pageSession->webLeadSummaryId)) {
         $this->_webLeadSummaryId = $pageSession->webLeadSummaryId;
     }
     $session = new Zend_Session_Namespace('homelet_global');
     if (isset($session->referrer)) {
         $this->_referrer = $session->referrer;
     }
 }
Example #17
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;
         }
     }
 }