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. */ ?> award_id=$id;"; } $q = "UPDATE award_awards SET award_types_id='".intval($_POST['award_types_id'])."', presenter='".mysql_escape_string(stripslashes($_POST['presenter']))."', excludefromac='".(($_POST['excludefromac'] == 1) ? 1 : 0)."', cwsfaward='".(($_POST['cwsfaward'] == 1) ? 1 : 0)."', self_nominate='".(($_POST['self_nominate'] == 'yes') ? 'yes' : 'no')."', schedule_judges='".(($_POST['schedule_judges'] == 'yes') ? 'yes' : 'no')."', description='".mysql_escape_string(stripslashes($_POST['description']))."' "; if(array_key_exists('name', $_POST)) { /* These values may be disabled, if they name key exists, assume * they aren't disabled and save them too */ $q .= ",name='".mysql_escape_string(stripslashes($_POST['name']))."', criteria='".mysql_escape_string(stripslashes($_POST['criteria']))."', sponsors_id='".intval($_POST['sponsors_id'])."' "; } $q .= "WHERE id='$id'"; mysql_query($q); print_r($_POST); echo $q; echo mysql_error(); happy_("Award information saved"); exit; case 'eligibility_load': $id = intval($_GET['id']); //select the current categories that this award is linked to $ret = array('categories'=>array(), 'divisions'=>array() ); $q=mysql_query("SELECT * FROM award_awards_projectcategories WHERE award_awards_id='$id'"); while($r=mysql_fetch_assoc($q)) { $ret['categories'][] = $r['projectcategories_id']; } //select the current categories that this award is linked to $q=mysql_query("SELECT * FROM award_awards_projectdivisions WHERE award_awards_id='$id'"); while($r=mysql_fetch_assoc($q)) { $ret['divisions'][] = $r['projectdivisions_id']; } echo json_encode($ret); exit; case 'eligibility_save': $id = intval($_POST['award_awards_id']); //now add the new ones if(!is_array($_POST['categories']) || !is_array($_POST['divisions'])) { error_("Invalid data"); exit; } foreach($_POST['categories'] AS $key=>$cat) { if(!is_numeric($cat)) { error_("Invalid data"); exit; } } foreach($_POST['divisions'] AS $key=>$div) { if(!is_numeric($div)) { error_("Invalid data"); exit; } } $q=mysql_query("SELECT (CASE WHEN ((SELECT a.award_types_id FROM award_awards AS a WHERE id=$id) = 1) THEN ( SELECT COUNT(*) AS c FROM award_awards AS aa LEFT JOIN award_awards_projectcategories AS aapc ON (aa.id = aapc.award_awards_id) LEFT JOIN award_awards_projectdivisions AS aapd ON (aa.id = aapd.award_awards_id) WHERE aa.conferences_id = {$conference['id']} AND aa.award_types_id=1 AND aa.id != $id AND projectcategories_id IN (". implode(",", $_POST['categories']) .") AND projectdivisions_id IN (". implode(",", $_POST['divisions']) .") ) ELSE 0 END) as c"); $r = mysql_fetch_object($q); if($r->c != 0) { error_("Cannot save. There is already a divisional award with the same eligibility criteria."); exit; } //wipe out any old award-category links mysql_query("DELETE FROM award_awards_projectcategories WHERE award_awards_id='$id'"); foreach($_POST['categories'] AS $key=>$cat) { $c = intval($cat); mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,conferences_id) VALUES ('$id','$c','{$conference['id']}')"); echo mysql_error(); } //wipe out any old award-divisions links mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$id'"); //now add the new ones foreach($_POST['divisions'] AS $key=>$div) { $d = intval($div); mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,conferences_id) VALUES ('$id','$d','{$conference['id']}')"); echo mysql_error(); } happy_("Eligibility information saved"); exit; case 'prize_order': $order = 0; foreach ($_GET['prizelist'] as $position=>$id) { if($id == '') continue; $order++; mysql_query("UPDATE `award_prizes` SET `order`='$order' WHERE `id`='$id'"); } // print_r($_GET); happy_("Order Updated."); exit; case 'award_order': $order = 0; foreach ($_GET['awardlist'] as $position=>$id) { if($id == '') continue; $order++; mysql_query("UPDATE `award_awards` SET `order`='$order' WHERE `id`='$id'"); } happy_("Order updated"); exit; case 'prizeinfo_load': $id = intval($_GET['id']); if($id == -1) { $q=mysql_query("SELECT * FROM award_prizes WHERE conferences_id='-1' AND award_awards_id='0' ORDER BY `order`"); } else { $q = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$id' ORDER BY `order`"); } while($r=mysql_fetch_assoc($q)) { $ret[] = $r; } echo json_encode($ret); exit; case 'prize_load': $id = intval($_GET['id']); $q = mysql_query("SELECT * FROM award_prizes WHERE id='$id'"); $ret=mysql_fetch_assoc($q); foreach($ret AS $k=>$v) { $ret[$k]=$v; } echo json_encode($ret); exit; case 'prize_create': $aaid = intval($_GET['award_awards_id']); $conferenceId = $conference['id']; if($aaid == -1) { $aaid = 0; $conferenceId = -1; } mysql_query("INSERT INTO award_prizes(award_awards_id,conferences_id) VALUES ('$aaid','$conferenceId');"); $ret = array('id' => mysql_insert_id() ); echo json_encode($ret); exit; case 'prize_save': $id = intval($_POST['id']); $q="UPDATE award_prizes SET prize='".mysql_escape_string(stripslashes($_POST['prize']))."', cash='".intval($_POST['cash'])."', scholarship='".intval($_POST['scholarship'])."', value='".intval($_POST['value'])."', number='".intval($_POST['number'])."', excludefromac='".(($_POST['excludefromac']==1)? 1 : 0)."', trophystudentkeeper='".(array_key_exists('trophystudentkeeper', $_POST) ? 1 : 0)."', trophystudentreturn='".(array_key_exists('trophystudentreturn', $_POST) ? 1 : 0)."', trophyschoolkeeper='".(array_key_exists('trophyschoolkeeper', $_POST) ? 1 : 0)."', trophyschoolreturn='".(array_key_exists('trophyschoolreturn', $_POST) ? 1 : 0)."' WHERE id='$id'"; mysql_query($q); // echo $q; // echo mysql_error(); happy_("Prize saved"); exit; case 'prize_delete': $id = intval($_GET['id']); award_prize_delete($id); happy_("Prize deleted"); exit; case 'feeder_load': $id = intval($_GET['id']); /* Prepare two lists of fair IDs, for which fairs can upload and download this award */ $q=mysql_query("SELECT * FROM fairs_awards_link WHERE award_awards_id='$id'"); $ul = array(); $dl = array(); while($r=mysql_fetch_assoc($q)) { if($r['upload_winners'] == 'yes') $ul[$r['fairs_id']] = true; if($r['download_award'] == 'yes') $dl[$r['fairs_id']] = true; } $q = mysql_query("SELECT * FROM award_awards WHERE id='$id'"); $a = mysql_fetch_assoc($q); ?>

