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

Last change on this file since 20095 was 19962, checked in by Daniela Dorner, 5 years ago
added information on who is also in magic
File size: 13.9 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, alsomagic ";
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, alsomagic ";
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 $result = mysql_query($querycurrent);
165 $num_rows = mysql_num_rows($result);
166 echo "<h3>Current Author List: ".$num_rows." authors</h3>\n";
167 echo "<table border='1'>\n";
168 echo "<thead><tr><th>*</th><th>First Middle Lastname</th><th>Institute (#)</th><th>also at</th><th>also MAGIC</th></tr></thead>\n";
169 echo "<tbody>\n";
170 $counter=0;
171 $letter=a;
172 $institutes = [];
173 $instnames = [];
174 $instaddresses = [];
175 $alsos = [];
176 while ($row = mysql_fetch_row($result))
177 {
178 echo "<tr>";
179 if ($_GET["corresponding".$row[0]]=="yes")
180 echo "<td><input type='checkbox' name='corresponding".$row[0]."' value='yes' checked='checked'></td>";
181 else
182 echo "<td><input type='checkbox' name='corresponding".$row[0]."' value='yes'></td>";
183 echo "<td title='".$row[0]."'>".$row[1]." ".$row[2]." ".$row[3]."</td>";
184 if (!in_array($row[4],$institutes))
185 {
186 $counter++;
187 $institutes[$counter]=$row[4];
188 $instnames[$counter]=$row[6];
189 $instaddresses[$counter]=$row[7];
190 }
191 echo "<td>".mb_convert_encoding($row[4], 'utf-8', 'iso-8859-1')." (".array_search($row[4], $institutes).")</td>";
192 if ($row[5])
193 {
194 if (!in_array($row[5], $alsos))
195 {
196 $alsos[$letter]=$row[5];
197 $letter++;
198 }
199 echo "<td>".$row[5]." (".array_search($row[5], $alsos).") </td>";
200 }
201 else
202 echo "<td></td>";
203 if ($row[8])
204 echo "<td>y</td></tr>";
205 else
206 echo "<td></td></tr>";
207 }
208 //print_r($institutes);
209 //print_r($alsos);
210 echo "</tbody>\n";
211 echo "</table>\n<br>\n";
212 mysql_free_result($result);
213
214 echo "<h3>Institute List:</h3>\n";
215 echo "<table border='1'>\n";
216 echo "<thead><tr><th>#</th><th>Institute</th><th>Institute Adresse</th></tr></thead>\n";
217 echo "<tbody>\n";
218 for ($i = 1; $i <= $counter; $i++)
219 {
220 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>";
221 }
222 echo "<tr><td></td><td></td><td></td></tr>";
223 foreach ($alsos as $num => $name)
224 {
225 echo "<tr><td>".$num."</td><td>".mb_convert_encoding($name, 'utf-8', 'iso-8859-1')."</td><td></td></tr>";
226 }
227 echo "</tbody>\n";
228 echo "</table>\n<br>\n";
229
230 echo "<br>\n<br>\n";
231 echo "<h3>Full list:</h3>\n";
232 echo "<table border='1'>\n";
233 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";
234 $result = mysql_query($queryall);
235 echo "<tbody>\n";
236 while ($row = mysql_fetch_row($result))
237 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>";
238 echo "</tbody>\n";
239 echo "</table>\n<br>\n";
240 mysql_free_result($result);
241
242
243 $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) ";
244 $queryassoc.="WHERE not isnull(associatedstop) ORDER BY associatedstart";
245 //$queryassoc.="WHERE associatedstart <= '".$date."' AND associatedstop >= '".$date."' ";
246 //echo $queryassoc;
247 $result = mysql_query($queryassoc);
248 //associated members
249 echo "<h3>Associated Members:</h3>\n";
250 echo "<table border='1'>\n";
251 echo "<tbody>\n";
252 echo "<thead><tr><th>First Middle Lastname</th><th>associated since</th><th>associated until</th><th>Host Institute (#)</th></tr></thead>\n";
253 while ($row = mysql_fetch_row($result))
254 {
255 echo "<tr>";
256 echo "<td>".$row[1]." ".$row[2]." ".$row[3]."</td>";
257 echo "<td>".$row[4]."</td>";
258 echo "<td>".$row[5]."</td>";
259 echo "<td>".mb_convert_encoding($row[6], 'utf-8', 'iso-8859-1')." (".array_search($row[6], $institutes).")</td>";
260 }
261
262 echo "</tbody>\n";
263 echo "</table>\n<br>\n";
264 mysql_free_result($result);
265
266 echo "<form name='formular' action='memberlist.php' METHOD='GET'>\n";
267 echo "<h3>Author List:</h3>\n";
268 echo "Format: <br>\n";
269 if ($_GET["listformat"]=="short")
270 echo "<input type=radio name='listformat' value='short' checked='checked'> short &nbsp;";
271 else
272 echo "<input type=radio name='listformat' value='short'> short &nbsp;";
273 if ($_GET["listformat"]=="long")
274 echo "<input type=radio name='listformat' value='long' checked='checked'> long <br>";
275 else
276 echo "<input type=radio name='listformat' value='long'> long <br>";
277 if ($_GET["textformat"]=="latex")
278 echo "<input type=radio name='textformat' value='latex' checked='checked'> latex &nbsp;";
279 else
280 echo "<input type=radio name='textformat' value='latex'> latex &nbsp;";
281 if ($_GET["textformat"]=="html")
282 echo "<input type=radio name='textformat' value='html' checked='checked'> html ";
283 else
284 echo "<input type=radio name='textformat' value='html'> html ";
285 if ($_GET["textformat"]=="text")
286 echo "<input type=radio name='textformat' value='text' checked='checked'> text <br>";
287 else
288 echo "<input type=radio name='textformat' value='text'> text <br>";
289 if ($_GET["magic"]=="on")
290 echo "<input type=checkbox name='magic' checked> show magic <br>";
291 else
292 echo "<input type=checkbox name='magic'> show magic <br>";
293 echo "<br><input type='submit' value='Get List'>\n";
294 echo "</form>\n";
295
296 $counter=0;
297 $letter=a;
298 $institutes = [];
299 $instnames = [];
300 $instaddresses = [];
301 $alsos = [];
302 $result = mysql_query($querylist);
303 while ($row = mysql_fetch_row($result))
304 {
305 if (!in_array($row[1],$institutes))
306 {
307 $counter++;
308 $institutes[$counter]=$row[1];
309 $instnames[$counter]=$row[3];
310 $instaddresses[$counter]=$row[4];
311 }
312 if ($corresponding=="" || $textformat!="latex")
313 echo $row[0].GetSup($textformat, array_search($row[1], $institutes));
314 else
315 echo " \speaker{".$row[0]."} ".GetSup($textformat, array_search($row[1], $institutes));
316 if ($row[2])
317 {
318 if (!in_array($row[2], $alsos))
319 {
320 $alsos[$letter]=$row[2];
321 $letter++;
322 }
323 }
324 if ($row[2])
325 echo GetSup($textformat, array_search($row[2], $alsos));
326 if ($_GET["magic"]=="on" && $row[5])
327 echo GetSup($textformat, "*");
328 echo GetEndl($textformat, ",");
329 }
330 mysql_free_result($result);
331 if ($querylist2)
332 {
333 $result = mysql_query($querylist2);
334 while ($row = mysql_fetch_row($result))
335 {
336 if (!in_array($row[1],$institutes))
337 {
338 $counter++;
339 $institutes[$counter]=$row[1];
340 $instnames[$counter]=$row[3];
341 $instaddresses[$counter]=$row[4];
342 }
343 echo " ".$row[0]." ".GetSup($textformat, array_search($row[1], $institutes));
344 if ($row[2])
345 {
346 if (!in_array($row[2], $alsos))
347 {
348 $alsos[$letter]=$row[2];
349 $letter++;
350 }
351 }
352 if ($row[2])
353 echo GetSup($textformat, array_search($row[2], $alsos));
354 if ($row[5])
355 echo GetSup($textformat, "*");
356 echo GetEndl($textformat, ",");
357 }
358 mysql_free_result($result);
359 }
360 for ($i = 1; $i <= $counter; $i++)
361 echo GetSup($textformat, $i)." ".GetBla($textformat, $instnames[$i]).", ".
362 GetBla($textformat, $instaddresses[$i]).GetEndl($textformat, "");
363 foreach ($alsos as $num => $name)
364 echo GetSup($textformat, $num)." also at ".GetBla($textformat, $name).GetEndl($textformat, "");
365 if ($_GET["magic"]=="on")
366 echo GetSup($textformat, "*")." also in MAGIC ";
367
368
369
370 mysql_close($db_id);
371
372 echo "</form>\n";
373 echo "</body>\n";
374 echo "</html>\n";
375?>
Note: See TracBrowser for help on using the repository browser.