forked from science-ation/science-ation
- 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.
This commit is contained in:
parent
b39072f098
commit
4c0cc8b3d5
@ -54,6 +54,24 @@
|
||||
</script>
|
||||
<?
|
||||
|
||||
function roll($currentfairyear, $newfairyear, $table, $fields)
|
||||
{
|
||||
echo "SELECT * FROM $table WHERE year='$currentfairyear'";
|
||||
$q=mysql_query("SELECT * FROM $table WHERE year='$currentfairyear'");
|
||||
echo mysql_error();
|
||||
$names = '`'.join('`,`', $fields).'`';
|
||||
while($r=mysql_fetch_assoc($q)) {
|
||||
$vals = '';
|
||||
foreach($fields as $f) {
|
||||
$vals .= ",'".mysql_escape_string($r[$f])."'";
|
||||
}
|
||||
|
||||
print("INSERT INTO $table(`year`,$names) VALUES ('$newfairyear'$vals)<br/>");
|
||||
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")."<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,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")."<br />";
|
||||
//award types
|
||||
$q=mysql_query("SELECT * FROM award_types WHERE year='$currentfairyear'");
|
||||
@ -303,36 +302,35 @@
|
||||
|
||||
echo i18n("Rolling registration fee items")."<br />";
|
||||
//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 "<br />";
|
||||
echo "<br />";
|
||||
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 "<br />";
|
||||
echo "<br />";
|
||||
|
||||
echo i18n('Rolling volunteer positions')."<br />";
|
||||
roll($currentfairyear, $newfairyear, 'volunteer_positions',
|
||||
array('name','desc','meet_place','start','end'));
|
||||
|
||||
//timeslots and rounds
|
||||
echo i18n('Rolling judging timeslots and rounds')."<br />";
|
||||
$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 "<br /><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)));
|
||||
send_footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user