} if ($address['address_line_2'] != '') { $lines[] = $address['address_line_2']; } if ($address['address_line_3'] != '') { $lines[] = $address['address_line_3']; } if ($address['address_line_4'] != '') { $lines[] = $address['address_line_4']; } if ($address['address_line_5'] != '') { $lines[] = $address['address_line_5']; } echo implode(chr(10), $lines); echo '</textarea></td>' . chr(10); echo '<td><input type="text" size="5" name="address_postalnum' . $id . '" id="address_postalnum' . $id . '" ' . 'value="' . $address['address_postalnum'] . '" ' . 'onkeyup="selectPostalNumber (\'address_postalplace' . $id . '\', document.getElementById(\'address_postalnum' . $id . '\').value);" ' . 'autocomplete="off"><br>' . '<input type="text" size="12" name="address_postalplace' . $id . '" id="address_postalplace' . $id . '" value="' . postalNumber($address['address_postalnum']) . '"></td>' . chr(10); echo '<td><input type="text" size="15" name="address_country' . $id . '" value="' . $address['address_line_7'] . '"></td>' . chr(10); echo '<td><input type="button" value="Fjern linje" onclick="removeFieldAddress(\'' . $id . '\');"></td>' . chr(10); echo '</tr>' . chr(10); $run_after .= 'as[' . $id . '] = new bsn.AutoSuggest(\'address_postalplace\' + ' . $id . ', autos_options_post, \'address_postalnum\' + ' . $id . ', \'\');' . chr(10); } echo '</table> <input type="button" value="' . _('Add one more address field') . '" onclick="addFieldAddress();"><br><br> * ' . _('Max 5 lines in each address') . '<br> ** ' . _('Place will be automaticlly found from the postalnumber. If the number is not valid, the field will just be empty.') . ' ' . _('You can also type a postal place in the field below.') . '<br> *** ' . _('For Norway, please leave this field empty.') . '<br> <br> </div>' . chr(10); /* ### ### ### ### ### ### ### */
} elseif (isset($_GET['postal_place'])) { // TODO: Fix bugs $postfil = file('libs/postnr'); $aResults = array(); foreach ($postfil as $line) { //echo trim(substr($line,4,strlen($_GET['postal_place'])+1)).' <b>----</b> '.$_GET['postal_place'].'<br>'; if (strtolower(trim(substr($line, 4, strlen($_GET['postal_place'])))) == strtolower($_GET['postal_place'])) { $poststed = trim(substr($line, 4, 31)); $postnum = trim(substr($line, 0, 4)); $aResults[] = array('id' => $postnum, 'value' => $poststed . ' (' . $postnum . ')', 'info' => $poststed); // Returnerer poststedet } } } elseif (isset($_GET['postal_num'])) { if (strlen($_GET['postal_num']) == 4 && postalNumber($_GET['postal_num'])) { echo postalNumber($_GET['postal_num']); } exit; } elseif (isset($_GET['customer_id'])) { $customer = getCustomer($_GET['customer_id']); if (count($customer)) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 header("Content-Type: application/json"); //echo "{\"customer\": [";
$postfil = file('libs/postnr'); $aResults = array(); foreach ($postfil as $line) { //echo trim(substr($line,4,strlen($_GET['postal_place'])+1)).' <b>----</b> '.$_GET['postal_place'].'<br>'; if (strtolower(trim(substr($line, 4, strlen($_GET['postal_place'])))) == strtolower($_GET['postal_place'])) { $poststed = trim(substr($line, 4, 31)); $postnum = trim(substr($line, 0, 4)); $aResults[] = array('id' => $postnum, 'value' => $poststed . ' (' . $postnum . ')', 'info' => $poststed); // Returnerer poststedet } } } elseif (isset($_GET['postal_num'])) { if (strlen($_GET['postal_num']) == 4 && postalNumber($_GET['postal_num'])) { // Fixing some norwegian characters, making utf-8 header('Content-Type: text/html; charset=utf-8'); echo utf8_encode(postalNumber($_GET['postal_num'])); } exit; } elseif (isset($_GET['customer_id'])) { $customer = getCustomer($_GET['customer_id']); if (count($customer)) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 header("Content-Type: application/json"); //echo "{\"customer\": [";