1<?
2include('../Code/confHeader.inc');
3$_SESSION[Me] -> goIfInvalid("../index.php");
4$_SESSION[Me] -> goIfNotChair('../index.php');
5$Conf -> connect();
6
7function Check($var)
8{
9  if ($var) {
10    print "<img src=\"../images/CheckMark.gif\">";
11  } else {
12    print "&nbsp;";
13  }
14}
15
16function Num($var)
17{
18  if ($var) {
19    print $var;
20  } else {
21    print "&nbsp;";
22  }
23}
24
25function countPapers($array, $table, $where)
26{
27  global $Conf;
28  global ${$array};
29
30  $query = "SELECT $table.paperId, COUNT(*) "
31    . " FROM $table "
32    . $where
33    . " GROUP BY $table.paperId ";
34
35  $result=$Conf->qe($query);
36  if (DB::isError($result)) {
37    $Conf->errorMsg("Error in retrieving $table count " . $result->getMessage());
38  } else {
39    while ($row = $result->fetchRow()) {
40      $id=$row[0];
41      ${$array}[$id] = $row[1];
42    }
43  }
44}
45
46?>
47
48<html>
49
50<? $Conf->header("Assign Papers to Program Committee Members") ?>
51
52<body>
53<?
54//
55// Process actions from this form..
56//
57if (IsSet($_REQUEST[assignPapers])) {
58  if (!IsSet($_REQUEST[reviewer]) || $_REQUEST[reviewer]==-1) {
59    $Conf->errorMsg("You need to select a reviewer.");
60  } else {
61    if (IsSet($_REQUEST[Primary])) {
62      for($i=0; $i < sizeof($_REQUEST[Primary]); $i++) {
63	$paper=$_REQUEST[Primary][$i];
64	$result = $Conf->qe("SELECT reviewer FROM PrimaryReviewer "
65			    . " WHERE reviewer='$_REQUEST[reviewer]' AND  paperId='$paper'");
66	if (DB::isError($result) ||  $result->numRows() == 0) {
67
68	  $result=$Conf->qe("INSERT INTO PrimaryReviewer "
69			     . " SET reviewer='$_REQUEST[reviewer]', paperId='$paper'");
70
71	  if ( !DB::isError($result) ) {
72	    $Conf->infoMsg("Added primary reviewer for paper $paper");
73	    $Conf->log("Added primary reviewer $reviewer for paper $paper", $_SESSION[Me]);
74	  } else {
75	    $Conf->errorMsg("Error in adding primary reviewer for paper $paper: " . $result->getMessage());
76	  }
77	} else {
78	  $Conf->errorMsg("You tried to add a duplicate reviewer for paper # $paper");
79	}
80      }
81    }
82    if (IsSet($_REQUEST[Secondary])) {
83      for($i=0; $i < sizeof($_REQUEST[Secondary]); $i++) {
84	$paper=$_REQUEST[Secondary][$i];
85	$result = $Conf->qe("SELECT reviewer FROM SecondaryReviewer "
86			    . " WHERE reviewer='$_REQUEST[reviewer]' AND  paperId='$paper'");
87
88	if (DB::isError($result) ||  $result->numRows() == 0) {
89
90	  $result=$Conf->qe("INSERT INTO SecondaryReviewer "
91			     . " SET reviewer='$_REQUEST[reviewer]', paperId='$paper'");
92
93	  if ( !DB::isError($result) ) {
94	    $Conf->infoMsg("Added secondary reviewer for paper $paper");
95	    $Conf->log("Added primary reviewer $reviewer for paper $paper", $_SESSION[Me]);
96	  } else {
97	    $Conf->errorMsg("Error in adding secondary reviewer for paper $paper: " . $result->getMessage());
98	  }
99	} else {
100	  $Conf->errorMsg("You tried to add a duplicate reviewer for paper # $paper");
101	}
102      }
103    }
104  }
105}
106?>
107<h2> Understanding The Displayed Table </h2>
108<p>
109This paper shows you all the papers that have been entered into the database.
110   From left to right, for each paper, you are also shown the number of primary and secondary
111reviewers assigned to that paper, the number of reviews requested by PC members
112(not including PC reviews),
113the number of started and finished reviews (including PC members),
114				  whether the paper has been finalized (checkmark)
115				  or withdrawn (checkmark).
116Following this is the paper title and a list of each primary and secondary
117reviewer for the paper.
118
119</p>
120<p>
121   You can select one program committee member and then select one or more papers
122   to indicate that the PC member should be the primary (or secondary)
123   reviewer for that paper. Primary reviewers are required to review
124		       the paper themselves; secondary reviewers
125may delegate the paper or review it themselves.
126</p>
127<p> For each paper, we show who has been assigned to review that paper
128(if anyone), either as a primary or secondary reviewer.
129In this view of the data, you will see <b> ALL </b> reviewers and
130<b> ALL </b> papers, including PC papers.
131</p>
132
133<p> If you want to remove a reviewer from a paper, click
134on the link containing their name - this will remove that
135reviewer <b> without further confirmation </b>.
136</p>
137
138<?
139//
140// Make an array of all the valid paper indicies.
141//
142  $paperResult=$Conf->qe("SELECT Paper.paperId, Paper.title, "
143		    . " Paper.acknowledged, Paper.withdrawn, "
144		    . " PaperStorage.mimetype "
145		    . " FROM Paper, PaperStorage "
146		    . " WHERE Paper.paperId=PaperStorage.paperId "
147		    . " ORDER BY Paper.paperId"
148		    );
149  $numpaper= 0;
150  if (DB::isError($paperResult)) {
151    $Conf->errorMsg("Error in retrieving paper list " . $result->getMessage());
152  } else {
153    $numpapers = $paperResult -> numrows();
154  }
155  countPapers("allPrimary", "PrimaryReviewer", "");
156  countPapers("allSecondary", "SecondaryReviewer", "");
157  countPapers("allReviewRequest", "ReviewRequest", "");
158  countPapers("allStartedReviews", "PaperReview", "WHERE (PaperReview.finalized!=0)");
159  countPapers("allFinishedReviews", "PaperReview", "WHERE (PaperReview.finalized=0)");
160  //
161  // Determine the number of completed and started reviews for all papers
162  //
163  ?>
164
165  <p> Found <? echo $numpapers ?> papers. </p>
166<?
167if (IsSet($_REQUEST[newReviewer]) ) {
168  $_REQUEST[reviewer] = $_REQUEST[newReviewer];
169}
170
171?>
172
173<CENTER>
174<FORM METHOD="POST" ACTION="<?echo $PHP_SELF ?>" name="selectReviewer">
175  <SELECT name=newReviewer SINGLE onChange="document.selectReviewer.submit()">
176  <?
177  $query = "SELECT ContactInfo.contactId, ContactInfo.firstName, ContactInfo.lastName, ContactInfo.email "
178  . " FROM ContactInfo, PCMember WHERE "
179  . " (PCMember.contactId=ContactInfo.contactId) "
180  . " ORDER BY ContactInfo.lastName";
181$result = $Conf->qe($query);
182 print "<OPTION VALUE=\"-1\"> (Remember to select a committee member!)</OPTION>";
183 if (!DB::isError($result)) {
184   while($row=$result->fetchRow()) {
185     if ($_REQUEST[reviewer] == $row[0] ) {
186       print "<OPTION VALUE=\"$row[0]\" SELECTED> $row[1] $row[2] ($row[3]) </OPTION>";
187     } else {
188       print "<OPTION VALUE=\"$row[0]\"> $row[1] $row[2] ($row[3]) </OPTION>";
189     }
190   }
191 }
192?>
193</SELECT>
194</FORM>
195</CENTER>
196<br>
197
198
199<?php
200
201if(IsSet($_REQUEST[reviewer]) && $_REQUEST[reviewer] >= 0) {
202     $Conf->reviewerSummary($_REQUEST[reviewer], 1 , 1);
203  //
204  // Print out a quick jump index
205  //
206  print "<p> <b> Jump To: </b> ";
207  $result = $Conf->qe("SELECT paperId from Paper ORDER BY paperId");
208  $sep = "";
209  $i = 0;
210  while($row=$result->fetchRow()) {
211     $paperId = $row[0];
212     if ($i % 10 == 0) {
213       print "$sep <a href=\"#paper$paperId\"> Paper $paperId </a>\n";
214       $sep = " -- ";
215     }
216     $i++;
217   }
218   print "</p>";
219
220?>
221 <FORM METHOD="POST" ACTION="<?echo $PHP_SELF ?>">
222 <INPUT TYPE="hidden" name="reviewer" value="<?echo $_REQUEST[reviewer]?>">
223 <INPUT TYPE="SUBMIT" name="assignPapers" value="Assign this PC member to the indicated papers">
224
225     <table border="1" width="100%" cellpadding=0 cellspacing=0>
226     <thead>
227     <tr>
228     <th colspan=1 width=15% valign="center" align="center"> </th>
229     <th colspan=2 width=5 valign="center" align="center"?> PC </th>
230     <th colspan=3 width=80% valign="center" align="center"> Paper </th>
231     </tr>
232<?
233    $rownum = -1;
234    while ($row = $paperResult->fetchRow(DB_FETCHMODE_ASSOC)) {
235      $rownum++;
236      $paperId = $row['paperId'];
237      $title = $row['title'];
238
239      $primary=$allPrimary[$paperId];
240      $secondary=$allSecondary[$paperId];
241
242       if (($rownum % 10)==0) {
243?>
244     <tr>
245     <th> <a name="paper<?echo $paperId?>">#</a> </th>
246     <th> # 1st </th>
247     <th> # 2nd </th>
248     <th> F? </th>
249     <th> W? </th>
250     <th> Title </th>
251     </tr>
252<?
253       }
254?>
255       <tr>
256       <td>
257       <table>
258       <tr>
259       <td>
260       <b> <? echo $paperId ?> </b>
261       </td>
262       <td>
263       <INPUT TYPE=checkbox NAME=Primary[] VALUE='<?echo $paperId?>'> Add Primary? <br>
264       <INPUT TYPE=checkbox NAME=Secondary[] VALUE='<?echo $paperId ?>'> Add Secondary? <br>
265       </td>
266       </tr>
267       </table>
268       </td>
269
270       <td valign="center" align="center"> <? echo Num($allPrimary[$paperId]) ?> </td>
271       <td valign="center" align="center"> <? echo Num($allSecondary[$paperId]) ?> </td>
272       <td valign="center" align="center"> <? echo Check($allSubmitted[$paperId]) ?> </td>
273       <td valign="center" align="center"> <? echo Check($allWithdrawn[$paperId]) ?> </td>
274
275       <td> <a href="../Assistant/AssistantViewSinglePaper.php?paperId=<?echo $paperId?>" target=_blank>
276<? echo $title ?> </a>
277       <?php
278	  //
279	  // Pull topics
280	  //
281	  $result=$Conf->qe("SELECT topicName from TopicArea,PaperTopic "
282			    . " WHERE TopicArea.topicAreaId = PaperTopic.topicId "
283			    . " AND PaperTopic.paperId=$paperId ");
284       if (!DB::isError($result) && $result -> numRows() > 0) {
285	 print "<br> Topics: ";
286	 while($row = $result->fetchRow() ) {
287	   print " " . $row[0] . ",";
288	 }
289       }
290
291       ?>
292       <br>
293       <table border="1" cellpadding="0" cellspacing="0" width="100%">
294       <tr> <td width="35%"> Primary: </td> <td>
295       <?
296       //
297       // Pull out the primary reviewers
298       //
299       $result = $Conf->qe("SELECT ContactInfo.firstName, ContactInfo.lastName, ContactInfo.email, ContactInfo.contactId "
300			   . " FROM ContactInfo, PrimaryReviewer "
301			   . " WHERE ( PrimaryReviewer.paperId='$paperId' "
302			   . "         AND PrimaryReviewer.reviewer=ContactInfo.contactId)"
303			   );
304       if (!DB::isError($result)) {
305	 while($row = $result->fetchRow() ) {
306	   print "$row[0] $row[1] ($row[2]) ";
307	   print "<a href=\"ChairRemoveReviewer.php?who=$row[3]&paperId=$paperId&reviewType=Primary\" target=\"_blank\">";
308	   print " [Remove] </a><br>";
309	 }
310       } else {
311	 print "<p> Error: " . $result->getMessage() . " </p>";
312       }
313       ?>
314       </td> </tr>
315       <tr> <td width="35%"> Secondary: </td>
316       <td>
317       <?
318       //
319       // Pull out the secondary reviewers
320       //
321       $result = $Conf->qe("SELECT ContactInfo.firstName, ContactInfo.lastName, ContactInfo.email, ContactInfo.contactId "
322			   . " FROM ContactInfo, SecondaryReviewer "
323			   . " WHERE ( SecondaryReviewer.paperId='$paperId' "
324			   . "         AND SecondaryReviewer.reviewer=ContactInfo.contactId)");
325       if (!DB::isError($result)) {
326	 while($row = $result->fetchRow() ) {
327	   print "$row[0] $row[1] ($row[2]) ";
328	   print "<a href=\"ChairRemoveReviewer.php?who=$row[3]&paperId=$paperId&reviewType=Secondary\" target=\"_blank\">";
329	   print "[Remove]</a><br>";
330	 }
331       } else {
332	 print "<p> Error: " . $result->getMessage() . " </p>";
333       }
334
335?>
336       </td> </tr>
337
338	<tr>
339	   <td colspan=2> <b> <a href="../PC/PCAllAnonReviewsForPaper.php?paperId=<? echo $paperId ?>" >
340            Reviews for paper #<? echo $paperId ?> </a> </b>
341	   </td>
342	</tr>
343
344       </table>
345       </td> </tr>
346       <?
347     }
348 ?>
349</table>
350<INPUT TYPE="SUBMIT" name="assignPapers" value="Assign this PC member to the indicated papers">
351</form>
352    <?php } ?>
353
354</body>
355<? $Conf->footer() ?>
356</html>
357
358