public function isValid($postData)
 {
     // If prestige rent guarantee is added to the quote this form isn't even shown because it's included for free
     // so we need to make the choice not required for validation purposes
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     if (isset($pageSession->quoteID)) {
         $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID);
         if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE) || isset($postData['need_prestige_rent_guarantee']) && $postData['need_prestige_rent_guarantee'] == 'yes') {
             $this->getElement('need_legal_expenses')->setRequired(false);
         }
     }
     return parent::isValid($postData);
 }
 public function isValid($postData)
 {
     // If building cover is added to the quote this form isn't even shown because Emergency Assistance is included for free
     // so we need to make the choice not required for validation purposes
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     if (isset($pageSession->quoteID)) {
         $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID);
         if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
             $this->getElement('need_emergency_assistance')->setRequired(false);
         }
     }
     return parent::isValid($postData);
 }
 public function isValid($postData)
 {
     // If Emergency Assistance is included for free
     // so we need to make the choice not required for validation purposes
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     if (isset($pageSession->quoteID)) {
         $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID);
         if (!$quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) && !$quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
             $this->getElement('need_boiler_heating')->setRequired(false);
         }
     }
     return parent::isValid($postData);
 }
 /**
  * Overridden isValid() method for pre-validation code
  *
  * @param array $formData data typically from a POST or GET request
  *
  * @return bool
  */
 public function isValid($formData = array())
 {
     if (isset($formData['need_building_insurance']) && $formData['need_building_insurance'] == 'yes') {
         // User has said they want building insurance so we need to make the extra information mandatory
         $this->getElement('building_built')->setRequired(true);
         $this->getElement('building_bedrooms')->setRequired(true);
         $this->getElement('building_type')->setRequired(true);
         $this->getElement('building_insurance_excess')->setRequired(true);
         $this->getElement('building_accidental_damage')->setRequired(true);
         // If landlord chooses to over-ride the DSI value we need to make sure they enter a manual value in
         $this->getElement('override_dsi')->setRequired(true);
         if (isset($formData['override_dsi']) && $formData['override_dsi'] == 1) {
             $this->getElement('building_value')->setRequired(true);
             // Need to add a validator to make sure they enter a value over 500k
             $this->getElement('building_value')->clearValidators();
             $minValueValidator = new Zend_Validate_GreaterThan(array('min' => 500000));
             $minValueValidator->setMessage('Please enter a building value above £500k', Zend_Validate_GreaterThan::NOT_GREATER);
             $this->getElement('building_value')->addValidator($minValueValidator);
         } else {
             $this->getElement('building_value')->setRequired(false);
             // They haven't chosen to over-ride but if we don't have a DSI then we still need them to enter one
             $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
             if (isset($pageSession->quoteID)) {
                 $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID);
                 $dsi = $quoteManager->calculateDSI();
                 if ($dsi == 0) {
                     $this->getElement('building_value')->setRequired(true);
                     // Need to add a validator as minimum value is 50k
                     $this->getElement('building_value')->clearValidators();
                     $minValueValidator = new Zend_Validate_GreaterThan(array('min' => 50000));
                     $minValueValidator->setMessage('Please enter a building value above £50k', Zend_Validate_GreaterThan::NOT_GREATER);
                     $this->getElement('building_value')->addValidator($minValueValidator);
                 }
             }
         }
     } else {
         $this->getElement('building_built')->setRequired(false);
         $this->getElement('building_bedrooms')->setRequired(false);
         $this->getElement('building_type')->setRequired(false);
         $this->getElement('building_insurance_excess')->setRequired(false);
         $this->getElement('building_accidental_damage')->setRequired(false);
     }
     return parent::isValid($formData);
 }
 /**
  * Overridden isValid() method for pre-validation code
  *
  * @param array $formData data typically from a POST or GET request
  *
  * @return bool
  */
 public function isValid($formData = array())
 {
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     $session = new Zend_Session_Namespace('homelet_global');
     $agentSchemeNumber = $session->referrer;
     // Populate $formData with data from model, if available
     if (isset($pageSession->quoteID)) {
         $customerData = array();
         // Fetch previously stored start date
         $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID);
         $startDate = $quoteManager->getStartDate();
         if ($startDate != '' && $startDate != '0000-00-00') {
             $customerData['policy_start'] = substr($startDate, 8, 2) . '/' . substr($startDate, 5, 2) . '/' . substr($startDate, 0, 4);
         }
         // Pipe into $formData, with any existing $formData content taking precedence
         $formData = array_merge($customerData, $formData);
     }
     // Call original isValid()
     return parent::isValid($formData);
 }
