Copyright (C) 2005-2009 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. */ ?> 'committee_main.php', 'SFIAB Configuration' => 'config/index.php') ,"rollover_fair_year" ); ?> "; config_update_variables($newfairyear, $currentfairyear); //now the dates echo i18n("Rolling dates")."
"; $q=mysql_query("SELECT DATE_ADD(date,INTERVAL 365 DAY) AS newdate,name,description FROM dates WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO dates (date,name,description,year) VALUES ( '".mysql_real_escape_string($r->newdate)."', '".mysql_real_escape_string($r->name)."', '".mysql_real_escape_string($r->description)."', '".mysql_real_escape_string($newfairyear)."')"); //page text echo i18n("Rolling page texts")."
"; $q=mysql_query("SELECT * FROM pagetext WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO pagetext (textname,textdescription,text,lastupdate,year,lang) VALUES ( '".mysql_real_escape_string($r->textname)."', '".mysql_real_escape_string($r->textdescription)."', '".mysql_real_escape_string($r->text)."', '".mysql_real_escape_string($r->lastupdate)."', '".mysql_real_escape_string($newfairyear)."', '".mysql_real_escape_string($r->lang)."')"); echo i18n("Rolling project categories")."
"; //project categories $q=mysql_query("SELECT * FROM projectcategories WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO projectcategories (id,category,category_shortform,mingrade,maxgrade,year) VALUES ( '".mysql_real_escape_string($r->id)."', '".mysql_real_escape_string($r->category)."', '".mysql_real_escape_string($r->category_shortform)."', '".mysql_real_escape_string($r->mingrade)."', '".mysql_real_escape_string($r->maxgrade)."', '".mysql_real_escape_string($newfairyear)."')"); echo i18n("Rolling project divisions")."
"; //project divisions $q=mysql_query("SELECT * FROM projectdivisions WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO projectdivisions (id,division,division_shortform,cwsfdivisionid,year) VALUES ( '".mysql_real_escape_string($r->id)."', '".mysql_real_escape_string($r->division)."', '".mysql_real_escape_string($r->division_shortform)."', '".mysql_real_escape_string($r->cwsfdivisionid)."', '".mysql_real_escape_string($newfairyear)."')"); echo i18n("Rolling project category-division links")."
"; //project categories divisions links $q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,year) VALUES ( '".mysql_real_escape_string($r->projectdivisions_id)."', '".mysql_real_escape_string($r->projectcategories_id)."', '".mysql_real_escape_string($newfairyear)."')"); echo i18n("Rolling project sub-divisions")."
"; //project subdivisions $q=mysql_query("SELECT * FROM projectsubdivisions WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO projectsubdivisions (id,projectdivisions_id,subdivision,year) VALUES ( '".mysql_real_escape_string($r->id)."', '".mysql_real_escape_string($r->projectsubdivisions_id)."', '".mysql_real_escape_string($r->subdivision)."', '".mysql_real_escape_string($newfairyear)."')"); echo i18n("Rolling safety questions")."
"; //safety questions $q=mysql_query("SELECT * FROM safetyquestions WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO safetyquestions (question,type,required,ord,year) VALUES ( '".mysql_real_escape_string($r->question)."', '".mysql_real_escape_string($r->type)."', '".mysql_real_escape_string($r->required)."', '".mysql_real_escape_string($r->ord)."', '".mysql_real_escape_string($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)) { /* award_source_fairs_id could be NULL, we want to keep it NULL if it is */ if($r->award_sourcefairs_id == null) $award_source_fairs_id="NULL"; else $award_source_fairs_id="'".mysql_real_escape_string($r->award_source_fairs_id)."'"; mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,description, presenter,`order`,year,excludefromac,cwsfaward,self_nominate,schedule_judges,external_identifier, external_additional_materials,external_register_winners, external_postback,award_source_fairs_id) VALUES ( '".mysql_real_escape_string($r->sponsors_id)."', '".mysql_real_escape_string($r->award_types_id)."', '".mysql_real_escape_string($r->name)."', '".mysql_real_escape_string($r->criteria)."', '".mysql_real_escape_string($r->description)."', '".mysql_real_escape_string($r->presenter)."', '".mysql_real_escape_string($r->order)."', '".mysql_real_escape_string($newfairyear)."', '".mysql_real_escape_string($r->excludefromac)."', '".mysql_real_escape_string($r->cwsfaward)."', '".mysql_real_escape_string($r->self_nominate)."', '".mysql_real_escape_string($r->schedule_judges)."', '".mysql_real_escape_string($r->external_identifier)."', '".mysql_real_escape_string($r->external_postaback)."', '".mysql_real_escape_string($r->external_identifier)."', '".mysql_real_escape_string($r->external_additional_materials)."', '".mysql_real_escape_string($r->external_register_winners)."', $award_source_fairs_id)"); $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_real_escape_string($award_awards_id)."', '".mysql_real_escape_string($r2->projectcategories_id)."', '".mysql_real_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_real_escape_string($award_awards_id)."', '".mysql_real_escape_string($r2->projectdivisions_id)."', '".mysql_real_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,trophystudentkeeper,trophystudentreturn,trophyschoolkeeper,trophyschoolreturn,external_identifier) VALUES ( '".mysql_real_escape_string($award_awards_id)."', '".mysql_real_escape_string($r2->cash)."', '".mysql_real_escape_string($r2->scholarship)."', '".mysql_real_escape_string($r2->value)."', '".mysql_real_escape_string($r2->prize)."', '".mysql_real_escape_string($r2->number)."', '".mysql_real_escape_string($r2->order)."', '".mysql_real_escape_string($newfairyear)."', '".mysql_real_escape_string($r2->excludefromac)."', '".mysql_real_escape_string($r2->trophystudentkeeper)."', '".mysql_real_escape_string($r2->trophystudentreturn)."', '".mysql_real_escape_string($r2->trophyschoolkeeper)."', '".mysql_real_escape_string($r2->trophyschoolreturn)."', '".mysql_real_escape_string($r2->external_identifier)."' )"); } } 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_real_escape_string($r->id)."', '".mysql_real_escape_string($r->type)."', '".mysql_real_escape_string($r->order)."', '".mysql_real_escape_string($newfairyear)."')"); echo i18n("Rolling schools")."
"; //award types $q=mysql_query("SELECT * FROM schools WHERE year='$currentfairyear'"); echo mysql_error(); while($r=mysql_fetch_object($q)) $puid = ($r->principal_uid == null) ? 'NULL' : ("'".intval($r->principal_uid)."'"); $shuid = ($r->sciencehead_uid == null) ? 'NULL' : ("'".intval($r->sciencehead_uid)."'"); mysql_query("INSERT INTO schools (school,schoollang,schoollevel,board,district,phone,fax,address,city,province_code,postalcode,principal_uid,schoolemail,sciencehead_uid,accesscode,lastlogin,junior,intermediate,senior,registration_password,projectlimit,projectlimitper,year) VALUES ( '".mysql_real_escape_string($r->school)."', '".mysql_real_escape_string($r->schoollang)."', '".mysql_real_escape_string($r->schoollevel)."', '".mysql_real_escape_string($r->board)."', '".mysql_real_escape_string($r->district)."', '".mysql_real_escape_string($r->phone)."', '".mysql_real_escape_string($r->fax)."', '".mysql_real_escape_string($r->address)."', '".mysql_real_escape_string($r->city)."', '".mysql_real_escape_string($r->province_code)."', '".mysql_real_escape_string($r->postalcode)."',$puid, '".mysql_real_escape_string($r->schoolemail)."',$shuid, '".mysql_real_escape_string($r->accesscode)."', NULL, '".mysql_real_escape_string($r->junior)."', '".mysql_real_escape_string($r->intermediate)."', '".mysql_real_escape_string($r->senior)."', '".mysql_real_escape_string($r->registration_password)."', '".mysql_real_escape_string($r->projectlimit)."', '".mysql_real_escape_string($r->projectlimitper)."', '".mysql_real_escape_string($newfairyear)."')"); echo i18n("Rolling questions")."
"; $q = mysql_query("SELECT * FROM questions WHERE year='$currentfairyear'"); while($r=mysql_fetch_object($q)) mysql_query("INSERT INTO questions (id,year,section,db_heading,question,type,required,ord) VALUES ( '', '$newfairyear', '".mysql_real_escape_string($r->section)."', '".mysql_real_escape_string($r->db_heading)."', '".mysql_real_escape_string($r->question)."', '".mysql_real_escape_string($r->type)."', '".mysql_real_escape_string($r->required)."', '".mysql_real_escape_string($r->ord)."')"); echo i18n("Rolling registration fee items")."
"; //regfee items roll($currentfairyear, $newfairyear, 'regfee_items', array('name','description','cost','per')); //volunteer positions 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`,`name`) VALUES ('$newfairyear','0','{$r['type']}',DATE_ADD('{$r['date']}', INTERVAL $d YEAR), '{$r['starttime']}','{$r['endtime']}','{$r['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(); exit; } } echo "
"; echo "".i18n("You should consider making a database backup before rolling over, just in case!")."
\n"; echo "
"; echo "
"; echo ""; echo i18n("Current Fair Year").": ".$config['FAIRYEAR']."
"; $nextfairyear=$config['FAIRYEAR']+1; echo i18n("Next Fair Year").": "; echo "
"; echo ""; echo "
"; send_footer(); ?>