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

Last change on this file since 18893 was 18893, checked in by Daniela Dorner, 7 years ago
implemented printing of authorlist in differen formats
File size: 12.1 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
210 echo "<h3>Institute List:</h3>\n";
211 echo "<table border='1'>\n";
212 echo "<thead><tr><th>#</th><th>Institute</th><th>Institute Adresse</th></tr></thead>\n";
213 echo "<tbody>\n";
214 for ($i = 1; $i <= $counter; $i++)
215 {
216 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>";
217 }
218 echo "<tr><td></td><td></td><td></td></tr>";
219 foreach ($alsos as $num => $name)
220 {
221 echo "<tr><td>".$num."</td><td>".mb_convert_encoding($name, 'utf-8', 'iso-8859-1')."</td><td></td></tr>";
222 }
223 echo "</tbody>\n";
224 echo "</table>\n<br>\n";
225
226 echo "<br>\n<br>\n";
227 echo "<h3>Full list:</h3>\n";
228 echo "<table border='1'>\n";
229 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";
230 $result = mysql_query($queryall);
231 echo "<tbody>\n";
232 while ($row = mysql_fetch_row($result))
233 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>";
234 echo "</tbody>\n";
235 echo "</table>\n<br>\n";
236 mysql_free_result($result);
237
238
239 echo "<form name='formular' action='memberlist.php' METHOD='GET'>\n";
240 echo "<h3>Author List:</h3>\n";
241 echo "Format: <br>\n";
242 if ($_GET["listformat"]=="short")
243 echo "<input type=radio name='listformat' value='short' checked='checked'> short &nbsp;";
244 else
245 echo "<input type=radio name='listformat' value='short'> short &nbsp;";
246 if ($_GET["listformat"]=="long")
247 echo "<input type=radio name='listformat' value='long' checked='checked'> long <br>";
248 else
249 echo "<input type=radio name='listformat' value='long'> long <br>";
250 if ($_GET["textformat"]=="latex")
251 echo "<input type=radio name='textformat' value='latex' checked='checked'> latex &nbsp;";
252 else
253 echo "<input type=radio name='textformat' value='latex'> latex &nbsp;";
254 if ($_GET["textformat"]=="html")
255 echo "<input type=radio name='textformat' value='html' checked='checked'> html ";
256 else
257 echo "<input type=radio name='textformat' value='html'> html ";
258 if ($_GET["textformat"]=="text")
259 echo "<input type=radio name='textformat' value='text' checked='checked'> text <br>";
260 else
261 echo "<input type=radio name='textformat' value='text'> text <br>";
262 echo "<br><input type='submit' value='Get List'>\n";
263 echo "</form>\n";
264
265 $counter=0;
266 $letter=a;
267 $institutes = [];
268 $instnames = [];
269 $instaddresses = [];
270 $alsos = [];
271 $result = mysql_query($querylist);
272 while ($row = mysql_fetch_row($result))
273 {
274 if (!in_array($row[1],$institutes))
275 {
276 $counter++;
277 $institutes[$counter]=$row[1];
278 $instnames[$counter]=$row[3];
279 $instaddresses[$counter]=$row[4];
280 }
281 if ($corresponding=="" || $textformat!="latex")
282 echo $row[0].GetSup($textformat, array_search($row[1], $institutes));
283 else
284 echo " \speaker{".$row[0]."} ".GetSup($textformat, array_search($row[1], $institutes));
285 if ($row[2])
286 {
287 if (!in_array($row[2], $alsos))
288 {
289 $alsos[$letter]=$row[2];
290 $letter++;
291 }
292 }
293 if ($row[2])
294 echo GetSup($textformat, array_search($row[2], $alsos));
295 echo GetEndl($textformat, ",");
296 }
297 mysql_free_result($result);
298 if ($querylist2)
299 {
300 $result = mysql_query($querylist2);
301 while ($row = mysql_fetch_row($result))
302 {
303 if (!in_array($row[1],$institutes))
304 {
305 $counter++;
306 $institutes[$counter]=$row[1];
307 $instnames[$counter]=$row[3];
308 $instaddresses[$counter]=$row[4];
309 }
310 echo " ".$row[0]." ".GetSup($textformat, array_search($row[1], $institutes));
311 if ($row[2])
312 {
313 if (!in_array($row[2], $alsos))
314 {
315 $alsos[$letter]=$row[2];
316 $letter++;
317 }
318 }
319 if ($row[2])
320 echo GetSup($textformat, array_search($row[2], $alsos));
321 echo GetEndl($textformat, ",");
322 }
323 mysql_free_result($result);
324 }
325 for ($i = 1; $i <= $counter; $i++)
326 echo GetSup($textformat, $i)." ".GetBla($textformat, $instnames[$i]).", ".
327 GetBla($textformat, $instaddresses[$i]).GetEndl($textformat, "");
328 foreach ($alsos as $num => $name)
329 echo GetSup($textformat, $num)." also at ".GetBla($textformat, $name).GetEndl($textformat, "");
330
331
332
333 mysql_close($db_id);
334
335 echo "</form>\n";
336 echo "</body>\n";
337 echo "</html>\n";
338?>
Note: See TracBrowser for help on using the repository browser.