Esempio n. 6
0
 /**
  * Returns the endorsements required by a quote or policy.
  *
  * This method will identify the endorsements that should be applied to
  * the quote or policy identified by $policyNumber. If any endorsements are
  * identified, they will be detailed in one or more Model_Insurance_Endorsement 
  * objects, which will then be returned in an array. If the quote / policy does
  * not merit any endorsements, then null will be returned.
  *
  * @param string $policyNumber
  * The quote or policy number.
  *
  * @return mixed
  * Returns an array of Model_Insurance_Endorsement objects,
  * or null if no endorsements are applicable.
  * 
  * @todo
  * Not yet complete.
  */
 public function getEndorsementsRequired($quoteID)
 {
     //Create a quote object from the $policyNumber
     $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteID);
     $legacyQuoteId = $quoteManager->getModel()->legacyID;
     //Extract the postcode from the policyNumber
     $properties = $quoteManager->getProperties();
     $postCode = $properties[0]['postcode'];
     //Extract the contents cover, if applicable.
     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
         $contentsMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER);
         $contentsCover = $contentsMeta['cover_amount'];
     } else {
         $contentsCover = 0;
     }
     $params = Zend_Registry::get('params');
     $returnArray = array();
     //First check for flood endorsements.
     $termsDatasource = new Datasource_Insurance_LandlordsPlus_Terms();
     $floodRiskScore = $termsDatasource->getFloodRiskScore($postCode);
     if ($floodRiskScore > 0) {
         //Mandatory/optional endorsement
         $endorsement = new Model_Insurance_Endorsement();
         $endorsement->setPolicyNumber($legacyQuoteId);
         $endorsementType = new Model_Insurance_EndorsementType();
         $endorsementType->setID($params->uw->ed->landlordsp->floodExclusion->id);
         $endorsementType->setName($params->uw->ed->landlordsp->floodExclusion->name);
         $endorsement->setEndorsementType($endorsementType);
         $endorsement->setEffectiveDate(new Zend_Date($quoteManager->getStartDate(), Zend_Date::ISO_8601));
         $returnArray[] = $endorsement;
     }
     //Next check for subsidence endorsements.
     $subsidenceRiskScore = $termsDatasource->getSubsidenceRiskScore($postCode);
     if ($subsidenceRiskScore > 0) {
         //Mandatory endorsement
         $endorsement = new Model_Insurance_Endorsement();
         $endorsement->setPolicyNumber($legacyQuoteId);
         $endorsementType = new Model_Insurance_EndorsementType();
         $endorsementType->setID($params->uw->ed->landlordsp->subsidence->id);
         $endorsementType->setName($params->uw->ed->landlordsp->subsidence->name);
         $endorsement->setEndorsementType($endorsementType);
         $endorsement->setEffectiveDate(new Zend_Date($quoteManager->getStartDate(), Zend_Date::ISO_8601));
         $returnArray[] = $endorsement;
     }
     //Next check for minimum standards of security.
     if ($contentsCover >= $params->uw->et->landlordsp->mandatory->contents) {
         //Mandatory endorsement
         $endorsement = new Model_Insurance_Endorsement();
         $endorsement->setPolicyNumber($legacyQuoteId);
         $endorsementType = new Model_Insurance_EndorsementType();
         $endorsementType->setID($params->uw->ed->landlordsp->minStandardProtection->id);
         $endorsementType->setName($params->uw->ed->landlordsp->minStandardProtection->name);
         $endorsement->setEndorsementType($endorsementType);
         $endorsement->setEffectiveDate(new Zend_Date($quoteManager->getStartDate(), Zend_Date::ISO_8601));
         $returnArray[] = $endorsement;
     }
     //Provide a return value consistent with this methods contract.
     if (empty($returnArray)) {
         $returnVal = null;
     } else {
         $returnVal = $returnArray;
     }
     return $returnVal;
 }
