diff --git a/admin/award_upload.php b/admin/award_upload.php
index f1eb48a..9515e29 100644
--- a/admin/award_upload.php
+++ b/admin/award_upload.php
@@ -27,7 +27,7 @@ require_once('curl.inc.php');
user_auth_required('committee', 'admin');
//function get_cwsf_award_winners()
-function get_winners($awardid, $fairs_id, $catmap_str=NULL, $divmap_str=NULL)
+function get_winners($awardid, $fairs_id)
{
global $config;
@@ -172,6 +172,51 @@ function get_winners($awardid, $fairs_id, $catmap_str=NULL, $divmap_str=NULL)
return $all_winners;
}
+function count_winners($awardid, $fairs_id)
+{
+ global $config;
+ $count = 0;
+ $awards = array();
+ if($awardid == -1) {
+ /* Get all for this fair */
+ $q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND year='{$config['FAIRYEAR']}'");
+ if(mysql_num_rows($q) == 0) {
+ error_("Can't find award id $awardid");
+ return 0;
+ }
+ while($a = mysql_fetch_assoc($q)) {
+ $awards[] = $a;
+ }
+ } else {
+ /* 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 0;
+ }
+ $award=mysql_fetch_assoc($q);
+ $awards[] = $award;
+ }
+
+ foreach($awards as $award) {
+ /* 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 COUNT(projects.id) as C 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']}'");
+ $wc = mysql_fetch_assoc($wq);
+ $count += $wc['C'];
+ }
+ }
+ return $count;
+
+}
+
function load_server_cats_divs($fairs_id)
{
@@ -243,15 +288,21 @@ case 'award_upload':
$upload_something = false;
foreach($all_winners as &$w) {
foreach($w['prizes'] as &$p) {
+
+ if(count($p['projects']))
+ $upload_something = true;
+
+ /* Only update divs/cats for SFIAB fairs, the
+ * YSC/STO awards system doesn't care about divisions, but YSC
+ * registration does, but that's a different bit of code */
+ if($fair['type'] != 'sfaib') continue;
+
foreach($p['projects'] as &$pr) {
$div_id = intval($divs[$w['id']][$p['id']][$pr['projectid']]);
$pr['projectdivisions_id'] = $div_id;
$cat_id = intval($cats[$w['id']][$p['id']][$pr['projectid']]);
$pr['projectcategories_id'] = $cat_id;
}
-
- if(count($p['projects']))
- $upload_something = true;
}
}
@@ -386,7 +437,6 @@ case 'load':
$fairs_id = intval($_GET['fairs_id']);
$winners = get_winners($award_awards_id, $fairs_id);
- list($server_cats, $server_divs, $catmap, $divmap) = load_server_cats_divs($fairs_id);
$divs = projectdivisions_load();
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id}'");
@@ -394,17 +444,30 @@ case 'load':
echo i18n("The following list of winning projects/students will be sent to: %1. Use the 'Edit Default Division Assignments' button to change the default mappings for divisions. You can over-ride any division assignment by changing it in the list below. Category assignments are done automatically based on grade. When you are happy with the list below, click the 'Upload Winners' button.", array($fair['name']));
+ if($fair['type'] != 'sfiab') {
+ echo '
';
+ echo i18n('This server does not collection Division information, all division selection is disabled.');
+ $server_cats = array();
+ $server_divs = array();
+ $catmap =array();
+ $divmap = array();
+ $division_disabled = true;
+ } else {
+ list($server_cats, $server_divs, $catmap, $divmap) = load_server_cats_divs($fairs_id);
+ $division_disabled = false;
+ }
+
?>
-
-
-
+
+