diff --git a/admin/award_awardcreatedivisional.php b/admin/award_awardcreatedivisional.php new file mode 100644 index 00000000..2559fc64 --- /dev/null +++ b/admin/award_awardcreatedivisional.php @@ -0,0 +1,206 @@ + + 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"; + + //first, we can only do this if we dont have any type=divisional awards created yet + $q=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE award_types_id='1' AND year='{$config['FAIRYEAR']}'"); + $r=mysql_fetch_object($q); + if($r->num) + { + echo error(i18n("%1 Divisional awards already exist. There must not be any divisional awards in order to run this wizard",array($r->num))); + } + else + { + + $q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id"); + while($r=mysql_fetch_object($q)) + $div[$r->id]=$r->division; + + $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id"); + while($r=mysql_fetch_object($q)) + $cat[$r->id]=$r->category; + + + if($_GET['action']=="create") + { + $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); + $prizes=array(); + while($r=mysql_fetch_object($q)) + { + $prizes[]=array( + "cash"=>$r->cash, + "scholarship"=>$r->scholarship, + "prize"=>$r->prize, + "number"=>$r->number, + "order"=>$r->order); + } + + $ord=1; + echo "
"; + foreach($div AS $d_id=>$d_division) + { + foreach($cat AS $c_id=>$c_category) + { + + echo i18n("Creating %1 - %2",array($c_category,$d_division))."
"; + mysql_query("INSERT INTO award_awards (award_sponsors_id,award_types_id,name,criteria,`order`,year) VALUES ( + '{$_GET['award_sponsors_id']}', + '1', + '$c_category - $d_division', + '".i18n("Best %1 projects in the %2 division",array($c_category,$d_division))."', + '$ord', + '{$config['FAIRYEAR']}' + )"); + echo mysql_error(); + $award_awards_id=mysql_insert_id(); + + + mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES ('$award_awards_id','$c_id','{$config['FAIRYEAR']}')"); + mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES ('$award_awards_id','$d_id','{$config['FAIRYEAR']}')"); + + $ord++; + + echo "  ".i18n("Prizes: "); + foreach($prizes AS $prize) + { + mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,prize,number,`order`,year) VALUES ( + '$award_awards_id', + '{$prize['cash']}', + '{$prize['scholarship']}', + '{$prize['prize']}', + '{$prize['number']}', + '{$prize['order']}', + '{$config['FAIRYEAR']}' + )"); + echo $prize['prize'].","; + } + echo "
"; + } + } + echo happy(i18n("All divisional awards and prizes successfully created")); + echo "".i18n("Go to awards manager")."\n"; + } + else + { + echo "
"; + echo i18n("Please choose the sponsor and create the prizes that will be added to all divisional awards"); + echo "
"; + + + echo ""; + echo ""; + + echo ""; + echo "
".i18n("Sponsor").":"; + $sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); + echo ""; + echo "
".i18n("Prizes")."Edit prizes to be created for all divisional awards"; + //the 'generic' template prizes for the awards are stored with year =-1 and award_awards_id=0 + + $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); + + if(mysql_num_rows($q)) + { + /* + echo ""; + echo ""; + echo ""; + */ + + echo ""; + echo ""; + // echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + // echo " "; + echo "\n"; + + + while($r=mysql_fetch_object($q)) + { + echo "\n"; + echo " \n"; + echo " "; + echo " "; + echo " \n"; + echo "\n"; + } + + echo "
".i18n("Order")."".i18n("Prize Description")."".i18n("Cash Amount")."".i18n("Scholarship Amount")."".i18n("# of Prizes")."Actions
$r->prize"; + if($r->cash) echo "\$$r->cash"; + else echo " "; + echo " "; + if($r->scholarship) echo "\$$r->scholarship"; + else echo " "; + echo " $r->number
\n"; + } + + echo "
"; + + echo "".i18n("We will create the following awards with the prizes listed above").":"; + echo "
"; + + foreach($div AS $d_id=>$d_division) + { + foreach($cat AS $c_id=>$c_category) + { + echo i18n($c_category)." - ".i18n($d_division)."
"; + } + } + + echo ""; + echo ""; + echo "
"; + } + + } + send_footer(); +?> diff --git a/admin/award_prizes.php b/admin/award_prizes.php index c81eff97..ea703d51 100644 --- a/admin/award_prizes.php +++ b/admin/award_prizes.php @@ -40,14 +40,25 @@ if($award_awards_id) { - $q=mysql_query("SELECT * FROM award_awards WHERE id='".$award_awards_id."'"); - $award=mysql_fetch_object($q); + if($award_awards_id==-1) + { + $award->name="Generic Prize Template"; + } + else + { + $q=mysql_query("SELECT * FROM award_awards WHERE id='".$award_awards_id."'"); + $award=mysql_fetch_object($q); + } if($_POST['save']=="edit" || $_POST['save']=="add") { if($_POST['save']=="add") { - $q=mysql_query("INSERT INTO award_prizes (award_awards_id,year) VALUES ('$award_awards_id','".$config['FAIRYEAR']."')"); + if($award_awards_id==-1) + $q=mysql_query("INSERT INTO award_prizes (award_awards_id,year) VALUES ('0','-1')"); + else + $q=mysql_query("INSERT INTO award_prizes (award_awards_id,year) VALUES ('$award_awards_id','".$config['FAIRYEAR']."')"); + $id=mysql_insert_id(); } else @@ -135,7 +146,15 @@ echo "".i18n("Add New Prize to %1",array($award->name))."\n"; echo "
"; - $q=mysql_query("SELECT * FROM award_prizes WHERE year='".$config['FAIRYEAR']."' AND award_awards_id='$award_awards_id' ORDER BY `order`"); + if($award_awards_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 year='".$config['FAIRYEAR']."' AND award_awards_id='$award_awards_id' ORDER BY `order`"); + } if(mysql_num_rows($q)) { diff --git a/admin/awards.php b/admin/awards.php index 996a2e21..14ca11f4 100644 --- a/admin/awards.php +++ b/admin/awards.php @@ -33,6 +33,8 @@ echo "Award Sponsors
"; echo "Award Contacts
"; echo "Award Awards
"; + echo "
"; + echo "Create divisional awards for all divisions & categories
"; send_footer();