From 4c0cc8b3d5d0acd5ad550d8117d15fc807ac8200 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 5 Feb 2009 08:43:37 +0000 Subject: [PATCH] - Remove award_sponsors from the rollover script, they will automatically be handled by the user system (NOTE: make sure we use the users.uid instead of the users.id when linking to award contacts, because the users.id will change each year they login. - Rollover timeslots and rounds - Add a roll() function to simply rolling over simple databases, converted two rollovers to use it, could convert more. --- config/rollover.php | 88 ++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/config/rollover.php b/config/rollover.php index 5e0368ca..0b0d3281 100644 --- a/config/rollover.php +++ b/config/rollover.php @@ -54,6 +54,24 @@ "); + mysql_query("INSERT INTO $table(`year`,$names) VALUES ('$newfairyear'$vals)"); + echo mysql_error(); + } + } + if($_POST['action']=="rollover" && $_POST['nextfairyear']) { $newfairyear=intval($_POST['nextfairyear']); @@ -226,25 +244,6 @@ } } - 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'"); @@ -303,36 +302,35 @@ echo i18n("Rolling registration fee items")."
"; //regfee items - $q=mysql_query("SELECT * FROM regfee_items WHERE year='$currentfairyear'"); - echo mysql_error(); - while($r=mysql_fetch_object($q)) - mysql_query("INSERT INTO regfee_items (`year`,`name`,`description`,`cost`,`per`) VALUES ( - '$newfairyear', - '".mysql_escape_string($r->name)."', - '".mysql_escape_string($r->description)."', - '".mysql_escape_string($r->cost)."', - '".mysql_escape_string($r->per)."')"); - - echo "
"; - echo "
"; + roll($currentfairyear, $newfairyear, 'regfee_items', + array('name','description','cost','per')); //volunteer positions - $q=mysql_query("SELECT * FROM volunteer_positions WHERE year='$currentfairyear'"); - echo mysql_error(); - while($r=mysql_fetch_object($q)) - mysql_query("INSERT INTO volunteer_positions(`year`,`name`,`desc`,`meet_place`,`start`,`end`) VALUES ( - '$newfairyear', - '".mysql_escape_string($r->name)."', - '".mysql_escape_string($r->desc)."', - '".mysql_escape_string($r->meet_place)."', - '".mysql_escape_string($r->start)."', - '".mysql_escape_string($r->end)."')"); - - echo "
"; - echo "
"; - + echo i18n('Rolling volunteer positions')."
"; + roll($currentfairyear, $newfairyear, 'volunteer_positions', + array('name','desc','meet_place','start','end')); + //timeslots and rounds + echo i18n('Rolling judging timeslots and rounds')."
"; + $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='$currentfairyear' AND round_id='0'"); + echo mysql_error(); + while($r=mysql_fetch_assoc($q)) { + $d = $newfairyear - $currentfairyear; + mysql_query("INSERT INTO judges_timeslots (`year`,`round_id`,`type`,`date`,`starttime`,`endtime`,`round_name`) + VALUES ('$newfairyear','0','{$r['type']}',DATE_ADD('{$r['date']}', INTERVAL $d YEAR), + '{$r['starttime']}','{$r['endtime']}','{$r['round_name']}')"); + echo mysql_error(); + $round_id = mysql_insert_id(); + $qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r['id']}'"); + echo mysql_error(); + while($rr=mysql_fetch_assoc($qq)) { + mysql_query("INSERT INTO judges_timeslots (`year`,`round_id`,`type`,`date`,`starttime`,`endtime`) + VALUES ('$newfairyear','$round_id','timeslot',DATE_ADD('{$rr['date']}', INTERVAL $d YEAR), + '{$rr['starttime']}','{$rr['endtime']}')"); + } + } + echo "

"; mysql_query("UPDATE config SET val='$newfairyear' WHERE var='FAIRYEAR' AND year=0"); echo happy(i18n("Fair year has been rolled over from %1 to %2",array($currentfairyear,$newfairyear))); send_footer();