-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.php
More file actions
153 lines (127 loc) · 4.99 KB
/
map.php
File metadata and controls
153 lines (127 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
die;
include_once "config.php";
$PAGE = "map";
$BODY_ATT = 'onload="initialize()" onunload="GUnload()"';
$HEADER = '<script src="http://maps.googleapis.com/maps/api/js?sensor=false"
type="text/javascript"></script>';
include_once "includes/header.php";
$days = optional_param("days",14,PARAM_INT);
$opts = array('days'=>$days,'limit'=>500);
$submitted = $API->getProtocolsSubmitted($opts);
$healthposts = $API->getHealthPoints();
$dayopts = Array(7,14,31);
?>
<h2>
<?php
echo getstring('map.title');
for($i=0; $i<count($dayopts);$i++){
if($days == $dayopts[$i]){
printf(" <span style='color:green'>%s</span> ",getstring("map.nodays",array($dayopts[$i])));
} else {
printf(" <a href='?days=%d'>%s</a> ",$dayopts[$i],getstring("map.nodays",array($dayopts[$i])));
}
if($i != count($dayopts)-1){
printf("|");
}
}
?>
</h2>
<script type="text/javascript">
var map;
function initialize() {
var myOptions = {
zoom: 9,
center: new google.maps.LatLng(13.5,39.49),
mapTypeId: google.maps.MapTypeId.HYBRID,
}
map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
loadMarkers();
}
function loadMarkers(){
<?php
// health posts
foreach ($healthposts as $hp){
if ($hp->locationlat != 0 && $hp->locationlng !=0){
?>
var marker<?php echo $hp->hpid; ?> = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $hp->locationlat.",".$hp->locationlng; ?>),
title:"<?php echo displayHealthPointName($hp->hpcode); ?>",
map: map,
icon: '<?php echo $CONFIG->homeAddress; ?>images/mapicons/hospital-building.png'
});
var infowindow<?php echo $hp->hpid; ?> = new google.maps.InfoWindow({
content: "<?php echo displayHealthPointName($hp->hpcode); ?>"
});
google.maps.event.addListener(marker<?php echo $hp->hpid; ?>, 'click', function() {
infowindow<?php echo $hp->hpid; ?>.open(map,marker<?php echo $hp->hpid; ?>);
});
<?php
}
}
// submitted protocols
foreach ($submitted->protocols as $s){
if ($s->Q_LOCATION == "healthpost" || $s->Q_LOCATION == "healthcentre" ){
$gpslat = $s->locationlat;
$gpslng = $s->locationlng;
} else {
$gpslat = $s->Q_GPSDATA_LAT;
$gpslng = $s->Q_GPSDATA_LNG;
}
if ($gpslat != "" && $gpslng != ""){
switch ($s->protocol){
case getString('protocol.registration'):
?>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $gpslat.",".$gpslng; ?>),
title:"<?php echo $s->patientname; ?>",
map: map,
icon: '<?php echo $CONFIG->homeAddress; ?>images/mapicons/protocol1.png'
});
<?php
break;
case getString('protocol.anc'):
?>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $gpslat.",".$gpslng; ?>),
title:"<?php echo $s->patientname; ?>",
map: map,
icon: '<?php echo $CONFIG->homeAddress; ?>images/mapicons/protocol2.png'
});
<?php
break;
case getString('protocol.anclabtest'):
?>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $gpslat.",".$gpslng; ?>),
title:"<?php echo $s->patientname; ?>",
map: map,
icon: '<?php echo $CONFIG->homeAddress; ?>images/mapicons/protocol5.png'
});
<?php
break;
default:
?>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $gpslat.",".$gpslng; ?>),
title:"<?php echo $s->patientname; ?>",
map: map
});
<?php
}
}
}
?>
}
</script>
<div id="map_canvas" style="float:left; height: 500px; width:700px" class="summarygraph"><?php echo getstring('warning.map.unavailable');?></div>
<div id="legend" style="float:left, width:100px">
Legend:<br/>
<img align="center" src="<?php echo $CONFIG->homeAddress; ?>images/mapicons/hospital-building.png"/> <?php echo getString('map.healthpost');?><br/>
<img align="center" src="<?php echo $CONFIG->homeAddress; ?>images/mapicons/protocol1.png"/> <?php echo getString('protocol.registration');?><br/>
<img align="center" src="<?php echo $CONFIG->homeAddress; ?>images/mapicons/protocol2.png"/> <?php echo getString('protocol.anc');?><br/>
<img align="center" src="<?php echo $CONFIG->homeAddress; ?>images/mapicons/protocol5.png"/> <?php echo getString('protocol.anclabtest');?><br/>
</div>
<?php
include_once "includes/footer.php";
?>