source: subversion/applications/mobile/healthwhere/detail.php @ 34887

Last change on this file since 34887 was 21241, checked in by avantman42, 9 years ago

Removed source column in OS-created postcode DB. No need for it, and should make DB file smaller
Now using OS postcode data (OS OpenData? Code-Point® Open)
Re-licensed (GPL v2) because PHPCoord is licensed under GPL v2

File size: 4.0 KB
Line 
1<?php
2/*
3Healthwhere, a web service to find local pharmacies and hospitals
4Copyright (C) 2009-2010 Russell Phillips (russ@phillipsuk.org)
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along
17with this program; if not, write to the Free Software Foundation, Inc.,
1851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21require ("inc_head.php");
22require_once ("inc_head_html.php");
23
24$id = (int) $_GET ["id"];
25$dist = (float) $_GET ["dist"];
26$search = $_COOKIE ["SearchType"];
27$waynode = $_GET ['waynode'];
28
29//Get data from OSM
30if ($waynode == 'node')
31        $url = "$osm_api_base/node/$id";
32else
33        $url = "$osm_api_base/way/$id";
34$xml = simplexml_load_file ($url);
35if ($xml === False)
36        death ("Error getting data from $url", "Could not get data from OpenStreetMap");
37
38$ph = array ();
39if ($waynode == 'node')
40        node_parse ($xml->node [0], $search, $ph);
41else
42        node_parse ($xml->way [0], $search, $ph);
43
44$sname = stripslashes ($ph ["name"]);
45$soperator = stripslashes ($ph ["operator"]);
46if ($sname != "" && $soperator != "")
47        $displayname = "$sname ($soperator)";
48elseif ($sname == "" && $soperator == "")
49        $displayname = "[No name]";
50else
51        $displayname = "$sname$soperator";
52echo "<p><b>$displayname</b></p>\n";
53
54if ($_GET ['edit'] == "yes")
55        echo "<p><i>Details edited. Note that it may take some time for the new details to be displayed in all views.</i></p>";
56
57echo "<p>$dist miles away\n";
58//Only display map link in JS-capable browsers
59$sMap = "\n<script type='text/javascript'>\n<!--\n";
60$mapurl = "http://www.openstreetmap.org/?mlat={$ph ['lat']}&mlon={$ph ['lon']}&zoom=17";
61$sMap .= "document.write (\" (<a href = '$mapurl' title = 'map of $postcode'>map</a>)\")";
62$sMap .= "\n// -->\n";
63$sMap .= "</script>\n<br>\n";
64echo $sMap;
65
66if ($ph ['dispensing'] != '') {
67        $dispensing = strtolower ($ph ['dispensing']);
68        if ($dispensing == "yes" || $dispensing == "true" || $dispensing == "1")
69                echo "<p>Dispensing: Yes</p>\n";
70        elseif ($dispensing == "no" || $dispensing == "false" || $dispensing == "0")
71                echo "<p>Dispensing: No</p>\n";
72}
73
74if ($ph ['addr_housename'] != '')
75        echo $ph ['addr_housename'] . "<br>\n";
76if ($ph ['addr_street'] != '') {
77        if ($ph ['addr_housenumber'] != '')
78                echo $ph ['addr_housenumber'] . " ";
79        echo $ph ['addr_street'] . "<br>\n";
80}
81if ($ph ['addr_city'] != '')
82        echo $ph ['addr_city'] . "<br>\n";
83if ($ph ['addr_postcode'] != '')
84        echo $ph ['addr_postcode'] . "<br>\n";
85
86if ($ph ['phone'] != '')
87        echo "<p>" . $ph ['phone'] . "</p>\n";
88if ($ph ['hours'] != '') {
89        $hours = str_replace (array ("mo", "tu", "we", "th", "fr", "sa", "su", ";"), array ("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su", "<br>"), $ph ['hours']);
90        echo "<p>Opening Hours:<br>$hours</p>\n";
91}
92if ($ph ['description'] != '')
93        echo "<p>" . $ph ['description'] . "</p>\n";
94if ($ph ['url'] != '') {
95        echo "<p><a href = '";
96        if (substr ($ph ['url'], 0, 7) != 'http://')
97                echo "http://";
98        echo $ph ['url'] . "'>Website</a></p>\n";
99}
100
101if ($waynode == 'node') {
102        echo "<p class = 'small'>Edit <a href = 'edit_hours.php?id=$id&amp;dist=$dist&amp;name=" .
103                urlencode ($displayname) . "&amp;waynode=$waynode'>opening hours</a> / ";
104        echo "<a href = 'edit_addr.php?id=$id&amp;dist=$dist&amp;name=" .
105                urlencode ($displayname) . "&amp;waynode=$waynode'>address</a> / ";
106        echo "<a href = 'edit.php?id=$id&amp;dist=$dist&amp;name=" .
107                urlencode ($displayname) . "&amp;waynode=$waynode'>other details</a></p>\n";
108}
109
110echo "<p><a href = '" . $_COOKIE ["ResultsPage"] . "'>Back to results</a><br><a href = 'index.php'>New search</a></p>\n";
111require ("inc_foot.php");
112?>
Note: See TracBrowser for help on using the repository browser.