forked from science-ation/science-ation
Added the fair year rollover code to go from one year to the next
This commit is contained in:
parent
bd4f8b6739
commit
343c70f633
@ -742,5 +742,10 @@ function email_send($val,$to,$sub_subject=array(),$sub_body=array())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function output_page_text($textname)
|
||||
{
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname'");
|
||||
$r=mysql_fetch_object($q);
|
||||
echo nl2br(i18n($r->text));
|
||||
}
|
||||
?>
|
||||
|
@ -33,6 +33,8 @@
|
||||
echo "<a href=\"divisions.php\">Project Divisons</a> <br />";
|
||||
echo "<a href=\"subdivisions.php\">Project Sub-Divisons</a> <br />";
|
||||
echo "<a href=\"images.php\">Images (Fair Logo)</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"rollover.php\">Rollover Fair Year</a> <br />";
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
246
config/rollover.php
Normal file
246
config/rollover.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
auth_required('config');
|
||||
send_header("Year Rollover");
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
function confirmYearRollover()
|
||||
{
|
||||
var currentyear=<?=$config['FAIRYEAR']?>;
|
||||
var nextyear=document.forms.rollover.nextfairyear.value;
|
||||
if(nextyear<currentyear)
|
||||
alert('You cannot roll backwards in years!');
|
||||
else if(nextyear==currentyear)
|
||||
alert('You cannot roll to the same year!');
|
||||
else
|
||||
{
|
||||
|
||||
var okay=confirm('Are you sure you want to roll the FAIRYEAR from '+currentyear+' to '+nextyear+'? This can not be undone and should only be done if you are absolutely sure!');
|
||||
if(okay)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<?
|
||||
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Configuration")."</a><br />";
|
||||
|
||||
if($_POST['action']=="rollover" && $_POST['nextfairyear'])
|
||||
{
|
||||
$newfairyear=$_POST['nextfairyear'];
|
||||
$currentfairyear=$config['FAIRYEAR'];
|
||||
|
||||
if($newfairyear<$currentfairyear)
|
||||
echo error(i18n("You cannot roll backwards in years!"));
|
||||
else if($newfairyear==$currentfairyear)
|
||||
echo error(i18n("You cannot roll to the same year!"));
|
||||
else
|
||||
{
|
||||
//okay here we go! this is going to get to be a pretty big script me thinks!
|
||||
|
||||
//first, lets do all of the configuration variables
|
||||
echo i18n("Rolling configuration variables")."<br />";
|
||||
$q=mysql_query("SELECT * FROM config WHERE year='$currentfairyear'");
|
||||
echo mysql_error();
|
||||
while($r=mysql_fetch_object($q))
|
||||
mysql_query("INSERT INTO config (var,val,description,year) VALUES (
|
||||
'".mysql_escape_string($r->var)."',
|
||||
'".mysql_escape_string($r->val)."',
|
||||
'".mysql_escape_string($r->description)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
//now the dates
|
||||
echo i18n("Rolling dates")."<br />";
|
||||
$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_escape_string($r->newdate)."',
|
||||
'".mysql_escape_string($r->name)."',
|
||||
'".mysql_escape_string($r->description)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
|
||||
//page text
|
||||
echo i18n("Rolling page texts")."<br />";
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE year='$currentfairyear'");
|
||||
echo mysql_error();
|
||||
while($r=mysql_fetch_object($q))
|
||||
mysql_query("INSERT INTO pagetext (textname,text,year) VALUES (
|
||||
'".mysql_escape_string($r->textname)."',
|
||||
'".mysql_escape_string($r->text)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
echo i18n("Rolling project categories")."<br />";
|
||||
//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,mingrade,maxgrade,year) VALUES (
|
||||
'".mysql_escape_string($r->id)."',
|
||||
'".mysql_escape_string($r->category)."',
|
||||
'".mysql_escape_string($r->mingrade)."',
|
||||
'".mysql_escape_string($r->maxgrade)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
echo i18n("Rolling project divisions")."<br />";
|
||||
//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,year) VALUES (
|
||||
'".mysql_escape_string($r->id)."',
|
||||
'".mysql_escape_string($r->division)."',
|
||||
'".mysql_escape_string($r->division_shortform)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
echo i18n("Rolling project sub-divisions")."<br />";
|
||||
//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_escape_string($r->id)."',
|
||||
'".mysql_escape_string($r->projectsubdivisions_id)."',
|
||||
'".mysql_escape_string($r->subdivision)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
echo i18n("Rolling safety questions")."<br />";
|
||||
//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_escape_string($r->question)."',
|
||||
'".mysql_escape_string($r->type)."',
|
||||
'".mysql_escape_string($r->required)."',
|
||||
'".mysql_escape_string($r->ord)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
|
||||
|
||||
echo i18n("Rolling awards")."<br />";
|
||||
//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) 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)."')");
|
||||
$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")."<br />";
|
||||
$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,prize,number,`order`,year) VALUES (
|
||||
'".mysql_escape_string($award_awards_id)."',
|
||||
'".mysql_escape_string($r2->cash)."',
|
||||
'".mysql_escape_string($r2->scholarship)."',
|
||||
'".mysql_escape_string($r2->prize)."',
|
||||
'".mysql_escape_string($r2->number)."',
|
||||
'".mysql_escape_string($r2->order)."',
|
||||
'".mysql_escape_string($newfairyear)."')");
|
||||
}
|
||||
}
|
||||
|
||||
echo i18n("Rolling award contacts")."<br />";
|
||||
//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,firstname,lastname,email,phonehome,phonework,phonecell,fax,notes,year) VALUES (
|
||||
'".mysql_escape_string($r->award_sponsors_id)."',
|
||||
'".mysql_escape_string($r->firstname)."',
|
||||
'".mysql_escape_string($r->lastname)."',
|
||||
'".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")."<br />";
|
||||
//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)."')");
|
||||
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
echo "<br />";
|
||||
echo "<form name=\"rollover\" method=\"post\" action=\"rollover.php\" onsubmit=\"return confirmYearRollover()\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"rollover\" />";
|
||||
echo i18n("Current Fair Year").": <b>".$config['FAIRYEAR']."</b><br />";
|
||||
$nextfairyear=$config['FAIRYEAR']+1;
|
||||
echo i18n("Next Fair Year").": <input size=\"8\" type=\"text\" name=\"nextfairyear\" value=\"$nextfairyear\" />";
|
||||
echo "<br />";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Rollover Fair Year")."\" />";
|
||||
echo "</form>";
|
||||
|
||||
send_footer();
|
||||
?>
|
@ -1 +1 @@
|
||||
7
|
||||
8
|
||||
|
12
db/db.update.8.php
Normal file
12
db/db.update.8.php
Normal file
@ -0,0 +1,12 @@
|
||||
ALTER TABLE `award_types` CHANGE `id` `id` INT( 10 ) UNSIGNED NOT NULL;
|
||||
ALTER TABLE `award_types` ADD UNIQUE ( id, year );
|
||||
INSERT INTO `award_types` VALUES (1, 'Divisional', 1, -1);
|
||||
INSERT INTO `award_types` VALUES (2, 'Special', 2, -1);
|
||||
INSERT INTO `award_types` VALUES (3, 'Interdisciplinary', 3, -1);
|
||||
INSERT INTO `award_types` VALUES (4, 'Grand', 5, -1);
|
||||
INSERT INTO `award_types` VALUES (5, 'Other', 4, -1);
|
||||
INSERT INTO `award_types` VALUES (1, 'Divisional', 1, 2006);
|
||||
INSERT INTO `award_types` VALUES (2, 'Special', 2, 2006);
|
||||
INSERT INTO `award_types` VALUES (3, 'Interdisciplinary', 3, 2006);
|
||||
INSERT INTO `award_types` VALUES (4, 'Grand', 5, 2006);
|
||||
INSERT INTO `award_types` VALUES (5, 'Other', 4, 2006);
|
@ -122,12 +122,21 @@ if($_POST['action']=="save")
|
||||
else
|
||||
mysql_query("INSERT INTO config (var,val,description,year) VALUES ('$r->var','$r->val','$r->description','".$_POST['fairyear']."')");
|
||||
}
|
||||
|
||||
//copy over the dates defautls
|
||||
$q=mysql_query("SELECT * FROM dates WHERE year='-1'");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
mysql_query("INSERT INTO dates (date,name,description,year) VALUES ('$r->date','$r->name','$r->description','".$_POST['fairyear']."')");
|
||||
}
|
||||
|
||||
//copy over the award_types defautls
|
||||
$q=mysql_query("SELECT * FROM awards_types WHERE year='-1'");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
mysql_query("INSERT INTO award_types (id,type,`order`,year) VALUES ('$r->id','$r->type','$r->order','".$_POST['fairyear']."')");
|
||||
}
|
||||
|
||||
echo "<b>Done!</b><br />";
|
||||
echo "Creating superuser account...";
|
||||
mysql_query("INSERT INTO committees_members (email,emailprivate,password,access_admin,access_config,access_super) VALUES ('".$_POST['email']."','".$_POST['email']."','".$_POST['pass1']."','Y','Y','Y')");
|
||||
|
@ -243,9 +243,7 @@ echo "<table><tr><td>";
|
||||
echo "<h3>".i18n("Registration Instructions")."</h3>";
|
||||
|
||||
//now get the text of special instructions for the bottom of this page:
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='register_participants_main_instructions'");
|
||||
$r=mysql_fetch_object($q);
|
||||
echo nl2br(i18n($r->text));
|
||||
output_page_text("register_participants_main_instructions");
|
||||
|
||||
echo "<br /><br />";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user