Esempio n. 7
0
 /**
  * Save a new schedule record,
  * This function needs various bit of information to create a schedule entry
  * @param String $refNo Policy reference number
  */
 public function save($refNo, $quote)
 {
     #$session = new Zend_Session_Namespace('tenants_insurance_quote');
     $scheduleObject = new Model_Insurance_Schedule();
     // Get the quote data
     # $quote = new Manager_Insurance_TenantsContentsPlus_Quote($refNo);
     // Get policy start date
     list($year, $month, $day) = explode("-", date("Y-m-d", strtotime($quote->getStartDate())));
     // This is the month the policy is incepted, there will be no payment on this day (0.00)
     $startMonth = date("F", strtotime("{$year}-{$month}-{$day}"));
     // This is the month that first payment is made, this will be 2x monthly value
     $firstPayMonth = date("F", mktime(0, 0, 0, $month++ > 12 ? 1 : $month, $day, $year));
     //Get the payment Refernce Number
     $scheduleObject->policyNumber = $quote->getPolicyNumber();
     if (strtolower($quote->getPayBy()) == "monthly") {
         /**
          * Direct Debit monthly set the current month to 0, next month is doubled remaining months to a single premium
          * ddfee set to Fees value
          * 
          **/
         // TENANTS FEES
         $feesObject = new Model_Insurance_Fee();
         $feesObject = $quote->getFees();
         $scheduleObject->ddFee = $feesObject->monthlyFeeSP;
         if ($quote->getPolicyName() == "landlordsp") {
             $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quote->getID());
             $landlordsFees = $quoteManager->getFees();
             $scheduleObject->ddFee = $landlordsFees['landlords_insurance_plus_monthly_admin'];
         }
         if (strtolower($quote->getPayMethod()) == "directdebit" || strtolower($quote->getPayMethod()) == "dd") {
             $ddPayment = new Manager_Core_Directdebit();
             // Get Payment data no from dd table
             $ddData = $ddPayment->getByRefNo($refNo);
             // Set Payment refno
             $scheduleObject->paymentRefNo = $ddData->paymentRefNo;
             // Set dd Fee
             // Iterate thru the months and apply the monthly payment
             while (key($scheduleObject->months)) {
                 $current = key($scheduleObject->months);
                 if ($current != strtolower($startMonth) && $current != strtolower($firstPayMonth)) {
                     $scheduleObject->months[$current] = round($quote->getPolicyQuote(), 2);
                 }
                 if ($current == strtolower($firstPayMonth)) {
                     $scheduleObject->months[$current] = round($quote->getPolicyQuote() * 2, 2);
                 }
                 next($scheduleObject->months);
             }
         } elseif (strtolower($quote->getPayMethod()) == "creditcard" || strtolower($quote->getPayMethod()) == "cc") {
             $ccPayment = new Manager_Core_CreditCard();
             // Get Payment data no from cc table
             $ccData = $ccPayment->getByRefNo($refNo);
             // Set Payment refno
             $scheduleObject->paymentRefNo = $ccData->paymentRefNo;
             // Set cc Fee
             $amount = $quote->getPolicyQuote();
             // This is the month the policy is incepted, there will be no payment on this day (0.00)
             // Iterate thru the months and apply the monthly payment
             while (key($scheduleObject->months)) {
                 $current = key($scheduleObject->months);
                 if ($current != strtolower($startMonth)) {
                     $scheduleObject->months[$current] = round($amount, 2);
                 }
                 next($scheduleObject->months);
             }
         }
     } else {
         /* Annual Stuff happens here */
         /**
          * Direct Debit annual set next month payment to full ammount
          **/
         if (strtolower($quote->getPayMethod()) == "directdebit" || strtolower($quote->getPayMethod()) == "dd") {
             $ddPayment = new Manager_Core_Directdebit();
             // Get Payment data no from dd table
             $ddData = $ddPayment->getByRefNo($refNo);
             // Set Payment refno
             $scheduleObject->paymentRefNo = $ddData->paymentRefNo;
             // Set Next month to full ammount
             $current = strtolower($firstPayMonth);
             $scheduleObject->months[$current] = round($quote->getPolicyQuote(), 2);
         } elseif (strtolower($quote->getPayMethod()) == "creditcard" || strtolower($quote->getPayMethod()) == "cc") {
             /**
              *  Credit Card annual sets all months to zero and Banked to full ammount
              **/
             $ccPayment = new Manager_Core_CreditCard();
             // Get Payment data no from cc table
             $ccData = $ccPayment->getByRefNo($refNo);
             // Set Payment refno
             $scheduleObject->paymentRefNo = $ccData->paymentRefNo;
             // Set firstPayment as banked
             $amount = $quote->getPolicyQuote();
         }
     }
     $schedule = new Datasource_Insurance_Schedules();
     $schedule->insertNew($scheduleObject);
 }
