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; } //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,year) VALUES ('$id','$c','{$config['FAIRYEAR']}')"); 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,year) VALUES ('$id','$d','{$config['FAIRYEAR']}')"); 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 year='-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); echo json_encode($ret); exit; case 'prize_create': $aaid = intval($_GET['award_awards_id']); $year = $config['FAIRYEAR']; if($aaid == -1) { $aaid = 0; $year = -1; } mysql_query("INSERT INTO award_prizes(award_awards_id,year) VALUES ('$aaid','$year');"); $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='".(($_POST['trophystudentkeeper']==1) ? 1 : 0)."', trophystudentreturn='".(($_POST['trophystudentreturn']==1) ? 1 : 0)."', trophyschoolkeeper='".(($_POST['trophyschoolkeeper']==1) ? 1 : 0)."', trophyschoolreturn='".(($_POST['trophyschoolreturn']==1) ? 1 : 0)."' WHERE id='$id'"; mysql_query($q); // echo $q; // echo mysql_error(); happy_("Prize saved"); exit; case 'prize_delete': $id = intval($_GET['id']); mysql_query("DELETE FROM award_prizes WHERE id='$id'"); // echo "DELETE FROM award_prizes WHERE id='$id'"; happy_("Prize deleted"); exit; case 'feeder_load': $id = intval($_GET['id']); $ret = array('ul'=>array(), 'dl'=>array()); /* 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'"); while($r=mysql_fetch_assoc($q)) { if($r['download_award'] == 'yes') $ret['dl'][] = $r['fairs_id']; if($r['upload_winners'] == 'yes') $ret['ul'][] = $r['fairs_id']; } $q = mysql_query("SELECT * FROM award_awards WHERE id='$id'"); $a = mysql_fetch_assoc($q); $ret['identifier'] = $a['external_identifier']; $ret['additional_materials'] = $a['external_additional_materials']; $ret['register_winners'] = $a['external_register_winners']; echo json_encode($ret); exit; case 'feeder_save': // print_r($_POST); $id = intval($_POST['award_awards_id']); $dl = is_array($_POST['feeder_dl']) ? $_POST['feeder_dl'] : array(); $ul = is_array($_POST['feeder_ul']) ? $_POST['feeder_ul'] : array(); /* Prepare a fair-wise list */ $data = array(); foreach($dl AS $fairs_id) $data[$fairs_id]['dl'] = true; foreach($ul AS $fairs_id) $data[$fairs_id]['ul'] = true; /* Now save each one */ mysql_query("DELETE FROM fairs_awards_link WHERE award_awards_id='$id'"); echo mysql_error(); foreach($data as $fairs_id=>$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'])); $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' 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 year='{$config['FAIRYEAR']}' 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 "
"; ?>
" /> " />


" /> 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, award_types, sponsors WHERE award_awards.year='{$config['FAIRYEAR']}' $where_asi $where_ati $where_asc AND award_awards.sponsors_id=sponsors.id AND award_awards.award_types_id=award_types.id AND award_types.year='{$config['FAIRYEAR']}' ORDER BY `$orderby`"); echo mysql_error(); if(mysql_num_rows($q)) { echo ""; echo ""; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo "\n"; $hasexternal=false; while($r=mysql_fetch_object($q)) { $cl = ($r->award_source_fairs_id) ? externalaward : ''; $eh = "style=\"cursor:pointer;\" onclick=\"popup_editor({$r->id},'');\""; echo "id}\" >\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $numq=mysql_query("SELECT COUNT(id) AS num FROM award_prizes WHERE award_awards_id='{$r->id}'"); $numr=mysql_fetch_assoc($numq); 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"; if($_GET['action'] == 'edit_prize_template') { ?>