2007-09-20 17:26:18 +00:00
< ?
//THIS FILE IS NEEDED to fix a bug in the rollover script that some people might have already used
//the prizes werent properly rolled over, so if it detects that there are no prizes this year but there were
//prizes last year, it re-rolls the prizes over properly.
//it only does this if the number of awards matchces exactly (aka hasnt been modified yet since the rollover)
//it is safe to include this script at any point, since it does all the checks required.
//this file will eventually be deleted
//we know the years needed, so hardcode them in
$currentfairyear = 2007 ;
$newfairyear = 2008 ;
2007-09-20 17:31:43 +00:00
//first make sure they have indeed done the rollover...
if ( $config [ 'FAIRYEAR' ] == 2008 )
{
2007-09-20 17:26:18 +00:00
//make sure the number of awards are identical (aka they havent added any new ones)
2024-12-08 07:42:00 +00:00
$nq1 = $pdo -> prepare ( " SELECT * FROM award_awards WHERE year=' $newfairyear ' " );
$nq1 -> execute ();
$nq2 = $pdo -> prepare ( " SELECT * FROM award_awards WHERE year=' $currentfairyear ' " );
$nq2 -> execute ();
if ( $nq1 -> rowCount () == $nq2 -> rowcount ())
2007-09-20 17:26:18 +00:00
{
2024-12-08 07:42:00 +00:00
$npq1 = $pdo -> prepare ( " SELECT * FROM award_prizes WHERE year=' $newfairyear ' " );
$npq1 -> execute ();
$npq2 = $pdo -> prepare ( " SELECT * FROM award_prizes WHERE year=' $currentfairyear ' " );
$npq2 -> execute ();
2007-09-20 17:26:18 +00:00
2024-12-08 07:42:00 +00:00
if ( $npq2 -> rowCount () > 0 && $npq1 -> rowCount () == 0 )
2007-09-20 17:26:18 +00:00
{
echo " <br /> " ;
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. " )) . " <br /> " ;
2024-12-08 07:42:00 +00:00
$stmt = $pdo -> prepare ( " DELETE FROM award_awards WHERE year=' $newfairyear ' " );
$stmt -> execute ();
$stmt = $pdo -> prepare ( " DELETE FROM award_prizes WHERE year=' $newfairyear ' " );
$stmt -> execute ();
$stmt = $pdo -> prepare ( " DELETE FROM award_contacts WHERE year=' $newfairyear ' " );
$stmt -> execute ();
$stmt = $pdo -> prepare ( " DELETE FROM award_types WHERE year=' $newfairyear ' " );
$stmt -> execute ();
$stmt = $pdo -> prepare ( " DELETE FROM award_awards_projectcategories WHERE year=' $newfairyear ' " );
$stmt -> execute ();
$stmt = $pdo -> prepare ( " DELETE FROM award_awards_projectdivisions WHERE year=' $newfairyear ' " );
$stmt -> execute ();
2007-09-20 17:26:18 +00:00
echo i18n ( " Rolling awards " ) . " <br /> " ;
//awards
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_awards WHERE year=' $currentfairyear ' " );
$q -> execute ();
echo $pdo -> errorInfo ();
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ ))
2007-09-20 17:26:18 +00:00
{
2024-12-08 07:42:00 +00:00
$stmt = $pdo -> prepare ( " INSERT INTO award_awards (award_sponsors_id,award_types_id,name,criteria,presenter,`order`,year,excludefromac,cwsfaward) VALUES (
'".$r->award_sponsors_id."' ,
2024-12-17 06:34:35 +00:00
'".$r->award_types_i."' ,
2024-12-08 07:42:00 +00:00
'".$r->name."' ,
'".$r->criteria."' ,
'".$r->presenter."' ,
'".$r->order."' ,
'".$newfairyear."' ,
'".$r->excludefromac."' ,
'".$r->cwsfaward."' ) " );
$award_awards_id = $pdo -> lastInsertId ();
2007-09-20 17:26:18 +00:00
2024-12-08 07:42:00 +00:00
$q2 = $pdo -> prepare ( " SELECT * FROM award_awards_projectcategories WHERE year=' $currentfairyear ' AND award_awards_id=' $r->id ' " );
$q2 -> execute ();
echo $pdo -> errorInfo ();
while ( $r2 = $q2 -> fetch ( PDO :: FETCH_OBJ ))
2007-09-20 17:26:18 +00:00
{
2024-12-08 07:42:00 +00:00
$stmt = $pdo -> prepare ( " INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES (
'".$award_awards_id."' ,
'".$r2->projectcategories_id."' ,
'".$newfairyear."' ) " );
$stmt -> execute ();
2007-09-20 17:26:18 +00:00
}
2024-12-08 07:42:00 +00:00
$q2 = $pdo -> prepare ( " SELECT * FROM award_awards_projectdivisions WHERE year=' $currentfairyear ' AND award_awards_id=' $r->id ' " );
$q2 -> execute ();
echo $pdo -> errorInfo ();
while ( $r2 = $q2 -> fetch ( PDO :: FETCH_OBJ ))
2007-09-20 17:26:18 +00:00
{
2024-12-08 07:42:00 +00:00
$stmt = $pdo -> prepare ( " INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES (
'".$award_awards_id."' ,
'".$r2->projectdivisions_id."' ,
'".$newfairyear."' ) " );
$stmt -> execute ();
2007-09-20 17:26:18 +00:00
}
echo i18n ( " Rolling award prizes " ) . " <br /> " ;
2024-12-08 07:42:00 +00:00
$q2 = $pdo -> prepare ( " SELECT * FROM award_prizes WHERE year=' $currentfairyear ' AND award_awards_id=' $r->id ' " );
$q2 -> execute ();
echo $pdo -> errorInfo ();
while ( $r2 = $q2 -> fetch ( PDO :: FETCH_OBJ ))
2007-09-20 17:26:18 +00:00
{
2024-12-08 07:42:00 +00:00
$stmt = $pdo -> prepare ( " INSERT INTO award_prizes (award_awards_id,cash,scholarship,`value`,prize,number,`order`,year,excludefromac) VALUES (
'".$award_awards_id."' ,
'".$r2->cash."' ,
'".$r2->scholarship."' ,
'".$r2->value."' ,
'".$r2->prize."' ,
'".$r2->number."' ,
'".$r2->order."' ,
'".$newfairyear."' ,
'".$r2->excludefromac."' ) " );
2007-09-20 17:26:18 +00:00
}
}
echo i18n ( " Rolling award contacts " ) . " <br /> " ;
//award contacts
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_contacts WHERE year=' $currentfairyear ' " );
$q -> execute ();
echo $pdo -> errorInfo ();
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ ))
$stmt = $pdo -> prepare ( " INSERT INTO award_contacts (award_sponsors_id,salutation,firstname,lastname,position,email,phonehome,phonework,phonecell,fax,notes,year) VALUES (
'".$r->award_sponsors_id."' ,
'".$r->salutation."' ,
'".$r->firstname."' ,
'".$r->lastname."' ,
'".$r->position."' ,
'".$r->email."' ,
'".$r->phonehome."' ,
'".$r->phonework."' ,
'".$r->phonecell."' ,
'".$r->fax."' ,
'".$r->notes."' ,
'".$newfairyear."' ) " );
2007-09-20 17:26:18 +00:00
echo i18n ( " Rolling award types " ) . " <br /> " ;
//award types
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_types WHERE year=' $currentfairyear ' " );
$q -> execute ();
echo $pdo -> errorInfo ();
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ ))
$stmt = $pdo -> prepare ( " INSERT INTO award_types (id,type,`order`,year) VALUES (
'".$r->id."' ,
'".$r->type."' ,
'".$r->order."' ,
'".$newfairyear."' ) " );
$stmt -> execute ();
2007-09-20 17:26:18 +00:00
}
}
2007-09-20 17:31:43 +00:00
}
2007-09-20 17:26:18 +00:00
?>