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. */ ?> mysql_insert_id() ); echo json_encode($ret); exit; case 'award_delete': $id=intval($_GET['id']); mysql_query("DELETE FROM award_prizes WHERE award_awards_id='$id'"); mysql_query("DELETE FROM award_awards_projectcategories WHERE award_awards_id='$id'"); mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$id'"); mysql_query("DELETE FROM award_awards WHERE id='$id'"); exit; case 'awardinfo_save': /* Scrub the data while we save it */ $id=intval($_POST['id']); $q = "UPDATE award_awards SET name='".mysql_escape_string(stripslashes($_POST['name']))."', sponsors_id='".intval($_POST['sponsors_id'])."', 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')."', criteria='".mysql_escape_string(stripslashes($_POST['criteria']))."', description='".mysql_escape_string(stripslashes($_POST['description']))."' WHERE id='$id'"; happy_("Award Information Saved."); mysql_query($q); exit; case 'eligibilty_load': $id = intval($_GET['id']); //select the current categories that this award is linked to $reg = 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['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']}')"); } //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']}')"); } happy_("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(); /* 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']; 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'])); mysql_query("UPDATE award_awards SET external_identifier='$ident' WHERE id='$id'"); happy_("Saved"); exit; } send_header("Awards Management", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Awards Main' => 'admin/awards.php') ); ?> "; ?>

:
: "; //only show the "choose a sponsor" option if we are adding,if we are editing, then they must have already chosen one. echo $firstsponsor; while($sr=mysql_fetch_object($sq)) { echo ""; } ?>
:
: "; //only show the "choose a type" option if we are adding,if we are editing, then they must have already chosen one. echo $firsttype; while($tr=mysql_fetch_object($tq)) { echo ""; } ?>
:
:

Options


"; ?>
: id}\" name=\"categories[]\" value=\"$cr->id\" />".i18n($cr->category)."
"; } ?>
: id}\" name=\"divisions[]\" value=\"$dr->id\" />".i18n($dr->division)."
"; } // if(count($currentcategories)==0 || count($currentdivisions)==0) // echo "
".i18n("At least one age category and one division must be selected")."



*


Click on a prize to edit


:
:
($):
($):
($):
:
:

" /> " disabled="disabled" />

:

"; echo ""; echo ""; echo ''; } ?>
{$r['name']}

" />
"; 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') { ?>