/>

/>

:
/>
/>

"; $ch = $dl[$r['id']] == true ? 'checked="checked"' : ''; echo ""; $ch = $ul[$r['id']] == true ? 'checked="checked"' : ''; echo ""; echo ''; } ?>
{$r['name']}

$f) { $dl = ($f['dl'] == true) ? 'yes' : 'no'; $ul = ($f['ul'] == true) ? 'yes' : 'no'; mysql_query("INSERT INTO fairs_awards_link (award_awards_id,fairs_id,download_award,upload_winners) VALUES ('$id','$fairs_id','$dl','$ul')"); echo mysql_error(); } $ident=mysql_escape_string(stripslashes($_POST['identifier'])); $per_fair = $_POST['per_fair'] == 'yes' ? 'yes' : 'no'; $mat = intval($_POST['additional_materials']); $w = intval($_POST['register_winners']); mysql_query("UPDATE award_awards SET external_identifier='$ident', external_additional_materials='$mat', external_register_winners='$w', per_fair='$per_fair' WHERE id='$id'"); happy_("Feeder Fair information saved"); exit; } send_header("Awards Management", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Awards Main' => 'admin/awards.php') ); ?>
"; echo i18n("Filter By:"); echo "
"; echo ""; echo ""; echo "
"; $q=mysql_query("SELECT id,organization FROM sponsors ORDER BY organization"); echo ""; echo "
"; $q=mysql_query("SELECT id,type FROM award_types WHERE conferences_id='{$conference['id']}' ORDER BY type"); echo ""; echo ""; /* //FIXME: 'confirmed' no longer exists, we need to lookup their sponsorship record and check the status there, either pending, confirmed or received, dunno if it makes sense to put that here or not.. echo ""; */ echo ""; echo "
"; ?>
" /> " />


"; draw_awards_table(); echo ""; if($_GET['action'] == 'edit_prize_template') { ?> " /> if($sponsors_id) $where_asi="AND sponsors_id='$sponsors_id'"; if($award_types_id) $where_ati="AND award_types_id='$award_types_id'"; // if($award_sponsors_confirmed) $where_asc="AND award_sponsors.confirmed='$award_sponsors_confirmed'"; if(!$orderby) $orderby="order"; $q=mysql_query("SELECT award_awards.id, award_awards.name, award_awards.order, award_awards.award_source_fairs_id, award_types.type, sponsors.organization FROM award_awards LEFT JOIN sponsors ON sponsors.id = award_awards.sponsors_id LEFT JOIN award_types ON award_types.id = award_awards.award_types_id WHERE award_awards.conferences_id='{$conference['id']}' $where_asi $where_ati AND award_types.conferences_id='{$conference['id']}' ORDER BY `$orderby`"); echo mysql_error(); if(mysql_num_rows($q)){ echo "* ".i18n("Click on the Script Order and drag to re-order the awards"); echo ""; echo ""; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo "\n"; $hasexternal=false; while($r=mysql_fetch_object($q)) { if($r->award_source_fairs_id) { $cl="externalaward"; $hasexternal=true; } else $cl=""; $eh = "style=\"cursor:pointer;\" onclick=\"popup_editor({$r->id},'');\""; echo "id}\" >\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $numq=mysql_query("SELECT SUM(number) AS num FROM award_prizes WHERE award_awards_id='{$r->id}'"); $numr=mysql_fetch_assoc($numq); if(!$numr['num']) $numr['num']=0; echo " "; echo " \n"; echo "\n"; } if($hasexternal) echo ""; echo "
".i18n("Order")."".i18n("Sponsor")."".i18n("Type")."".i18n("Name")."".i18n("Prizes")."".i18n("Actions")."
id}\" class=\"drag_handle\" style=\"cursor:move; text-align:right;\">{$r->order}{$r->organization}{$r->type}{$r->name}{$numr['num']}"; // echo ""; // echo " "; echo "id});\" href=\"#\" >"; echo "
".i18n("Indicates award imported from an external source")."
\n"; // echo ""; } echo "
"; //echo "Edit prizes for the generic prize template"; } ?>