public function init() { //Reference subject title element $this->addElement('select', 'personal_title', array('label' => 'Tenant Title', 'required' => true, 'multiOptions' => array('' => 'Not Known', 'Mr' => 'Mr', 'Ms' => 'Ms', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Dr' => 'Dr', 'Prof' => 'Professor', 'Sir' => 'Sir'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the tenant title', 'notEmptyInvalid' => 'Please select a valid tenant title')))), 'attribs' => array('class' => 'form-control'))); //First name entry $this->addElement('text', 'first_name', array('label' => 'Tenant First Name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s first name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control'))); //Last name entry $this->addElement('text', 'last_name', array('label' => 'Tenant Last Name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s last name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control'))); // Email entry $this->addElement('text', 'email', array('label' => 'Tenant Email Address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s email address')))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control'))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('email')->addValidator($emailValidator); // Add share of rent element $this->addElement('text', 'share_of_rent', array('label' => 'Share of rent per month (£)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the share of rent per month')), 'Digits', true, array('messages' => array('notDigits' => 'Please enter the share of rent per month', 'digitsStringEmpty' => 'Please enter the Share of rent per month')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'currency', 'class' => 'currency form-control'))); // List the products based on the user choice. $productManager = new Manager_Referencing_Product(); $session = new Zend_Session_Namespace('referencing_global'); $productList = array(); if ($session->displayRentGuaranteeProducts) { $productVariable = Model_Referencing_ProductVariables::RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { if (!preg_match("/international/i", $product->name)) { $productList[$product->key] = strtoupper($product->name); } } } else { $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); $productSelection = new Model_Referencing_ProductSelection(); $productSelection->referenceId = 0; $productSelection->duration = 0; foreach ($products as $product) { if (!preg_match("/international/i", $product->name)) { $productSelection->product = $product; $price = $productManager->getPrice($productSelection); $productList[$product->key] = strtoupper($product->name) . " (" . $price . " + VAT)"; } } } $this->addElement('radio', 'product_choice', array('required' => true, 'multiOptions' => $productList, 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your product choice', 'notEmptyInvalid' => 'Please select a valid product choice')))))); //Identify if we need to indicate duration. if ($session->displayRentGuaranteeProducts) { //Determine the allowable durations... Needs to be done in ajax //Display duration box. $this->addElement('select', 'product_duration', array('label' => 'Product Duration (months)', 'required' => true, 'multiOptions' => array(6 => '6', 12 => '12'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the product duration', 'notEmptyInvalid' => 'Please select a valid product duration')))), 'attribs' => array('class' => 'form-control'))); } //Completion method element $this->addElement('select', 'completion_method', array('label' => 'Completion Method', 'required' => true, 'multiOptions' => array(Model_Referencing_ReferenceCompletionMethods::ONE_STEP => 'Complete Information Now', Model_Referencing_ReferenceCompletionMethods::TWO_STEP => 'Email to Tenant'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the completion method', 'notEmptyInvalid' => 'Please select a valid completion method')))), 'attribs' => array('class' => 'form-control'))); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'landlords-referencing/product-selection.phtml')))); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
/** * Get array of product choices * * @return array */ private function getProductChoices() { $productChoices = array(); $productManager = new \Manager_Referencing_Product(); $productResults = $productManager->getAll(true); foreach ($productResults as $product) { $productChoices[$product->name] = $product->name; } return $productChoices; }
/** * Fetches all the products * * @param string $fsa_status * @param int $letType * @param int $howRgOffered * @param bool $isCompanyApplication bool * * @return array */ public function fetchProducts($fsa_status, $letType, $howRgOffered, $isCompanyApplication = false) { $productList = array(); //Suppress all products for agents with an FSA status of none. if (preg_match("/^\$|none/i", $fsa_status)) { return $productList; } $productManager = new Manager_Referencing_Product(); if (!$this->canOfferRentGuanantee($fsa_status, $letType, $howRgOffered)) { //Offer only non-rent-guarantee products only. $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { $productList[] = array('value' => $product->key, 'name' => strtoupper($product->name)); } return $productList; } if ((strtoupper($fsa_status) == "AR" || strtoupper($fsa_status) == "DIRECT" || strtoupper($fsa_status) == "NAR") && $howRgOffered != 4) { // Get ALL products $productVariable = Model_Referencing_ProductVariables::RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { $productList[] = array('value' => $product->key, 'name' => strtoupper($product->name)); } $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { $productList[] = array('value' => $product->key, 'name' => strtoupper($product->name)); } } else { if ($howRgOffered == 4 || ($letType == 1 || $letType == 3) && $howRgOffered != 1) { // Get NON RG products only $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { $productList[] = array('value' => $product->key, 'name' => strtoupper($product->name)); } } else { // Get ALL products $productVariable = Model_Referencing_ProductVariables::RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { $productList[] = array('value' => $product->key, 'name' => strtoupper($product->name)); } $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE; $products = $productManager->getByVariable($productVariable); foreach ($products as $product) { $productList[] = array('value' => $product->key, 'name' => strtoupper($product->name)); } } } return $productList; }
/** * Create reference search form. * * @return void */ public function init() { // TODO: This is a stand-in until there's a product manager to give the // names of all active products $productList = array('' => 'Select Product'); $productManager = new Manager_Referencing_Product(); $productArray = $productManager->getAll(true); foreach ($productArray as $product) { $productList[$product->name] = $product->name; } $this->setMethod('get'); // Add reference number element $this->addElement('text', 'refno', array('label' => 'Reference Number', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^\\d+\\.?\\d+\\/?\\d+$/', 'messages' => 'Reference Number must contain digits and an optional full stop and/or forward slash'))))); // Add applicant first name element $this->addElement('text', 'firstname', array('label' => 'Applicant First Name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \']+$/i', 'messages' => 'Applicant First Name must contain alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add applicant last name element $this->addElement('text', 'lastname', array('label' => 'Applicant Last Name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \']+$/i', 'messages' => 'Applicant Last Name must contain alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add property address element $this->addElement('text', 'address', array('label' => 'Property Address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\-\\ \'\\,\\.]+$/i', 'messages' => 'Property Address must contain alphanumeric characters and only basic punctuation (hyphen, space, single quote, comma and full stop)'))))); // Add property town element $this->addElement('text', 'town', array('label' => 'Property Town', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \'\\,\\.]+$/i', 'messages' => 'Property Town must contain alphabetic characters and only basic punctuation (hyphen, space, single quote, comma and full stop)'))))); // Add postcode element $this->addElement('text', 'postcode', array('label' => 'Property Post Code', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\ ]+$/i', 'messages' => 'Property Post Code must only contain alphanumeric characters and spaces'))))); // Add state element $this->addElement('select', 'state', array('label' => 'State', 'required' => false, 'multiOptions' => array('Incomplete' => 'Incomplete', 'Complete' => 'Complete', 'Unknown' => 'Search All'))); // Add results per page element $this->addElement('select', 'rows', array('label' => 'Results per Page ', 'required' => false, 'multiOptions' => array('' => 'All', '10' => '10', '25' => '25', '50' => '50', '100' => '100'))); // Add page element $this->addElement('hidden', 'page', array('label' => '', 'value' => '1')); // Add type element $this->addElement('select', 'type', array('label' => 'Product', 'required' => false, 'multiOptions' => $productList)); // Set up the element decorators $this->setElementDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div')))); // Add search button $this->addElement('submit', 'search', array('label' => 'Search')); }
/** * 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; }