From 7f3a0ff528c07011e1f18d4fa3f887417fc01cfb Mon Sep 17 00:00:00 2001 From: james Date: Thu, 20 Sep 2007 17:26:18 +0000 Subject: [PATCH] Add a fix to re-roll award prizes that werent properly rolled over due to the rollover bug in 2.1.0 --- admin/awards.php | 2 + admin/rerollprizes.php | 124 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 admin/rerollprizes.php diff --git a/admin/awards.php b/admin/awards.php index 845a893..14b829e 100644 --- a/admin/awards.php +++ b/admin/awards.php @@ -28,6 +28,8 @@ send_header("Administration - Awards"); echo "<< ".i18n("Back to Administration")."\n"; + require_once("rerollprizes.php"); + echo "
"; echo "
"; echo "Award Sponsors
"; diff --git a/admin/rerollprizes.php b/admin/rerollprizes.php new file mode 100644 index 0000000..2e27d47 --- /dev/null +++ b/admin/rerollprizes.php @@ -0,0 +1,124 @@ +0 && mysql_num_rows($npq1)==0) + { + + + echo "
"; + echo notice(i18n("A BUG WAS IDENTIFIED IN YOUR PREVIOUS YEAR ROLLOVER WHICH CAUSED AWARD PRIZES TO NOT BE ROLLED OVER PROPERLY. THEY ARE NOW BEING RE-ROLLED OVER WITH THE PROPER PRIZE INFORMATION. THIS WILL ONLY HAPPEN ONCE."))."
"; + mysql_query("DELETE FROM award_awards WHERE year='$newfairyear'"); + mysql_query("DELETE FROM award_prizes WHERE year='$newfairyear'"); + mysql_query("DELETE FROM award_contacts WHERE year='$newfairyear'"); + mysql_query("DELETE FROM award_types WHERE year='$newfairyear'"); + mysql_query("DELETE FROM award_awards_projectcategories WHERE year='$newfairyear'"); + mysql_query("DELETE FROM award_awards_projectdivisions WHERE year='$newfairyear'"); + + echo i18n("Rolling awards")."
"; + //awards + $q=mysql_query("SELECT * FROM award_awards WHERE year='$currentfairyear'"); + echo mysql_error(); + while($r=mysql_fetch_object($q)) + { + mysql_query("INSERT INTO award_awards (award_sponsors_id,award_types_id,name,criteria,presenter,`order`,year,excludefromac,cwsfaward) VALUES ( + '".mysql_escape_string($r->award_sponsors_id)."', + '".mysql_escape_string($r->award_types_id)."', + '".mysql_escape_string($r->name)."', + '".mysql_escape_string($r->criteria)."', + '".mysql_escape_string($r->presenter)."', + '".mysql_escape_string($r->order)."', + '".mysql_escape_string($newfairyear)."', + '".mysql_escape_string($r->excludefromac)."', + '".mysql_escape_string($r->cwsfaward)."')"); + $award_awards_id=mysql_insert_id(); + + $q2=mysql_query("SELECT * FROM award_awards_projectcategories WHERE year='$currentfairyear' AND award_awards_id='$r->id'"); + echo mysql_error(); + while($r2=mysql_fetch_object($q2)) + { + mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES ( + '".mysql_escape_string($award_awards_id)."', + '".mysql_escape_string($r2->projectcategories_id)."', + '".mysql_escape_string($newfairyear)."')"); + + } + + $q2=mysql_query("SELECT * FROM award_awards_projectdivisions WHERE year='$currentfairyear' AND award_awards_id='$r->id'"); + echo mysql_error(); + while($r2=mysql_fetch_object($q2)) + { + mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES ( + '".mysql_escape_string($award_awards_id)."', + '".mysql_escape_string($r2->projectdivisions_id)."', + '".mysql_escape_string($newfairyear)."')"); + + } + + echo i18n("  Rolling award prizes")."
"; + $q2=mysql_query("SELECT * FROM award_prizes WHERE year='$currentfairyear' AND award_awards_id='$r->id'"); + echo mysql_error(); + while($r2=mysql_fetch_object($q2)) + { + mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,`value`,prize,number,`order`,year,excludefromac) VALUES ( + '".mysql_escape_string($award_awards_id)."', + '".mysql_escape_string($r2->cash)."', + '".mysql_escape_string($r2->scholarship)."', + '".mysql_escape_string($r2->value)."', + '".mysql_escape_string($r2->prize)."', + '".mysql_escape_string($r2->number)."', + '".mysql_escape_string($r2->order)."', + '".mysql_escape_string($newfairyear)."', + '".mysql_escape_string($r2->excludefromac)."')"); + } + } + + echo i18n("Rolling award contacts")."
"; + //award contacts + $q=mysql_query("SELECT * FROM award_contacts WHERE year='$currentfairyear'"); + echo mysql_error(); + while($r=mysql_fetch_object($q)) + mysql_query("INSERT INTO award_contacts (award_sponsors_id,salutation,firstname,lastname,position,email,phonehome,phonework,phonecell,fax,notes,year) VALUES ( + '".mysql_escape_string($r->award_sponsors_id)."', + '".mysql_escape_string($r->salutation)."', + '".mysql_escape_string($r->firstname)."', + '".mysql_escape_string($r->lastname)."', + '".mysql_escape_string($r->position)."', + '".mysql_escape_string($r->email)."', + '".mysql_escape_string($r->phonehome)."', + '".mysql_escape_string($r->phonework)."', + '".mysql_escape_string($r->phonecell)."', + '".mysql_escape_string($r->fax)."', + '".mysql_escape_string($r->notes)."', + '".mysql_escape_string($newfairyear)."')"); + + echo i18n("Rolling award types")."
"; + //award types + $q=mysql_query("SELECT * FROM award_types WHERE year='$currentfairyear'"); + echo mysql_error(); + while($r=mysql_fetch_object($q)) + mysql_query("INSERT INTO award_types (id,type,`order`,year) VALUES ( + '".mysql_escape_string($r->id)."', + '".mysql_escape_string($r->type)."', + '".mysql_escape_string($r->order)."', + '".mysql_escape_string($newfairyear)."')"); + + } + } +?>