Copyright (C) 2005 James Grant This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?> number; $q=mysql_query("SELECT COUNT(*) AS count FROM winners WHERE awards_prizes_id='".$_POST['prize_id']."'"); echo mysql_Error(); $r=mysql_fetch_object($q); $count=$r->count; if($count<$number) { mysql_query("INSERT INTO winners (awards_prizes_id,projects_id,year) VALUES ('".$_POST['prize_id']."','".$_POST['winner']."','".$config['FAIRYEAR']."')"); $notice = 'added'; } else { $notice = 'nomore'; $notice_data = array($number); } } $action="edit"; } if($action=="delete") { if($_GET['prize_id'] && $_GET['project_id']) { mysql_query("DELETE FROM winners WHERE awards_prizes_id='".$_GET['prize_id']."' AND projects_id='".$_GET['project_id']."'"); $notice = 'removed'; } $action="edit"; } if($action=="edit" && $edit) { send_header("Choose Projects", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Enter Winning Projects' => 'admin/winners.php'), "enter_winning_projects" ); switch($notice) { case 'removed': echo happy(i18n("Winning project removed")); break; case 'nomore': echo error(i18n("This prize cannot accept any more winners. Maximum: %1",$notice_data)); break; case 'added': echo happy(i18n("Winning project added")); break; } $q=mysql_query("SELECT award_awards.id, award_awards.name, award_awards.criteria, award_awards.order AS awards_order, award_types.type FROM award_awards, award_types WHERE award_awards.year='".$config['FAIRYEAR']."' AND award_awards.award_types_id=award_types.id AND award_awards.id='$edit' "); echo mysql_error(); if($r=mysql_fetch_object($q)) { echo "
"; //get the projets that are eligible for the award, given the award ID ($r->id) if($r->type=="Special" && !$_GET['eligible']) { $projects=getProjectsNominatedForSpecialAward($r->id); } else $projects=getProjectsEligibleForAward($r->id); $winq=mysql_query("SELECT winners.projects_id FROM winners,award_prizes,award_awards WHERE award_awards.id='$r->id' AND award_prizes.award_awards_id=award_awards.id AND winners.awards_prizes_id=award_prizes.id ORDER BY projects_id "); echo mysql_error(); $alreadywinners=array(); while($winr=mysql_fetch_object($winq)) { $alreadywinners[]=$winr->projects_id; } //print_r($alreadywinners); /* echo "projects:"; echo nl2br(print_r($projects,true)); echo "
"; */ // echo ""; echo "{$r->type} - {$r->name}
"; echo "{$r->criteria}
"; $pq=mysql_query("SELECT award_prizes.prize, award_prizes.number, award_prizes.id, award_prizes.cash, award_prizes.scholarship, winners.projects_id, projects.projectnumber, projects.title FROM award_prizes LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id LEFT JOIN projects ON projects.id=winners.projects_id WHERE award_awards_id='$r->id' AND award_prizes.year='".$config['FAIRYEAR']."' ORDER BY `order`"); echo mysql_error(); $prevprizeid=-1; while($pr=mysql_fetch_object($pq)) { if($prevprizeid!=$pr->id) { echo "
"; echo " "; echo " "; echo ""; echo "$pr->prize"; if($pr->cash || $pr->scholarship) { echo " ("; if($pr->cash && $pr->scholarship) echo "\$$pr->cash cash / \$$pr->scholarship scholarship"; else if($pr->cash) echo "\$$pr->cash cash"; else if($pr->scholarship) echo "\$$pr->scholarship scholarship"; echo ")"; } $cq=mysql_query("SELECT COUNT(*) AS count FROM winners WHERE awards_prizes_id='$pr->id'"); echo mysql_Error(); $cr=mysql_fetch_object($cq); $count=$cr->count; if($count<$pr->number) $color="red"; else $color="green"; echo " [".$count."/".$pr->number."]"; echo ""; $prevprizeid=$pr->id; if($count<$pr->number) { echo "
"; echo ""; echo "id\">"; echo ""; echo ""; echo ""; echo "
"; echo "Show All Eligible"; echo "
"; } else echo "
"; } if($pr->projectnumber) { echo " "; echo " "; echo " "; echo " "; echo "id&project_id=$pr->projects_id\">"; echo " ($pr->projectnumber) $pr->title"; echo "
"; } } } } else { send_header("Enter Winning Projects", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php'), "enter_winning_projects" ); switch($notice) { case 'removed': echo happy(i18n("Winning project removed")); break; case 'nomore': echo error(i18n("This prize cannot accept any more winners. Maximum: %1",$notice_data)); break; case 'added': echo happy(i18n("Winning project added")); break; } $q=mysql_query("SELECT award_awards.id, award_awards.name, award_awards.order AS awards_order, award_types.type, sponsors.organization FROM award_awards, award_types, sponsors WHERE award_awards.year='".$config['FAIRYEAR']."' AND award_awards.award_types_id=award_types.id AND award_types.year='".$config['FAIRYEAR']."' AND award_awards.sponsors_id=sponsors.id ORDER BY awards_order"); echo mysql_error(); if(mysql_num_rows($q)) { echo "
"; echo i18n("Choose an award to assign winners"); echo "
"; echo "
"; while($r=mysql_fetch_object($q)) { echo "id\">"; // echo ""; echo " $r->type - \n"; echo " $r->name \n"; echo ""; echo " (".$r->organization.")
"; $pq=mysql_query("SELECT award_prizes.prize, award_prizes.number, award_prizes.id, award_prizes.cash, award_prizes.scholarship, winners.projects_id, projects.projectnumber, projects.title FROM award_prizes LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id LEFT JOIN projects ON projects.id=winners.projects_id WHERE award_awards_id='$r->id' AND award_prizes.year='".$config['FAIRYEAR']."' ORDER BY `order`"); echo mysql_error(); $prevprizeid=-1; while($pr=mysql_fetch_object($pq)) { if($prevprizeid!=$pr->id) { echo " "; echo " "; echo ""; echo "$pr->prize"; if($pr->cash || $pr->scholarship) { echo " ("; if($pr->cash && $pr->scholarship) echo "\$$pr->cash cash / \$$pr->scholarship scholarship"; else if($pr->cash) echo "\$$pr->cash cash"; else if($pr->scholarship) echo "\$$pr->scholarship scholarship"; echo ")"; } $cq=mysql_query("SELECT COUNT(*) AS count FROM winners WHERE awards_prizes_id='$pr->id'"); echo mysql_Error(); $cr=mysql_fetch_object($cq); $count=$cr->count; if($count<$pr->number) $color="red"; else $color="green"; echo " [".$count."/".$pr->number."]"; echo ""; echo "
"; $prevprizeid=$pr->id; } if($pr->projectnumber) { echo " "; echo " "; echo " "; echo " "; echo "($pr->projectnumber) $pr->title"; echo "
"; } else { /* echo " "; echo " "; echo " "; echo " "; echo "No winner(s) specified"; */ } } echo "
"; } } } send_footer(); ?>