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. */ require_once('../common.inc.php'); require_once('../user.inc.php'); require_once('../projects.inc.php'); require_once('curl.inc.php'); user_auth_required('committee', 'admin'); //function get_cwsf_award_winners() function get_winners($awardid) { global $config; /* Mappings of the name we want => to the column name returned in MYSQL */ $school_fields = array( 'schoolname'=>'school', 'schoollang'=>'schoollang', 'schoollevel'=>'schoollevel', 'board'=>'board', 'district'=>'district', 'phone'=>'phone', 'fax'=>'fax', 'address'=>'address', 'city'=>'city', 'province_code'=>'province_code', 'postalcode'=>'postalcode', 'principal'=>'principal', 'schoolemail'=>'schoolemail', 'sciencehead'=>'sciencehead', 'scienceheademail'=>'scienceheademail', 'scienceheadphone'=>'scienceheadphone'); $student_fields = array('firstname'=>'firstname', 'lastname'=>'lastname', 'email'=>'email', 'gender'=>'sex', 'grade'=>'grade', 'language'=>'lang', 'birthdate'=>'dateofbirth', 'address'=>'address', 'city'=>'city', 'province'=>'province', 'postalcode'=>'postalcode', 'phone'=>'phone', 'teachername'=>'teachername', 'teacheremail'=>'teacheremail'); /* Get the award */ $q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND year='{$config['FAIRYEAR']}'"); if(mysql_num_rows($q)!=1) { error_("Can't find award id $awardid"); return false; } $award=mysql_fetch_assoc($q); $winners=array( 'prizes' => array(), 'external_identifier' => $award['external_identifier'], 'postback' => $award['external_postback']); /* Get the prizes */ $q=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='{$award['id']}'"); while($prize=mysql_fetch_assoc($q)) { $pid = $prize['id']; $wq=mysql_query("SELECT projects.* FROM award_prizes LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id LEFT JOIN projects ON projects.id=winners.projects_id WHERE awards_prizes_id='$pid' AND winners.year='{$config['FAIRYEAR']}'"); echo mysql_error(); /* Get all projects assigned to this prize */ $prizewinners = array(); while($project=mysql_fetch_assoc($wq)) { /* Get the students */ $sq=mysql_query("SELECT * FROM students WHERE registrations_id='{$project['registrations_id']}' AND year='{$config['FAIRYEAR']}'"); $students=array(); while($s=mysql_fetch_assoc($sq)) { /* Get the student's school */ $schoolq=mysql_query("SELECT * FROM schools WHERE id='{$s['schools_id']}'"); $schoolr=mysql_fetch_assoc($schoolq); $school = array("xml_type"=>"school");/* for ysc compatability */ foreach($school_fields as $k=>$v) $school[$k] = $schoolr[$v]; /* Pack up the student data too */ $student = array('xml_type'=>'student',/* for ysc compatability */ 'school' => $school); foreach($student_fields as $k=>$v) $student[$k] = $s[$v]; $students[] = $student; } /* Save the project info => students */ $prizewinners[]=array( 'xml_type' => 'project',/* for ysc compatability */ 'projectid'=>$project['id'], 'projectnumber'=>$project['projectnumber'], 'title'=>$project['title'], 'abstract'=>$project['summary'], 'students'=>$students ); } /* Save the prize info => projects */ $winners['prizes'][$prize['prize']] = array( 'xml_type'=>'prize', /* For ysc compatability */ 'identifier'=>$prize['prize'], /* for ysc compatability */ 'projects'=>$prizewinners); } return $winners; } switch($_GET['action']) { case 'award_upload': $award_awards_id = intval($_GET['id']); $winners = get_winners($award_awards_id); /* Get the fair */ $q = mysql_query("SELECT award_source_fairs_id FROM award_awards WHERE id='$award_awards_id'"); $a = mysql_fetch_assoc($q); $q = mysql_query("SELECT * FROM fairs WHERE id='{$a['award_source_fairs_id']}'"); $fair = mysql_fetch_assoc($q); echo 'Award
'; if($winners == false) { echo notice(i18n('No winners selected for this award')); } else { if($fair['type'] == 'ysc') { $req=array("awardwinners"=>array( "username"=>$fair['username'], "password"=>$fair['password'], "identifier"=>$winners['external_identifier']; "prizes"=>$winners; ) ); $url = $winners['external_postback']; } else { $req = array('award_upload' => $winners); $req['award_upload']['year'] = $config['FAIRYEAR']; $url = ''; /* url is ignored for type = sfiab */ } $data = curl_query($fair, $req, $url); if($data['error'] != 0) { echo error("Server said: $data"); } else { echo notice("Server Said: $data"); } echo "
";
		print_r($winners);
		echo "
"; } exit; } send_header("Award Upload", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Awards Main' => 'admin/awards.php') ); echo "
"; ?> \n"; echo ""; echo ""; } ?>
{$r->awardname}{$r->fairname}"; echo "id})\" >".i18n("send").""; echo "