/** * Add a new job vacancy * */ public function addNew($jobTitle, $reportingTo, $location, $startDate, $endDate, $description) { $mysqlStartDate = Application_Core_Utilities::ukDateToMysql($startDate); $mysqlEndDate = Application_Core_Utilities::ukDateToMysql($endDate); $data = array('title' => $jobTitle, 'reporting_to' => $reportingTo, 'location' => $location, 'start_date' => $mysqlStartDate, 'end_date' => $mysqlEndDate, 'description' => $description); return $this->insert($data); }
/** * Set options * * @param array data An array of reference number, guarantor name, house name, street * town, city, postcode * @return void */ public function insertGuarantors($data, $guarantorId, $referenceNumber) { $dataArray = array(); //delete guarantor information before inserting to avoid dupliaction $this->removeGuarantors($referenceNumber); $totalGuarantors = empty($data['total_guarantors']) ? '0' : $data['total_guarantors']; for ($i = 1; $i <= $totalGuarantors; $i++) { if ($i <= 4) { if (isset($data['guarantor_address_' . $i]) && $data['guarantor_address_' . $i] != '' && $data['guarantor_address_' . $i] != '-') { // Address lookup worked $coreAddressManager = new Manager_Core_Postcode(); $guarantorAddress = $coreAddressManager->getPropertyByID($data['guarantor_address_' . $i]); $address_id = $guarantorAddress['id']; $houseName = $guarantorAddress['houseNumber'] != '' ? $guarantorAddress['houseNumber'] : $guarantorAddress['buildingName']; $street = $guarantorAddress['address1'] != '' ? $guarantorAddress['address1'] : $guarantorAddress['address2']; $town = $guarantorAddress['address4']; $city = $guarantorAddress['address5']; $postcode = $guarantorAddress['postcode']; } else { // Address lookup failed, hence manual entry $address_id = '-'; $houseName = $data['guarantor_housename_' . $i]; $street = $data['guarantor_street_' . $i]; $town = $data['guarantor_town_' . $i]; $city = $data['guarantor_city_' . $i]; $postcode = $data['guarantor_postcode_' . $i]; } $dataArray['reference_number'] = $referenceNumber; $dataArray['guarantor_name'] = $data['guarantor_name_' . $i]; $dataArray['hometelno'] = $data['guarantor_hometelno_' . $i]; $dataArray['worktelno'] = $data['guarantor_worktelno_' . $i]; $dataArray['mobiletelno'] = $data['guarantor_mobiletelno_' . $i]; $dataArray['email'] = $data['guarantor_email_' . $i]; $dataArray['dob'] = Application_Core_Utilities::ukDateToMysql($data['guarantors_dob_' . $i]); $dataArray['address_id'] = $address_id; $dataArray['house_name'] = $houseName; $dataArray['street'] = $street; $dataArray['town'] = $town; $dataArray['city'] = $city; $dataArray['postcode'] = $postcode; $dataArray['homeletrefno'] = $data['guarantor_homeletrefno_' . $i]; if ($guarantorId != '') { $where = $this->getAdapter()->quoteInto('id = ?', $guarantorId); $this->update($data, $where); } else { $this->insert($dataArray); } } } }
/** * Set options * * @param array data An array of reference number, tenant name, house name, street * town, city, postcode * @return void */ public function insertTenants($data, $referenceNumber) { $dataArray = array(); // remove tenants inserted before $this->removeTenants($referenceNumber); //get guaranor address from already existing postocde address table $totalTenants = empty($data['total_tenants']) ? '0' : $data['total_tenants']; for ($i = 1; $i <= $totalTenants; $i++) { if ($i <= 7) { $tenantDOB = Application_Core_Utilities::ukDateToMysql($data['tenants_dob_' . $i]); $dataArray['reference_number'] = $referenceNumber; $dataArray['tenant_name'] = $data['tenant_name_' . $i]; $dataArray['tenant_hometelno'] = $data['tenant_hometelno_' . $i]; $dataArray['tenant_worktelno'] = $data['tenant_worktelno_' . $i]; $dataArray['tenant_mobiletelno'] = $data['tenant_mobiletelno_' . $i]; $dataArray['tenant_email'] = $data['tenant_email_' . $i]; $dataArray['tenant_dob'] = $tenantDOB; $dataArray['rg_policy_ref'] = $data['rg_policy_ref_' . $i]; $this->insert($dataArray); } } }
/** * @param mixed array $data */ private function _update($data) { if (isset($dataToSave['date_established'])) { $dataToSave['date_established'] = Application_Core_Utilities::ukDateToMysql($data['date_established']); } $dataToSave = array_diff_key($data, array('id' => "")); $where = $this->quoteInto('uid = ?', $dataToSave['uid']); $this->update($dataToSave, $where); return $data['id']; }
/** * Initialise the step 1 form * * @return void */ public function step1Action() { // Append the address lookup javascript $this->view->headScript()->appendFile('/assets/common/js/addressLookup.js', 'text/javascript'); // Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 1;'); $pageForm = new Form_PortfolioInsuranceQuote_Step1(); if ($this->getRequest()->isPost()) { // We need to validate and save the data // TODO: Need to re-factor this to make it quicker $valid = $this->_formStepCommonValidate($pageForm, 1); // As these items aren't stored in the DB, assume that if user has validated step 1 in the past // then DPA and IDD are ticked $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote'); $pageForm->subform_idd->getElement('idd')->setValue($pageSession->step1->idd); if ($valid) { // Save the data and continue to next step $data = $pageForm->getValues(); // According to the Zend manual these *should* be the clean values $pageSession->step1->idd = $data["subform_idd"]["idd"]; //Capture and store the insurance data protections. $this->_saveInsuranceDPA($data["subform_dataprotection"]["dpa_phone_post"], $data["subform_dataprotection"]["dpa_sms_email"], $data["subform_dataprotection"]["dpa_resale"]); $customerObject = new Model_Insurance_Portfolio_LegacyCustomer(); $customerObject->title = $data["subform_personaldetails"]["title"]; $customerObject->first_name = $data["subform_personaldetails"]["first_name"]; $customerObject->last_name = $data["subform_personaldetails"]["last_name"]; // Look up address again to populate dropdown $customerObject->address1 = $data["subform_correspondenceaddress"]["cor_address_line1"]; $customerObject->address2 = $data["subform_correspondenceaddress"]["cor_address_line2"]; $customerObject->address3 = $data["subform_correspondenceaddress"]["cor_address_line3"]; $customerObject->postcode = $data["subform_correspondenceaddress"]["cor_postcode"]; $customerObject->telephone1 = $data["subform_personaldetails"]["phone_number"]; $customerObject->telephone2 = $data["subform_personaldetails"]["mobile_number"]; $customerObject->email_address = $data["subform_personaldetails"]["email_address"]; $customerObject->date_of_birth_at = Application_Core_Utilities::ukDateToMysql($data['subform_personaldetails']['date_of_birth_at']); // Check to see if we have a session if (!isset($pageSession->CustomerRefNo)) { // We don't have a session so we need to create a new customer/quote entry to save against // Now get the reference number from the newly created customer // This is not a standard referecnce number // Saved customer now create portfolio reference number $NumberTracker = new Datasource_Core_NumberTracker(); $customerRefNo = $NumberTracker->getNextPortfolioNumber(); $customerObject->refNo = $customerRefNo; $customerManager = new Manager_Insurance_Portfolio_LegacyCustomer(); $customerManager->save($customerObject); $this->_customerReferenceNumber = $customerRefNo; $pageSession->CustomerRefNo = $customerRefNo; } else { // We are in session so just instantiate the customer manager with the existing reference number $customerManager = new Manager_Insurance_Portfolio_LegacyCustomer(); $customerObject->refNo = $pageSession->CustomerRefNo; } $customerManager->save($customerObject); //Record this WebLead, if not already done so. First create or retrieve the //WebLead summary. $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote'); $webLeadManager = new Manager_Core_WebLead(); if (empty($pageSession->webLeadSummaryId)) { $isNewWebLead = true; $webLeadSummary = $webLeadManager->createNewSummary(); } else { $isNewWebLead = false; $webLeadSummary = $webLeadManager->getSummary($pageSession->webLeadSummaryId); } //Create or retrieve the step 1 blob. if (!$webLeadManager->getBlobExists($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP1)) { $webLeadBlob = $webLeadManager->createNewBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP1); } else { $webLeadBlob = $webLeadManager->getBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP1); } //Update the WebLead summary and store. $webLeadSummary->title = $data["subform_personaldetails"]["title"]; $webLeadSummary->firstName = $data["subform_personaldetails"]["first_name"]; $webLeadSummary->lastName = $data["subform_personaldetails"]["last_name"]; if (!empty($data["subform_personaldetails"]["phone_number"])) { $contactNumber = $data["subform_personaldetails"]["phone_number"]; } else { $contactNumber = $data["subform_personaldetails"]["mobile_number"]; } $webLeadSummary->contactNumber = $contactNumber; $webLeadSummary->emailAddress = $data["subform_personaldetails"]["email_address"]; if ($isNewWebLead) { $webLeadSummary->startTime = $this->_offsetDate(); } $webLeadSummary->lastUpdatedTime = $this->_offsetDate(); $webLeadSummary->product = Model_Core_WebLeadProduct::PORTFOLIO; $webLeadSummary->quoteNumber = $customerRefNo; $webLeadManager->updateSummary($webLeadSummary); //Update the blob, serialize and store. $webLeadBlob->blob = Zend_Json::encode($_POST); $webLeadBlob->blobChecksum = crc32($webLeadBlob->blob); $webLeadManager->updateBlob($webLeadBlob); //Finally, record the WebLead identifier in the page session. $pageSession->webLeadSummaryId = $webLeadSummary->webLeadSummaryId; //Capture and store the WebLead data protections. $this->_saveWebLeadDPA($webLeadSummary->webLeadSummaryId, $data["subform_dataprotection"]["dpa_phone_post"], $data["subform_dataprotection"]["dpa_sms_email"], $data["subform_dataprotection"]["dpa_resale"]); $this->_formStepCommonNavigate(1); return; } elseif (isset($_POST['back'])) { $this->_formStepCommonNavigate(1); return; } } // Load the element data from the database if we can if ($this->_formStepCommonPopulate($pageForm, 1)) { // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step'); } }
/** * Updates a claim. * * @param array * * @return void */ public function updateClaim($claim) { // These dates are not mandatory $tenancyEndDate = $claim->getTenancyEndDate() ? Application_Core_Utilities::ukDateToMysql($claim->getTenancyEndDate()) : null; $tenantVacatedDate = $claim->getTenantVacatedDate() ? Application_Core_Utilities::ukDateToMysql($claim->getTenantVacatedDate()) : null; $confirmedByTelDate = $claim->getTenantsOccupationOfPropertyConfirmedByTelDate() ? Application_Core_Utilities::ukDateToMysql($claim->getTenantsOccupationOfPropertyConfirmedByTelDate()) : null; $confirmedByEmailDate = $claim->getTenantsOccupationOfPropertyConfirmedByEmailDate() ? Application_Core_Utilities::ukDateToMysql($claim->getTenantsOccupationOfPropertyConfirmedByEmailDate()) : null; $confirmedByVisitDate = $claim->getTenantsOccupationOfPropertyConfirmedByVisitDate() ? Application_Core_Utilities::ukDateToMysql($claim->getTenantsOccupationOfPropertyConfirmedByVisitDate()) : null; $s21NoticeExpiryDate = $claim->getS21NoticeExpiry() ? Application_Core_Utilities::ukDateToMysql($claim->getS21NoticeExpiry()) : null; $s8NoticeExpiryDate = $claim->getS8NoticeExpiry() ? Application_Core_Utilities::ukDateToMysql($claim->getS8NoticeExpiry()) : null; $data = array('last_updated_date' => date('Y-m-d'), 'agent_name' => $claim->getAgentName(), 'agent_contact_name' => $claim->getAgentContactName(), 'agent_postcode' => $claim->getAgentPostcode(), 'agent_housename' => $claim->getAgentHousename(), 'agent_street' => $claim->getAgentStreet(), 'agent_town' => $claim->getAgentTown(), 'agent_city' => $claim->getAgentCity(), 'agent_telephone' => $claim->getAgentTelephone(), 'agent_fax' => $claim->getAgentFax(), 'agent_email' => $claim->getAgentEmail(), 'agent_isar' => $claim->getIsAr(), 'agent_isdir' => $claim->getIsDir(), 'housing_act_adherence' => $claim->getHousingActAdherence(), 'tenancy_start_date' => Application_Core_Utilities::ukDateToMysql($claim->getTenancyStartDate()), 'tenancy_renewal_date' => $tenancyEndDate, 'original_cover_start_date' => Application_Core_Utilities::ukDateToMysql($claim->getOriginalCoverStartDate()), 'tenancy_address_id' => $claim->getTenancyAddressId(), 'tenancy_postcode' => $claim->getTenancyPostcode(), 'tenancy_housename' => $claim->getTenancyHouseName(), 'tenancy_street' => $claim->getTenancyStreet(), 'tenancy_town' => $claim->getTenancyTown(), 'tenancy_city' => $claim->getTenancyCity(), 'monthly_rent' => $claim->getMonthlyRent(), 'deposit_amount' => $claim->getDepositAmount(), 'rent_arrears' => $claim->getRentArrears() ? $claim->getRentArrears() : NULL, 'tenant_vacated_date' => $tenantVacatedDate, 'first_arrear_date' => $claim->getFirstArrearDate() ? Application_Core_Utilities::ukDateToMysql($claim->getFirstArrearDate()) : NULL, 'deposit_received_date' => Application_Core_Utilities::ukDateToMysql($claim->getDepositReceivedDate()), 'landlord1_name' => $claim->getLandlord1Name(), 'landlord_company_name' => $claim->getLandlordCompanyName(), 'landlord_address_id' => $claim->getLandlordAddressId(), 'landlord_postcode' => $claim->getLandlordPostcode(), 'landlord_housename' => $claim->getLandlordHouseName(), 'landlord_street' => $claim->getLandlordStreet(), 'landlord_town' => $claim->getLandlordTown(), 'landlord_city' => $claim->getLandlordCity(), 'landlord_telephone' => $claim->getLandlordTelephone(), 'landlord_fax' => $claim->getLandlordFax(), 'landlord_email' => $claim->getLandlordEmail(), 'cheque_payable_to' => $claim->getChequePayableTo(), 'additional_information' => $claim->getAdditionalInfo(), 'doc_confirmation_agent_name' => $claim->getDocConfirmationAgentName(), 'submitted_to_keyhouse' => $claim->getSubmittedToKeyHouse(), 'housing_benefit_applied' => $claim->getHousingBenefitApplied(), 'data_complete' => $claim->getDataComplete(), 'tenant_vacated' => $claim->getTenantVacated(), 'recent_complaints' => $claim->getRecentComplaints(), 'recent_complaints_further_details' => $claim->getRecentComplaintsDetails(), 'policy_number' => $claim->getPolicyNumber(), 'grounds_for_claim' => $claim->getGroundsForClaim(), 'grounds_for_claim_further_details' => $claim->getGroundsForClaimDetails(), 'arrears_at_vacant_possession' => $claim->getArrearsAtVacantPossession(), 'tenant_occupation_confirmed_by_tel' => $claim->getTenantsOccupationOfPropertyConfirmedByTel(), 'tenant_occupation_confirmed_by_tel_dateofcontact' => $confirmedByTelDate, 'tenant_occupation_confirmed_by_tel_tenantname' => $claim->getTenantsOccupationOfPropertyConfirmedByTelContact(), 'tenant_occupation_confirmed_by_email' => $claim->getTenantsOccupationOfPropertyConfirmedByEmail(), 'tenant_occupation_confirmed_by_email_dateofcontact' => $confirmedByEmailDate, 'tenant_occupation_confirmed_by_email_tenantname' => $claim->getTenantsOccupationOfPropertyConfirmedByEmailContact(), 'tenant_occupation_confirmed_by_visit' => $claim->getTenantsOccupationOfPropertyConfirmedByVisit(), 'tenant_occupation_confirmed_by_visit_dateofvisit' => $confirmedByVisitDate, 'tenant_occupation_confirmed_by_visit_individualattending' => $claim->getTenantsOccupationOfPropertyConfirmedByVisitIndividual(), 'tenant_occupation_confirmed_by_visit_tenantname' => $claim->getTenantsOccupationOfPropertyConfirmedByVisitContact(), 'tenantsforwarding_address_id' => $claim->getTenantsForwardingAddressId(), 'tenantsforwarding_housename' => $claim->getTenantsForwardingHouseName(), 'tenantsforwarding_street' => $claim->getTenantsForwardingStreet(), 'tenantsforwarding_town' => $claim->getTenantsForwardingTown(), 'tenantsforwarding_city' => $claim->getTenantsForwardingCity(), 'tenantsforwarding_postcode' => $claim->getTenantsForwardingPostcode(), 'section21_served' => $claim->getS21NoticeServed(), 'section21_expiry' => $s21NoticeExpiryDate, 'section21_moneydepositreceived' => $claim->getS21NoticeMoneyDepositReceived(), 'section21_money_held_under_tds_deposit_scheme' => $claim->getS21NoticeMoneyDepositHeldUnderTdsScheme(), 'section21_tds_complied_with' => $claim->getS21NoticeTdsCompliedWith(), 'section21_tds_prescribed_information_to_tenant' => $claim->getS21NoticeTdsPrescribedToTenant(), 'section21_landlord_deposit_in_property_form' => $claim->getS21NoticeLandlordDepositInPropertyForm(), 'section21_returned_at_notice_serve_date' => $claim->getS21NoticePropertyReturnedAtNoticeServeDate(), 'section8_served' => $claim->getS8NoticeServed(), 'section8_expiry' => $s8NoticeExpiryDate, 'section8_demand_letter_sent' => $claim->getS8NoticeDemandLetterSent(), 'section8_over18_occupants' => $claim->getS8NoticeOver18Occupants(), 'payment_account_name' => $claim->getClaimPaymentBankAccountName(), 'payment_account_number' => $claim->getClaimPaymentBankAccountNumber(), 'payment_account_sortcode' => $claim->getClaimPaymentBankAccountSortCode(), 'landlord_property_proprietor' => $claim->getLandlordIsPropertyProprietor(), 'authority_confirmed' => $claim->getAuthorityConfirmed(), 'dec_confirmed' => $claim->getDeclarationConfirmed()); $where = $this->getAdapter()->quoteInto('reference_number = ?', $claim->_referenceNumber); $this->update($data, $where); }
/** * Initialise the step 3 form [Important Information Form] * * @return void */ public function step3Action() { $pageForm = new TenantsInsuranceQuoteB_Form_Step3(); // Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 3;'); // Get customer details $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); // Hydrate registration form if (isset($pageForm->subform_register) || isset($pageForm->subform_login)) { // Grab a new customer to populate the form $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $newCust = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $pageSession->CustomerID); if (isset($pageForm->subform_register)) { if ($newCust) { $pageForm->subform_register->email->setValue($newCust->getEmailAddress()); $pageForm->subform_register->security_question->setValue($newCust->getSecurityQuestion()); $pageForm->subform_register->security_answer->setValue($newCust->getSecurityAnswer()); $emailAddress = $newCust->getEmailAddress(); } else { $pageForm->subform_register->email->setValue($customer->getEmailAddress()); $emailAddress = $customer->getEmailAddress(); } if (!$emailAddress) { $emailAddress = $newCust->getEmailAddress(); } } else { if ($newCust) { $pageForm->subform_login->email->setValue($newCust->getEmailAddress()); } } } if ($this->getRequest()->isPost()) { $valid = $this->_formStepCommonValidate($pageForm, 3); if (isset($pageForm->subform_register)) { $pageForm->subform_register->getElement('email')->setValue($emailAddress); } if ($valid) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $pageSession->IsNewCustomer = false; $data = $pageForm->getValues(); //Update the WebLead summary and create a STEP3 blob. $webLeadManager = new Manager_Core_WebLead(); $webLeadSummary = $webLeadManager->getSummary($this->_webLeadSummaryId); $webLeadSummary->lastUpdatedTime = $this->_offsetDate(); $webLeadSummary->promotionCode = $data["subform_howhear"]['campaign_code']; $webLeadManager->updateSummary($webLeadSummary); //Determine if a new STEP3 blob needs to be created, or an existing one retrieved. if ($webLeadManager->getBlobExists($this->_webLeadSummaryId, Model_Core_WebLeadStep::STEP3)) { $webLeadBlob = $webLeadManager->getBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3); } else { $webLeadBlob = $webLeadManager->createNewBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3); } //Update the blob and store $webLeadBlob->blob = Zend_Json::encode($_POST); $webLeadBlob->blobChecksum = crc32($webLeadBlob->blob); $webLeadManager->updateBlob($webLeadBlob); // Instantiate the quote manager $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber); // Save new ASN if there is one // Create a postcode model $postcode = new Manager_Core_Postcode(); // Get the address as array for Insured and correspondance address $insuredAddress = $postcode->getPropertyByID($data['subform_insuredaddress']['ins_address'], false); $correspondenceAddress = $postcode->getPropertyByID($data['subform_correspondencedetails']['cor_address'], false); // Update the property address in the quote $quoteManager->setPropertyAddress(($insuredAddress['organisation'] != '' ? "{$insuredAddress['organisation']}, " : '') . ($insuredAddress['buildingName'] != '' ? "{$insuredAddress['buildingName']}, " : '') . ($insuredAddress['houseNumber'] != '' ? "{$insuredAddress['houseNumber']} " : '') . $insuredAddress['address2'], $insuredAddress['address4'], $insuredAddress['address5'], $insuredAddress['postcode']); // Update start and end dates $startDate = $data['subform_policydetails']['policy_start']; $startDate = substr($startDate, 6, 4) . '-' . substr($startDate, 3, 2) . '-' . substr($startDate, 0, 2); $endDate = date('Y-m-d', strtotime(date('Y-m-d', strtotime($startDate)) . ' +1 year -1 day')); $quoteManager->setStartAndEndDates($startDate, $endDate); //Update the customer in the DataStore and the LegacyDataStore. Use the CustomerManager //to do this. //$customerManager = new Manager_Core_Customer(); //First get the existing customer details. //$customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); //Now modify the details. $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']); $customer->setPostCode($correspondenceAddress['postcode']); $customer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); //Finally, save the details back to both DataStores. $customerManager->updateCustomer($customer); $premiums = $quoteManager->calculatePremiums(); // Save MI information - how did you hear about us $marketQuestion = new Manager_Core_ManagementInformation(); $marketQuestion->saveMarketingAnswers($this->_policyNumber, $this->_customerReferenceNumber, $data["subform_howhear"]["how_hear"]); // Perform login/register procedure $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer')); if (isset($data['subform_register'])) { // Process registration $params = Zend_Registry::get('params'); $newCustomer = $customerManager->getCustomerByEmailAddress($data['subform_register']['email']); if (!$newCustomer) { $newCustomer = $customerManager->createCustomerFromLegacy($data['subform_register']['email'], $this->_customerReferenceNumber); } // Update customer with password and security data $newCustomer->setTitle($customer->getTitle()); $newCustomer->setFirstName($customer->getFirstName()); $newCustomer->setLastName($customer->getLastName()); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']); $newCustomer->setPostCode($correspondenceAddress['postcode']); $newCustomer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); // assuming that the email is already set and so won't require setting again. // $newCustomer->setEmailAddress($data['subform_register']['email']); $newCustomer->setSecurityQuestion($data['subform_register']['security_question']); $newCustomer->setSecurityAnswer($data['subform_register']['security_answer']); $newCustomer->setPassword($data['subform_register']['password']); $newCustomer->setAccountLoadComplete(true); $newCustomer->typeID = Model_Core_Customer::CUSTOMER; $customerManager->updateCustomer($newCustomer); // Create sign-up completion email $mail = new Application_Core_Mail(); $mail->setTo($data['subform_register']['email'], null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject('My HomeLet account validation'); // Generate activation link $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false); $digest = $mac->generate(array('email' => $data['subform_register']['email'])); $activationLink = 'email=' . $data['subform_register']['email'] . '&' . 'mac=' . $digest; // Apply template $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml'); $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml'); // Send email $mail->send(); // Everything has been saved ok so navigate to next step $this->_formStepCommonNavigate(3); } elseif ($auth->hasIdentity()) { $this->_formStepCommonNavigate(3); } //return; } elseif (isset($_POST['back'])) { $this->_formStepCommonNavigate(3); return; } } // Load the element data from the database if we can if ($this->_formStepCommonPopulate($pageForm, 3)) { // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step'); } }
/** * Set options * * @param array data An array of rent payment id, reference number, date due, amount due * amount paid, date paid & arrear amount * @return void */ public function updateRentalPayments($data) { $dataArray = array(); foreach ($data->updateRecords as $updatePayment) { $dateDue = Application_Core_Utilities::ukDateToMysql($updatePayment->date_due); if (strtoupper($updatePayment->date_paid) === self::DATE_PAID_NOT_APPLICABLE) { $datePaid = ''; } else { $datePaid = Application_Core_Utilities::ukDateToMysql($updatePayment->date_paid); } $dataArray['id'] = $updatePayment->id; $dataArray['reference_number'] = $updatePayment->reference_number; $dataArray['date_due'] = $dateDue; $dataArray['amount_due'] = $updatePayment->amount_due; $dataArray['amount_paid'] = $updatePayment->amount_paid; $dataArray['date_paid'] = $datePaid; $where = $this->getAdapter()->quoteInto('id = ?', $dataArray['id'] . 'AND' . 'reference_number = ?', $dataArray['reference_number']); $this->update($dataArray, $where); } return true; }
/** * Handle registering for or sign in to My HomeLet. * * @param int $policyNumber * @return LandlordsInsuranceQuote_Form_MyHomeLetRegistration */ private function registrationFormProcess($policyNumber) { $pageForm = new LandlordsInsuranceQuote_Form_MyHomeLetRegistration(); // Tell page NOT to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = false;'); // Get the session $session = new Zend_Session_Namespace('landlords_insurance_quote'); // Get customer details $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); // Hydrate registration form if (isset($pageForm->subform_register)) { // Grab a new customer to populate the form $newCust = $customerManager->getCustomerByEmailAddress($customer->getEmailAddress()); if ($newCust) { $pageForm->subform_register->email->setValue($newCust->getEmailAddress()); $pageForm->subform_register->security_question->setValue($newCust->getSecurityQuestion()); $pageForm->subform_register->security_answer->setValue($newCust->getSecurityAnswer()); $emailAddress = $newCust->getEmailAddress(); } else { $pageForm->subform_register->email->setValue($customer->getEmailAddress()); $emailAddress = $customer->getEmailAddress(); } if (!$emailAddress) { $emailAddress = $newCust->getEmailAddress(); } } elseif (isset($pageForm->subform_login)) { // Get the email address from the legacy customer and pre-populate the login form $pageForm->subform_login->email->setValue($customer->getEmailAddress()); } if ($this->getRequest()->isPost() && isset($_POST['register'])) { // We need to validate and save the data $valid = $this->_formStepCommonValidate($pageForm, 'registration'); if (isset($pageForm->subform_register)) { $pageForm->subform_register->getElement('email')->setValue($emailAddress); } if ($valid) { $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); $data = $pageForm->getValues(); // Re-add the DoB remembered from Step 1 because otherwise logging-in landlords' DoBs go missing. $customer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); $customerManager->updateCustomer($customer); // Perform login/register procedure $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer')); if (isset($data['subform_register'])) { // Process registration $newCustomer = $customerManager->getCustomerByEmailAddress($data['subform_register']['email']); if (!$newCustomer) { $newCustomer = $customerManager->createCustomerFromLegacy($data['subform_register']['email'], $this->_customerReferenceNumber); $customerID = $newCustomer->getIdentifier(Model_Core_Customer::IDENTIFIER); $customerManager->updateCustomerByLegacy($customer, $customerID); $newCustomer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerID); } // Update customer with password and security data $newCustomer->setEmailAddress($data['subform_register']['email']); // Set the new customer's DoB with that remembered from Step 1 otherwise newly registering // landlords' DoBs become empty. $newCustomer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); $newCustomer->setSecurityQuestion($data['subform_register']['security_question']); $newCustomer->setSecurityAnswer($data['subform_register']['security_answer']); $newCustomer->setPassword($data['subform_register']['password']); $newCustomer->setAccountLoadComplete(true); $newCustomer->typeID = Model_Core_Customer::CUSTOMER; $customerManager->updateCustomer($newCustomer); // Create sign-up completion email $newCustomer->sendAccountValidationEmail(); // Everything has been saved OK so navigate to registration confirmation step $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/registration-confirmation?pn=' . $policyNumber); } elseif ($auth->hasIdentity()) { $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/registration-confirmation?pn=' . $policyNumber); } } } return $pageForm; }
/** * Handle registering for or sign in to My HomeLet. * * @param int $policyNumber * @return TenantsInsuranceQuote_Form_MyHomeLetRegistration */ private function registrationFormProcess($policyNumber) { $pageForm = new TenantsInsuranceQuote_Form_MyHomeLetRegistration(); // Tell page NOT to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = false;'); // Get customer details $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); // Hydrate registration form if (isset($pageForm->subform_register) || isset($pageForm->subform_login)) { // Grab a new customer to populate the form $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $newCust = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $pageSession->CustomerID); if (isset($pageForm->subform_register)) { if ($newCust) { $pageForm->subform_register->email->setValue($newCust->getEmailAddress()); $pageForm->subform_register->security_question->setValue($newCust->getSecurityQuestion()); $pageForm->subform_register->security_answer->setValue($newCust->getSecurityAnswer()); $emailAddress = $newCust->getEmailAddress(); } else { $pageForm->subform_register->email->setValue($customer->getEmailAddress()); $emailAddress = $customer->getEmailAddress(); } if (!$emailAddress) { $emailAddress = $newCust->getEmailAddress(); } } else { if ($newCust) { $pageForm->subform_login->email->setValue($newCust->getEmailAddress()); } } } if ($this->getRequest()->isPost() && isset($_POST['register'])) { $valid = $this->_formStepCommonValidate($pageForm, 'registration'); if (isset($pageForm->subform_register)) { $pageForm->subform_register->getElement('email')->setValue($emailAddress); } if ($valid) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $pageSession->IsNewCustomer = false; $data = $pageForm->getValues(); // Perform login/register procedure $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer')); if (isset($data['subform_register'])) { // Process registration $newCustomer = $customerManager->getCustomerByEmailAddress($data['subform_register']['email']); if (!$newCustomer) { $newCustomer = $customerManager->createCustomerFromLegacy($data['subform_register']['email'], $this->_customerReferenceNumber); } // Update customer with password and security data $newCustomer->setTitle($customer->getTitle()); $newCustomer->setFirstName($customer->getFirstName()); $newCustomer->setLastName($customer->getLastName()); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE1)); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE2)); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE3)); $newCustomer->setPostcode($customer->getPostcode()); $newCustomer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); $newCustomer->setSecurityQuestion($data['subform_register']['security_question']); $newCustomer->setSecurityAnswer($data['subform_register']['security_answer']); $newCustomer->setPassword($data['subform_register']['password']); $newCustomer->setAccountLoadComplete(true); $newCustomer->typeID = Model_Core_Customer::CUSTOMER; $customerManager->updateCustomer($newCustomer); // Create sign-up completion email $newCustomer->sendAccountValidationEmail(); // Everything has been saved OK so navigate to registration confirmation step $this->_helper->redirector->gotoUrl('/tenants/insurance-quote/registration-confirmation?pn=' . $policyNumber); } elseif ($auth->hasIdentity()) { $this->_helper->redirector->gotoUrl('/tenants/insurance-quote/registration-confirmation?pn=' . $policyNumber); } } } return $pageForm; }
/** * @param mixed array $data */ private function _update($data) { //Zend_Debug::dump($data); // die("UPDATE"); if (isset($data['birth_date'])) { $data['birth_date'] = Application_Core_Utilities::ukDateToMysql($data['birth_date']); } $dataToSave = array_diff_key($data, array('id' => "")); $where = $this->quoteInto('uid = ?', $data['uid']); if ($lastId = $this->update($dataToSave, $where)) { return $lastId; } else { // Error Application_Core_Logger::log("Could not update table {$this->_name}", 'error'); return false; } }