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. */ ?> << ".i18n("Back to Administration")."\n"; echo "<< ".i18n("Back to Awards Main")."\n"; if($_POST['save']=="edit" || $_POST['save']=="add") { if($_POST['save']=="add") { $q=mysql_query("INSERT INTO award_awards (award_sponsors_id,award_types_id,year) VALUES ('".$_POST['award_sponsors_id']."','".$_POST['award_types_id']."','".$config['FAIRYEAR']."')"); $id=mysql_insert_id(); } else $id=$_POST['id']; $exec="UPDATE award_awards SET ". "name='".mysql_escape_string(stripslashes($_POST['name']))."', ". "`order`='".mysql_escape_string(stripslashes($_POST['order']))."', ". "award_sponsors_id='".mysql_escape_string(stripslashes($_POST['award_sponsors_id']))."', ". "award_types_id='".mysql_escape_string(stripslashes($_POST['award_types_id']))."', ". "criteria='".mysql_escape_string(stripslashes($_POST['criteria']))."' ". "WHERE id='$id'"; mysql_query($exec); echo mysql_error(); //whipe out any old award-category links mysql_query("DELETE FROM award_awards_projectcategories WHERE award_awards_id='$id'"); //now add the new ones if(is_array($_POST['eligiblecategories'])) { foreach($_POST['eligiblecategories'] AS $cat) { mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES ('$id','$cat','".$config['FAIRYEAR']."')"); } } //whipe out any old award-divisions links mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$id'"); //now add the new ones if(is_array($_POST['eligibledivisions'])) { foreach($_POST['eligibledivisions'] AS $div) { mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES ('$id','$div','".$config['FAIRYEAR']."')"); } } if($_POST['save']=="add") echo happy("Award successfully added"); else echo happy("Successfully saved changes to award"); } if($_POST['action']=="reorder") { if(is_array($_POST['reorder'])) { foreach($_POST['reorder'] AS $key=>$val) { mysql_query("UPDATE award_awards SET `order`='$val' WHERE id='$key'"); } echo happy("Awards successfully reordered"); } } if($_GET['action']=="delete" && $_GET['delete']) { mysql_query("DELETE FROM award_awards WHERE id='".$_GET['delete']."'"); echo happy("Award successfully deleted"); } if($_GET['action']=="edit" || $action=="add") { echo "<< ".i18n("Back to Awards List")."\n"; if($_GET['action']=="edit") { echo "

".i18n("Edit Award")."

\n"; $buttontext="Save Award"; $q=mysql_query("SELECT award_awards.id, award_awards.name, award_awards.criteria, award_awards.order, award_types.id AS award_types_id, award_types.type, award_sponsors.id AS award_sponsors_id, award_sponsors.organization FROM award_awards, award_types, award_sponsors WHERE award_awards.year='".$config['FAIRYEAR']."' AND award_awards.id='".$_GET['edit']."' AND award_awards.award_sponsors_id=award_sponsors.id AND award_awards.award_types_id=award_types.id "); echo mysql_error(); $r=mysql_fetch_object($q); } else if($action=="add") { echo "

".i18n("Add Award")."

\n"; $buttontext="Add Award"; $firstsponsor="\n"; $firsttype="\n"; } $buttontext=i18n($buttontext); echo "
\n"; echo "\n"; echo "\n"; if($_GET['action']=="edit") echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n"; echo ""; echo "\n"; echo "
".i18n("Name")."name)."\" size=\"50\" maxlength=\"128\" />
".i18n("Order")."order)."\" size=\"5\" maxlength=\"5\" />(".i18n("presentation order").")
".i18n("Sponsor").""; $sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); echo ""; echo "
".i18n("Type").""; $tq=mysql_query("SELECT id,type FROM award_types ORDER BY type"); echo ""; echo "
".i18n("Criteria")."
".i18n("Eligibility").""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".i18n("Age Categories")."".i18n("Divisions")."
"; $currentcategories=array(); //select the current categories that this award is linked to $ccq=mysql_query("SELECT * FROM award_awards_projectcategories WHERE award_awards_id='$r->id'"); while($ccr=mysql_fetch_object($ccq)) $currentcategories[]=$ccr->projectcategories_id; //now select all the categories so we can list them all $cq=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade"); echo mysql_error(); while($cr=mysql_fetch_object($cq)) { if(in_array($cr->id,$currentcategories)) $ch="checked=\"checked\""; else $ch=""; echo "id\" />".i18n($cr->category)."
"; } echo "
"; $currentdivisions=array(); //select the current categories that this award is linked to $cdq=mysql_query("SELECT * FROM award_awards_projectdivisions WHERE award_awards_id='$r->id'"); while($cdr=mysql_fetch_object($cdq)) $currentdivisions[]=$cdr->projectdivisions_id; $dq=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division"); echo mysql_error(); while($dr=mysql_fetch_object($dq)) { if(in_array($dr->id,$currentdivisions)) $ch="checked=\"checked\""; else $ch=""; echo "id\" />".i18n($dr->division)."
"; } echo ""; echo "
"; echo "
\n"; echo "
\n"; } else { echo "
"; echo i18n("Filter By:"); echo "
"; echo ""; echo "
"; $q=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); echo ""; echo ""; $q=mysql_query("SELECT id,type FROM award_types ORDER BY type"); echo ""; echo ""; echo "
"; echo "
"; echo "".i18n("Add New Award")."\n"; echo "
"; if($award_sponsors_id) $where_asi="AND award_sponsors_id='$award_sponsors_id'"; if($award_types_id) $where_ati="AND award_types_id='$award_types_id'"; if(!$orderby) $orderby="order"; $q=mysql_query("SELECT award_awards.id, award_awards.name, award_awards.order, award_types.type, award_sponsors.organization FROM award_awards, award_types, award_sponsors WHERE award_awards.year='".$config['FAIRYEAR']."' $where_asi $where_ati AND award_awards.award_sponsors_id=award_sponsors.id AND award_awards.award_types_id=award_types.id ORDER BY `$orderby`"); echo mysql_error(); if(mysql_num_rows($q)) { echo "
"; echo ""; echo ""; echo ""; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo "\n"; while($r=mysql_fetch_object($q)) { echo "\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_object($numq); $numprizes=$numr->num; echo " "; echo " \n"; echo "\n"; } echo "
".i18n("Order")."".i18n("Sponsor")."".i18n("Type")."".i18n("Name")."".i18n("# of Prizes")."".i18n("Actions")."
id]\" value=\"$r->order\" size=\"3\" />$r->organization$r->type$r->name"; echo "$numprizes  "; echo "id\">\"view\""; echo ""; echo "id\">"; echo " "; echo "id\">"; echo "
\n"; echo ""; echo "
"; } } send_footer(); ?>