From 4b573c722479fd55f1bd37e8cb79318aaa477247 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 3 Nov 2008 05:05:09 +0000 Subject: [PATCH] Update the rest of the awards system to pull from sponsors instead of award_sponsors --- admin/award_awardcreatedivisional.php | 16 ++++---- admin/award_awards.php | 53 ++++++++++++++------------- admin/sponsors.php | 2 +- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/admin/award_awardcreatedivisional.php b/admin/award_awardcreatedivisional.php index b49d39d..e442aff 100644 --- a/admin/award_awardcreatedivisional.php +++ b/admin/award_awardcreatedivisional.php @@ -32,8 +32,8 @@ 'Awards Main' => 'admin/awards.php') ); - if($_GET['award_sponsors_id']) $award_sponsors_id=$_GET['award_sponsors_id']; - else if($_POST['award_sponsors_id']) $award_sponsors_id=$_POST['award_sponsors_id']; + if($_GET['sponsors_id']) $sponsors_id=$_GET['sponsors_id']; + else if($_POST['sponsors_id']) $sponsors_id=$_POST['sponsors_id']; if($_GET['award_types_id']) $award_types_id=$_GET['award_types_id']; else if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id']; @@ -77,7 +77,7 @@ } - if($_GET['action']=="create" && $_GET['award_sponsors_id']) + if($_GET['action']=="create" && $_GET['sponsors_id']) { $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); $prizes=array(); @@ -106,8 +106,8 @@ $c_category=$cat[$c_id]; 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']}', + mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,`order`,year) VALUES ( + '{$_GET['sponsors_id']}', '1', '$c_category - $d_division', '".i18n("Best %1 projects in the %2 division",array($c_category,$d_division))."', @@ -157,13 +157,13 @@ echo ""; echo "\n"; echo "
".i18n("Sponsor").":"; - $sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); - echo ""; //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)) { - if($sr->id == $award_sponsors_id) + if($sr->id == $sponsors_id) $sel="selected=\"selected\""; else $sel=""; diff --git a/admin/award_awards.php b/admin/award_awards.php index 5b24c37..b6a46c2 100644 --- a/admin/award_awards.php +++ b/admin/award_awards.php @@ -39,8 +39,8 @@ 'Awards Main' => 'admin/awards.php') ); } - if($_GET['award_sponsors_id'] && $_GET['award_sponsors_id']!="all") - $_SESSION['award_sponsors_id']=$_GET['award_sponsors_id']; + if($_GET['sponsors_id'] && $_GET['sponsors_id']!="all") + $_SESSION['sponsors_id']=$_GET['sponsors_id']; if($_GET['award_types_id'] && $_GET['award_types_id']!="all") $_SESSION['award_types_id']=$_GET['award_types_id']; @@ -48,15 +48,15 @@ if($_GET['award_sponsors_confirmed'] && $_GET['award_sponsors_confirmed']!="all") $_SESSION['award_sponsors_confirmed']=$_GET['award_sponsors_confirmed']; - if($_GET['award_sponsors_id']=="all") - unset($_SESSION['award_sponsors_id']); + if($_GET['sponsors_id']=="all") + unset($_SESSION['sponsors_id']); if($_GET['award_types_id']=="all") unset($_SESSION['award_types_id']); if($_GET['award_sponsors_confirmed']=="all") unset($_SESSION['award_sponsors_confirmed']); $award_types_id=$_SESSION['award_types_id']; - $award_sponsors_id=$_SESSION['award_sponsors_id']; + $sponsors_id=$_SESSION['sponsors_id']; $award_sponsors_confirmed=$_SESSION['award_sponsors_confirmed']; if($_POST['save']=="edit" || $_POST['save']=="add") @@ -65,7 +65,7 @@ echo error(i18n("Award Type is required")); $_GET['action']=$_POST['save']; } - else if(!$_POST['award_sponsors_id']) { + else if(!$_POST['sponsors_id']) { echo error(i18n("Award Sponsor is required")); $_GET['action']=$_POST['save']; } @@ -74,7 +74,7 @@ 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']."')"); + $q=mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,year) VALUES ('".$_POST['sponsors_id']."','".$_POST['award_types_id']."','".$config['FAIRYEAR']."')"); $id=mysql_insert_id(); } else @@ -85,7 +85,7 @@ $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']))."', ". + "sponsors_id='".mysql_escape_string(stripslashes($_POST['sponsors_id']))."', ". "award_types_id='".mysql_escape_string(stripslashes($_POST['award_types_id']))."', ". "presenter='".mysql_escape_string(stripslashes($_POST['presenter']))."', ". "excludefromac='".mysql_escape_string(stripslashes($_POST['excludefromac']))."', ". @@ -171,17 +171,17 @@ award_awards.schedule_judges, award_types.id AS award_types_id, award_types.type, - award_sponsors.id AS award_sponsors_id, - award_sponsors.organization + sponsors.id AS sponsors_id, + sponsors.organization FROM award_awards, award_types, - award_sponsors + 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.sponsors_id=sponsors.id AND award_awards.award_types_id=award_types.id "); @@ -195,7 +195,7 @@ echo mysql_error(); $award_awards_description=$r->description; $award_types_id=$r->award_types_id; $award_type=$r->type; - $award_sponsors_id=$r->award_sponsors_id; + $sponsors_id=$r->sponsors_id; $award_sponsor=$r->organization; $award_awards_presenter=$r->presenter; $award_awards_excludefromac=$r->excludefromac; @@ -236,7 +236,7 @@ echo mysql_error(); if($_POST['criteria']) $award_awards_criteria=$_POST['criteria']; if($_POST['description']) $award_awards_criteria=$_POST['description']; if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id']; - if($_POST['award_sponsors_id']) $award_sponsors_id=$_POST['award_sponsors_id']; + if($_POST['sponsors_id']) $sponsors_id=$_POST['sponsors_id']; if($_POST['eligiblecategories']) $currentcategories=$_POST['eligiblecategories']; if($_POST['eligibledivisions']) $currentdivisions=$_POST['eligibledivisions']; if($_POST['presenter']) $award_awards_presenter=$_POST['presenter']; @@ -257,12 +257,12 @@ echo mysql_error(); echo "
".i18n("Order")."(".i18n("presentation order").")
".i18n("Sponsor").""; $sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); - echo ""; //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)) { - if($sr->id == $award_sponsors_id) + if($sr->id == $sponsors_id) $sel="selected=\"selected\""; else $sel=""; @@ -362,12 +362,12 @@ echo mysql_error(); echo "
"; echo ""; echo "
"; - $q=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization"); - echo ""; echo ""; while($r=mysql_fetch_object($q)) { - if($r->id == $award_sponsors_id) + if($r->id == $sponsors_id) { $sel="selected=\"selected\""; $award_sponsors_organization=$r->organization; @@ -397,6 +397,9 @@ echo mysql_error(); 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 "
"; @@ -412,10 +416,10 @@ echo mysql_error(); echo "
"; - echo "".i18n("Add New Award")."\n"; + echo "".i18n("Add New Award")."\n"; echo "
"; - if($award_sponsors_id) $where_asi="AND award_sponsors_id='$award_sponsors_id'"; + 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'"; @@ -427,19 +431,18 @@ echo mysql_error(); award_awards.order, award_awards.award_sources_id, award_types.type, - award_sponsors.organization, - award_sponsors.confirmed + sponsors.organization FROM award_awards, award_types, - award_sponsors + sponsors WHERE award_awards.year='".$config['FAIRYEAR']."' $where_asi $where_ati $where_asc - AND award_awards.award_sponsors_id=award_sponsors.id + 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`"); diff --git a/admin/sponsors.php b/admin/sponsors.php index a999862..07c4b36 100644 --- a/admin/sponsors.php +++ b/admin/sponsors.php @@ -170,7 +170,7 @@ $numr=mysql_fetch_object($numq); $numsponsorships=$numr->num; - $numq=mysql_query("SELECT COUNT(users_id) AS num FROM users_sponsor WHERE sponsors_id='$r->id'"); + $numq=mysql_query("SELECT COUNT(users_id) AS num FROM users_sponsor, users WHERE sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.year='".$config['FAIRYEAR']."'"); $numr=mysql_fetch_object($numq); $numcontacts=$numr->num;