Esempio n. 8
0
 /**
  * Implements abstract method from superclass - refer to superclass for description.
  */
 public function setToRefer($quoteId)
 {
     $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteId);
     $quoteManager->setStatus('Referred');
     $quoteManager->save();
 }
 public function sendquoteAction()
 {
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     $quoteID = $pageSession->quoteID;
     $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteID);
     $postdata = $this->getRequest()->getPost();
     if (isset($postdata)) {
         // Find out how the customer wants their quote
         $sendBy = $postdata['how_send'];
         $request = $this->getRequest();
         $quoteManager->sendQuote($quoteManager->getPolicyNumber(), $sendBy);
     }
 }
 /**
  * Helper function for common work executed in each form step
  * Allows navigation between steps
  *
  * @param int $stepNum current step number
  *
  * @return void
  */
 private function _formStepCommonNavigate($stepNum)
 {
     $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
     $request = $this->getRequest();
     if ($request->isPost()) {
         // Handle moving backwards and forwards through the form
         $response = $this->getResponse();
         if ($stepNum == 'dd') {
             $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($this->_quoteID);
             $quoteNumber = $quoteManager->getPolicyNumber();
             $policyNumber = str_replace('Q', 'P', $quoteNumber);
             if (isset($_POST['next'])) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/ddconfirmation?pn=' . $policyNumber);
             }
             if (isset($_POST['back'])) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step' . $this->_stepMax);
             }
             $response->sendResponse();
         } elseif ($stepNum == 'cc') {
             if (isset($_POST['next'])) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/ccconfirmation');
             }
             if (isset($_POST['back'])) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step' . $this->_stepMax);
             }
             $response->sendResponse();
         } else {
             if (isset($_POST['back']) && $stepNum > 1) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step' . ($stepNum - 1));
             } elseif (isset($_POST['next']) && $stepNum < $this->_stepMax && $pageSession->completed[$stepNum]) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step' . ($stepNum + 1));
                 // Handle payment screen traversal
             } elseif (isset($_POST['next']) && isset($_POST['payment_method']) && $_POST['payment_method'] == 'cc' && $stepNum == $this->_stepMax) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/cc');
             } elseif (isset($_POST['next']) && isset($_POST['payment_method']) && $_POST['payment_method'] == 'dd' && $stepNum == $this->_stepMax) {
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/dd');
             }
         }
     }
 }
 public function isValid($formData)
 {
     //We only need additional information if some questions have been answered wrongly.
     $additionalInfoIsRequired = false;
     if (!empty($formData['declaration2']) && $formData['declaration2'] == 'no') {
         $additionalInfoIsRequired = true;
     } else {
         if (!empty($formData['declaration2b']) && $formData['declaration2b'] == 'no') {
             $additionalInfoIsRequired = true;
         } else {
             if (!empty($formData['declaration2c']) && $formData['declaration2c'] == 'yes') {
                 $additionalInfoIsRequired = true;
             } else {
                 if (!empty($formData['declaration2d']) && $formData['declaration2d'] == 'yes') {
                     $additionalInfoIsRequired = true;
                 } else {
                     if (!empty($formData['declaration3']) && $formData['declaration3'] == 'no') {
                         $additionalInfoIsRequired = true;
                     } else {
                         if (!empty($formData['declaration4']) && $formData['declaration4'] == 'no') {
                             $additionalInfoIsRequired = true;
                         } else {
                             if (!empty($formData['declaration6']) && $formData['declaration6'] == 'yes') {
                                 $additionalInfoIsRequired = true;
                             } else {
                                 if (!empty($formData['declaration8']) && $formData['declaration8'] == 'yes') {
                                     $additionalInfoIsRequired = true;
                                 } else {
                                     if (!empty($formData['declaration9']) && $formData['declaration9'] == 'yes') {
                                         $additionalInfoIsRequired = true;
                                     } else {
                                         if (!empty($formData['declaration10']) && $formData['declaration10'] == 'no') {
                                             $additionalInfoIsRequired = true;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($additionalInfoIsRequired) {
         $this->getElement('additional_information')->setRequired(true);
     } else {
         $this->getElement('additional_information')->setRequired(false);
     }
     //Superclass validations
     $returnVal = parent::isValid($formData);
     //Some compound processing. If the user has advised they have previous claims, then they must provide
     //details of these. Ensure this is the case.
     $session = new Zend_Session_Namespace('landlords_insurance_quote');
     $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID);
     $customerReferenceNumber = $quoteManager->getLegacyCustomerReference();
     $policyNumber = $quoteManager->getLegacyID();
     if (!empty($formData['declaration7'])) {
         if ($formData['declaration7'] == 'yes') {
             //One or more previous claims must exist.
             $claimsManager = new Manager_Insurance_PreviousClaims();
             $previousClaims = $claimsManager->getPreviousClaims($customerReferenceNumber);
             if (empty($previousClaims)) {
                 //Record error.
                 $this->declaration7->addError('Please provide details of previous claims');
                 $returnVal = false;
             }
         }
     }
     //If the user advised they have bank interest, then they must provide details of these.
     //Ensure this is the case.
     if (!empty($formData['declaration11'])) {
         if ($formData['declaration11'] == 'yes') {
             //One or more bank interests.
             $bankInterestManager = new Manager_Insurance_LegacyBankInterest();
             $bankInterestArray = $bankInterestManager->getAllInterests($policyNumber, $customerReferenceNumber);
             if (empty($bankInterestArray)) {
                 //Record error.
                 $this->declaration11->addError('Please provide details of bank interest');
                 $returnVal = false;
             }
         }
     }
     return $returnVal;
 }