$render = ' <p><a href="?stage=">Back</a></p> <table border="1" cellpadding="5" cellspacing="0"><tr> '; foreach ($Data as $keyd => $data) { $render .= '<td><a href="?stage=3&search_string=' . $data["id"] . '&back_search=' . $_GET["search_string"] . '">' . trim($data["description"]) . '</a></td>' . "\n"; $i++; if ($i % 3 == 0) { $render .= "</tr>\n<tr>\n"; } } $render .= '</tr></table>'; $render = '<p>' . $i . ' Streets</p>' . $render; } elseif ($_GET["stage"] == 3) { $postcode = new Postcode(); $Data = $postcode->lookup("by_streetkey", $_GET["search_string"], "data"); $render = ' <p><a href="?stage=2&search_string=' . $_GET["back_search"] . '">Back</a></p> <table border="1" cellpadding="5" cellspacing="0"><tr> '; foreach ($Data as $keyd => $data) { $render .= '<td><a href="?stage=4&search_string=' . $data["id"] . '">' . trim($data["description"]) . '</a></td>' . "\n"; $i++; if ($i % 1 == 0) { $render .= "</tr>\n<tr>\n"; } } $render .= '</tr></table>'; $render = '<p>' . $i . ' Properties</p>' . $render; } elseif ($_GET["stage"] == 4) { $postcode = new Postcode();
header("Location:?{$return_url}&msg=Please+fill+in+all+the+fields"); exit; } // if postcode lookup is on (available) if ($postcode_on) { // prepare array foreach ($terms as $val) { $search_string .= $val . ','; } $search_string = remove_lastchar($search_string, ","); $postcode = new Postcode(); $render .= ' <p class="stageTitle">Double click the correct address</p> <form method="get"> <input type="hidden" name="stage" value="elaborate"> ' . $postcode->lookup('by_freetext', $search_string) . ' </form> <p>If the address is not listed above <a href="?' . $return_url . '">click here</a> to try again.</p> '; } else { // prepare search terms from array foreach ($terms as $val) { $sql .= " ( property.pro_addr1 LIKE '%" . $val . "%' OR property.pro_addr2 LIKE '%" . $val . "%' OR"; $sql .= " property.pro_addr3 LIKE '" . $val . "%' OR property.pro_postcode LIKE '%" . $val . "%' ) AND"; } $sql = "SELECT pro_id,pro_addr1,pro_addr2,pro_addr3,pro_postcode FROM property WHERE " . remove_lastchar($sql, "AND"); $q = $db->query($sql); if (DB::isError($q)) { die("db error: " . $q->getMessage()); } $numRows = $q->numRows();
$form->addHtml($form->addDiv($form->makeField("submit", $formName, "", "Save Changes", array('class' => 'submit')))); echo '<div id="inset">If this address is incorrect please <a href="javascript:cancelResponse();">try again</a></div>'; echo $form->renderForm(); exit; } elseif ($lookup_type == "manual") { // make the form $formData = array($scope . '_pcid' => array('type' => 'hidden', 'value' => '-1'), $scope . '_addr1' => array('type' => 'text', 'label' => 'House Number', 'required' => 2, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), $scope . '_addr2' => array('type' => 'text', 'label' => 'Building Name', 'required' => 1, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), $scope . '_addr3' => array('type' => 'text', 'label' => 'Street', 'required' => 2, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), $scope . '_addr5' => array('type' => 'text', 'label' => 'City or County', 'required' => 2, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), $scope . '_postcode' => array('type' => 'text', 'label' => 'Postcode', 'required' => 2, 'attributes' => array('class' => 'pc', 'maxlength' => 9), 'function' => 'format_postcode'), $scope . '_country' => array('type' => 'select', 'label' => 'Country', 'value' => $default_country, 'required' => 2, 'options' => db_lookup("pro_country", "country", "array"), 'attributes' => array('class' => 'addr'))); $form = new Form(); $form->addData($formData, $_GET); $formName = "form2"; $form->addHtml($form->addDiv($form->makeField("submit", $formName, "", "Save Changes", array('class' => 'submit')))); echo '<div id="inset">If this address is incorrect please <a href="javascript:cancelResponse();">try again</a></div>'; echo $form->renderForm(); exit; } else { $Data = $postcode->lookup($lookup_type, $search_string, "data"); if (count($Data) == 1) { foreach ($Data as $keyd => $data) { $udprn = $data["id"]; } header("Location:?lookup_type=udprn&search_string=" . $udprn . "&scope=" . $scope); exit; } else { $form = new Form(); $form->addHtml($form->addLabel("select", "Select Property", $postcode->output_list($Data))); $buttons = $form->makeField("button", "button", "", "Use Selected", array('class' => 'submit', 'onClick' => 'ajax_select_address(this.id);')); $buttons .= $form->makeField("button", "tryagain", "", "Try Again", array('class' => 'button', 'onClick' => 'cancelResponse();')); $form->addHtml($form->addDiv($buttons)); echo $form->renderForm(); exit; }