source: trunk/www/dch/memberlist.php@ 19598

Last change on this file since 19598 was 19098, checked in by Daniela Dorner, 6 years ago
added associated members
File size: 13.3 KB
Line 
1<?php
2
3function GetSup($style, $sup)
4{
5 switch($style)
6 {
7 case "html":
8 return " &lt;sup&gt;".$sup."&lt;/sup&gt;";
9 break;
10 case "text":
11 return " <sup>".$sup."</sup>";
12 break;
13 case "latex":
14 return " $^".$sup."$";
15 break;
16 default:
17 break;
18 }
19
20}
21
22function GetBla($style, $text)
23{
24 switch($style)
25 {
26 case "html":
27 return str_replace("'", "\'", str_replace("ä", '&amp;auml;', str_replace("ü", '&amp;uuml;', mb_convert_encoding($text, 'utf-8', 'iso-8859-1'))));
28 break;
29 case "text":
30 return str_replace("'", "\'", str_replace("ä", '&auml;', str_replace("ü", '&uuml;', mb_convert_encoding($text, 'utf-8', 'iso-8859-1'))));
31 break;
32 case "latex":
33 return str_replace("'", "\'", str_replace("ä", '{\"a}', str_replace("ü", '{\"u}', mb_convert_encoding($text, 'utf-8', 'iso-8859-1'))));
34 break;
35 default:
36 break;
37 }
38}
39
40function GetEndl($style, $comma)
41{
42 switch($style)
43 {
44 case "latex":
45 return $comma." &bsol;&bsol; <br>\n";
46 break;
47 case "html":
48 return $comma." &lt;br&gt; <br>\n";
49 break;
50 case "text":
51 return $comma." \n";
52 break;
53 default:
54 return $comma." <br>\n";
55 break;
56 }
57}
58 echo "<html>\n";
59 echo "<head>\n";
60 echo "<meta name='Author' content='Daniela Dorner' />\n";
61 echo "<meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
62 echo "<title>FACT Project</title>\n";
63 echo "<link rel='StyleSheet' type='text/css' href='../style.css' />\n";
64 echo "</head>\n";
65 echo "<body>\n";
66 //echo (file_get_contents("../shifteval/header.html"));
67
68 if (!empty($_GET["date"]))
69 $date=$_GET["date"];
70 else
71 $date=date("Ymd");
72
73 if (!empty($_GET["listformat"]))
74 $listformat=$_GET["listformat"];
75 else
76 $listformat="long";
77
78 if (!empty($_GET["textformat"]))
79 $textformat=$_GET["textformat"];
80 else
81 $textformat="latex";
82
83 $starttimestamp = new DateTime($startdate);
84 date_add($starttimestamp, date_interval_create_from_date_string("12 hours"));
85 $stoptimestamp = new DateTime($stopdate);
86 date_add($stoptimestamp, date_interval_create_from_date_string("12 hours"));
87
88 echo "<form action='memberlist.php' METHOD='GET'>\n";
89 echo "<b>FACT Collaboration</b> status of date ";
90 printf("<input name='date' type='text' size='10' maxlength='10' value='%s'>\n", $date);
91 echo "<input type='submit' value='Show'> \n";
92
93 include ("db.php");
94 $db_id = mysql_connect($host, $user, $pw);
95
96 //without institute:
97 //select username, Date(Min(start)) as 'from', if(Max(stop)='2020-12-31
98 //23:59:59', 'unlimited', Date(Max(stop))) as 'until',
99 //Date(Adddate(Min(start), interval 6 MONTH)) as 'author since',
100 //if(Max(stop)='2020-12-31 23:59:59', 'unlimited',
101 //Date(Adddate(Max(stop), interval 1 year))) as 'author until' from
102 //members where not isnull(start) and not isnull(stop) group by username;
103
104 $selectcurrent="SELECT userid, firstname, middlename, lastname, inst.institutename, also.institutefullname, inst.institutefullname, inst.instituteadresse ";
105 $selectall="SELECT username, Date(start) AS 'from', if(stop='2020-12-31 23:59:59', 'unlimited', Date(stop)) AS 'until',";
106 $selectall.=" DATE(ADDDATE(start, INTERVAL 6 MONTH)) AS 'author since', ";
107 $selectall.=" IF(stop='2020-12-31 23:59:59', 'unlimited', DATE(ADDDATE(stop, INTERVAL 1 YEAR))) AS 'author until', ";
108 $selectall.=" inst.institutename, MID(username, LOCATE(' ', username)+1) AS surname, ";
109 $selectall.=" MID(username, 1, LOCATE(' ', username)) AS firstname, ";
110 $selectall.=" firstname, middlename, lastname, also.institutefullname, inst.institutefullname, inst.instituteadresse ";
111 $selectlist="SELECT ";
112 if ($textformat=="latex")
113 $sep="~";
114 else
115 $sep=" ";
116 switch ($listformat)
117 {
118 case "long":
119 $selectlist.="CONCAT(firstname, ' ', if (not isnull(middlename), middlename, ''), ' ', lastname), ";
120 break;
121 case "short":
122 $selectlist.="CONCAT(LEFT(firstname, 1), '.', if (not isnull(middlename), CONCAT(LEFT(middlename, 1), '.".$sep."'), '".$sep."'), lastname), ";
123 break;
124 }
125 $selectlist.="inst.institutename, also.institutefullname, inst.institutefullname, inst.instituteadresse ";
126 $from=" FROM memberlist.members ";
127 $join=" LEFT JOIN memberlist.institutes inst USING(instituteid) ";
128 $join.=" LEFT JOIN memberlist.institutes also ON also.instituteid=alsoat ";
129 $where.=" WHERE NOT start='1970-01-01 00:00:00' AND NOT isnull(stop) ";
130
131 $corresponding="";
132 foreach ($_GET as $key => $name)
133 {
134 if (strpos($key, 'corresponding') !== false)
135 {
136 if ($corresponding=="")
137 $corresponding.=str_replace('corresponding', '', $key);
138 else
139 $corresponding.=", ".str_replace('corresponding', '', $key);
140 }
141 }
142
143
144 $current=" AND ADDDATE(start, INTERVAL 6 MONTH) <= '".$date."' AND ADDDATE(stop, INTERVAL 1 YEAR) >= '".$date."' ";
145 $order=" ORDER BY lastname";
146 $querycurrent=$selectcurrent.$from.$join.$where.$current;
147 $querycurrent=$querycurrent.$order;
148 $queryall=$selectall.$from.$join.$where.$order.", start";
149 if ($corresponding=="")
150 {
151 $querylist=$selectlist.$from.$join.$where.$current.$order;
152 }
153 else
154 {
155 $querylist=$selectlist.$from.$join.$where." AND userid IN (".$corresponding.") ".$current.$order;
156 $querylist2=$selectlist.$from.$join.$where." AND userid NOT IN (".$corresponding.") ".$current.$order;
157 }
158
159 echo "<br>\n<br>\n";
160// echo $querycurrent."<br>\n<br>\n";
161// echo $queryall."<br>\n<br>\n";
162// echo $querylist."<br>\n<br>\n";
163 echo $_GET["corresponding"];
164 echo "<h3>Current Author List:</h3>\n";
165 echo "<table border='1'>\n";
166 echo "<thead><tr><th>*</th><th>First Middle Lastname</th><th>Institute (#)</th><th>also at</th></tr></thead>\n";
167 echo "<tbody>\n";
168 $result = mysql_query($querycurrent);
169 $counter=0;
170 $letter=a;
171 $institutes = [];
172 $instnames = [];
173 $instaddresses = [];
174 $alsos = [];
175 while ($row = mysql_fetch_row($result))
176 {
177 echo "<tr>";
178 if ($_GET["corresponding".$row[0]]=="yes")
179 echo "<td><input type='checkbox' name='corresponding".$row[0]."' value='yes' checked='checked'></td>";
180 else
181 echo "<td><input type='checkbox' name='corresponding".$row[0]."' value='yes'></td>";
182 echo "<td title='".$row[0]."'>".$row[1]." ".$row[2]." ".$row[3]."</td>";
183 if (!in_array($row[4],$institutes))
184 {
185 $counter++;
186 $institutes[$counter]=$row[4];
187 $instnames[$counter]=$row[6];
188 $instaddresses[$counter]=$row[7];
189 }
190 echo "<td>".mb_convert_encoding($row[4], 'utf-8', 'iso-8859-1')." (".array_search($row[4], $institutes).")</td>";
191 if ($row[5])
192 {
193 if (!in_array($row[5], $alsos))
194 {
195 $alsos[$letter]=$row[5];
196 $letter++;
197 }
198 echo "<td>".$row[5]." (".array_search($row[5], $alsos).") </td></tr>";
199 }
200 else
201 echo "<td></td></tr>";
202 }
203 //print_r($institutes);
204 //print_r($alsos);
205 echo "</tbody>\n";
206 echo "</table>\n<br>\n";
207 mysql_free_result($result);
208
209 echo "<h3>Institute List:</h3>\n";
210 echo "<table border='1'>\n";
211 echo "<thead><tr><th>#</th><th>Institute</th><th>Institute Adresse</th></tr></thead>\n";
212 echo "<tbody>\n";
213 for ($i = 1; $i <= $counter; $i++)
214 {
215 echo "<tr><td>".$i."</td><td>".mb_convert_encoding($instnames[$i], 'utf-8', 'iso-8859-1')."</td><td>".mb_convert_encoding($instaddresses[$i], 'utf-8', 'iso-8859-1')."</td></tr>";
216 }
217 echo "<tr><td></td><td></td><td></td></tr>";
218 foreach ($alsos as $num => $name)
219 {
220 echo "<tr><td>".$num."</td><td>".mb_convert_encoding($name, 'utf-8', 'iso-8859-1')."</td><td></td></tr>";
221 }
222 echo "</tbody>\n";
223 echo "</table>\n<br>\n";
224
225 echo "<br>\n<br>\n";
226 echo "<h3>Full list:</h3>\n";
227 echo "<table border='1'>\n";
228 echo "<thead><tr><th>Name</th><th>Institute</th><th>Member since</th><th>Member until</th><th>Author since</th><th>Author until</th></tr></thead>\n";
229 $result = mysql_query($queryall);
230 echo "<tbody>\n";
231 while ($row = mysql_fetch_row($result))
232 echo "<tr><td>".$row[0]."</td><td>".$row[5]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[4]."</td></tr>";
233 echo "</tbody>\n";
234 echo "</table>\n<br>\n";
235 mysql_free_result($result);
236
237
238 $queryassoc="SELECT username, firstname, middlename, lastname, Date(associatedstart), if(associatedstop='2020-12-31 23:59:59', 'unlimited', Date(associatedstop)), inst.institutename FROM memberlist.members LEFT JOIN memberlist.institutes inst USING(instituteid) ";
239 $queryassoc.="WHERE not isnull(associatedstop) ORDER BY associatedstart";
240 //$queryassoc.="WHERE associatedstart <= '".$date."' AND associatedstop >= '".$date."' ";
241 //echo $queryassoc;
242 $result = mysql_query($queryassoc);
243 //associated members
244 echo "<h3>Associated Members:</h3>\n";
245 echo "<table border='1'>\n";
246 echo "<tbody>\n";
247 echo "<thead><tr><th>First Middle Lastname</th><th>associated since</th><th>associated until</th><th>Host Institute (#)</th></tr></thead>\n";
248 while ($row = mysql_fetch_row($result))
249 {
250 echo "<tr>";
251 echo "<td>".$row[1]." ".$row[2]." ".$row[3]."</td>";
252 echo "<td>".$row[4]."</td>";
253 echo "<td>".$row[5]."</td>";
254 echo "<td>".mb_convert_encoding($row[6], 'utf-8', 'iso-8859-1')." (".array_search($row[6], $institutes).")</td>";
255 }
256
257 echo "</tbody>\n";
258 echo "</table>\n<br>\n";
259 mysql_free_result($result);
260
261 echo "<form name='formular' action='memberlist.php' METHOD='GET'>\n";
262 echo "<h3>Author List:</h3>\n";
263 echo "Format: <br>\n";
264 if ($_GET["listformat"]=="short")
265 echo "<input type=radio name='listformat' value='short' checked='checked'> short &nbsp;";
266 else
267 echo "<input type=radio name='listformat' value='short'> short &nbsp;";
268 if ($_GET["listformat"]=="long")
269 echo "<input type=radio name='listformat' value='long' checked='checked'> long <br>";
270 else
271 echo "<input type=radio name='listformat' value='long'> long <br>";
272 if ($_GET["textformat"]=="latex")
273 echo "<input type=radio name='textformat' value='latex' checked='checked'> latex &nbsp;";
274 else
275 echo "<input type=radio name='textformat' value='latex'> latex &nbsp;";
276 if ($_GET["textformat"]=="html")
277 echo "<input type=radio name='textformat' value='html' checked='checked'> html ";
278 else
279 echo "<input type=radio name='textformat' value='html'> html ";
280 if ($_GET["textformat"]=="text")
281 echo "<input type=radio name='textformat' value='text' checked='checked'> text <br>";
282 else
283 echo "<input type=radio name='textformat' value='text'> text <br>";
284 echo "<br><input type='submit' value='Get List'>\n";
285 echo "</form>\n";
286
287 $counter=0;
288 $letter=a;
289 $institutes = [];
290 $instnames = [];
291 $instaddresses = [];
292 $alsos = [];
293 $result = mysql_query($querylist);
294 while ($row = mysql_fetch_row($result))
295 {
296 if (!in_array($row[1],$institutes))
297 {
298 $counter++;
299 $institutes[$counter]=$row[1];
300 $instnames[$counter]=$row[3];
301 $instaddresses[$counter]=$row[4];
302 }
303 if ($corresponding=="" || $textformat!="latex")
304 echo $row[0].GetSup($textformat, array_search($row[1], $institutes));
305 else
306 echo " \speaker{".$row[0]."} ".GetSup($textformat, array_search($row[1], $institutes));
307 if ($row[2])
308 {
309 if (!in_array($row[2], $alsos))
310 {
311 $alsos[$letter]=$row[2];
312 $letter++;
313 }
314 }
315 if ($row[2])
316 echo GetSup($textformat, array_search($row[2], $alsos));
317 echo GetEndl($textformat, ",");
318 }
319 mysql_free_result($result);
320 if ($querylist2)
321 {
322 $result = mysql_query($querylist2);
323 while ($row = mysql_fetch_row($result))
324 {
325 if (!in_array($row[1],$institutes))
326 {
327 $counter++;
328 $institutes[$counter]=$row[1];
329 $instnames[$counter]=$row[3];
330 $instaddresses[$counter]=$row[4];
331 }
332 echo " ".$row[0]." ".GetSup($textformat, array_search($row[1], $institutes));
333 if ($row[2])
334 {
335 if (!in_array($row[2], $alsos))
336 {
337 $alsos[$letter]=$row[2];
338 $letter++;
339 }
340 }
341 if ($row[2])
342 echo GetSup($textformat, array_search($row[2], $alsos));
343 echo GetEndl($textformat, ",");
344 }
345 mysql_free_result($result);
346 }
347 for ($i = 1; $i <= $counter; $i++)
348 echo GetSup($textformat, $i)." ".GetBla($textformat, $instnames[$i]).", ".
349 GetBla($textformat, $instaddresses[$i]).GetEndl($textformat, "");
350 foreach ($alsos as $num => $name)
351 echo GetSup($textformat, $num)." also at ".GetBla($textformat, $name).GetEndl($textformat, "");
352
353
354
355 mysql_close($db_id);
356
357 echo "</form>\n";
358 echo "</body>\n";
359 echo "</html>\n";
360?>
Note: See TracBrowser for help on using the repository browser.