Handle multiple awards in the winner postback

This commit is contained in:
dave 2010-04-18 22:41:23 +00:00
parent f0515a93bd
commit 6242b9ef5e

View File

@ -294,10 +294,10 @@ function award_upload_assign(&$fair, &$award, &$prize, &$project, $year, &$respo
if($award['external_register_winners'] == 1 && $new_reg == true) {
/* This award is for students who are participating in this fair, we need
* to get their reg number to them if this is a new registration */
email_send("new_participant",$student['email'],array(),
array( "EMAIL"=>$student['email'],
"REGNUM"=>$registration['num'])
);
// email_send("new_participant",$student['email'],array(),
// array( "EMAIL"=>$student['email'],
// "REGNUM"=>$registration['num'])
// );
$response['notice'][] = " - Sent welcome registration email to: {$student['firstname']} {$student['lastname']} <{$student['email']}>";
}
}
@ -311,23 +311,33 @@ function award_upload_assign(&$fair, &$award, &$prize, &$project, $year, &$respo
function handle_award_upload(&$u, &$fair, &$data, &$response)
{
$external_identifier = $data['award_upload']['external_identifier'];
$year = intval($data['award_upload']['year']);
$prizes = $data['award_upload']['prizes'];
$response['notice'][] = 'Handle Award Upload deprecated , please upgrade your SFIAB';
$response['error'] = 1;
}
function handle_awards_upload(&$u, &$fair, &$data, &$response)
{
// $response['debug'] = array_keys($data['awards_upload']);
// $response['error'] = 0;
// return;
foreach($data['awards_upload'] as $award_data) {
$external_identifier = $award_data['external_identifier'];
$year = intval($award_data['year']);
/* Find the award */
$eid = mysql_real_escape_string($external_identifier);
$q = mysql_query("SELECT * FROM award_awards WHERE external_identifier='$eid' AND year='$year'");
if(mysql_num_rows($q) != 1) {
$response['message'] = "Unknown award identifier '$eid'";
$response['message'] = "Unknown award identifier '$eid' for year $year";
$response['error'] = 1;
return;
}
$award = mysql_fetch_assoc($q);
$aaid = $award['id'];
$response['notice'][] = "Found award: {$award['name']}";
$response['notice'][] = "Found award: {$award_data['name']}";
/* Load prizes, we fetched the right award by year, so we don't need to
* check the year as long as we query by aaid */
@ -335,20 +345,22 @@ function handle_award_upload(&$u, &$fair, &$data, &$response)
$q = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$aaid'");
while($prize = mysql_fetch_assoc($q)) {
$response['notice'][] = " - Prize: {$prize['prize']}";
/* Clean out existing winners for this prize */
mysql_query("DELETE FROM winners WHERE
award_prize_id='{$prize['id']}'
AND fairs_id='{$fair['id']}'");
/* Assign projects to this prize */
$ul_p =& $data['award_upload']['prizes'][$prize['prize']];
$ul_p =& $award_data['prizes'][$prize['prize']];
if(!is_array($ul_p['projects'])) continue;
foreach($ul_p['projects'] as &$project) {
award_upload_assign($fair, $award, $prize, $project, $year, $response);
}
}
$response['notice'][] = 'Award winners saved';
}
$response['notice'][] = 'All awards and winners saved';
$response['error'] = 0;
}
@ -449,11 +461,12 @@ function handle_award_additional_materials(&$u, &$fair, &$data, &$response)
if(array_key_exists('getstats', $data)) handle_getstats($u,$fair, $data, $response);
if(array_key_exists('stats', $data)) handle_stats($u,$fair, $data, $response);
if(array_key_exists('getawards', $data)) handle_getawards($u,$fair,$data, $response);
if(array_key_exists('awards_upload', $data)) handle_awards_upload($u,$fair,$data, $response);
if(array_key_exists('award_upload', $data)) handle_award_upload($u,$fair,$data, $response);
if(array_key_exists('get_categories', $data)) handle_get_categories($u,$fair,$data, $response);
if(array_key_exists('get_divisions', $data)) handle_get_divisions($u,$fair,$data, $response);
if(array_key_exists('award_additional_materials', $data)) handle_award_additional_materials($u,$fair,$data, $response);
$response['hi'] = 'hi';
// $response['hi'] = 'hi';
echo urlencode(json_encode($response));
// echo "Success!<br />";