Update dates configuration for science olympics

This commit is contained in:
james 2010-06-04 16:45:56 +00:00
parent 36024b63ca
commit b51b4420db

View File

@ -39,7 +39,7 @@ while($r=mysql_fetch_object($q)) {
?>
<script type="text/javascript">
$(document).ready(function() {
$(".date").datepicker({ dateFormat: 'yy-mm-dd', showOn: 'button', buttonText: "<?=i18n("calendar")?>" });
$(".date").datepicker({ dateFormat: 'yy-mm-dd' });
});
</script>
@ -54,7 +54,7 @@ $error_ids = array();
$d = mysql_escape_string(stripslashes($val));
$t =mysql_escape_string(stripslashes($_POST['savetimes'][$key]));
$v="$d $t";
mysql_query("UPDATE dates SET date='$v' WHERE year='".$config['FAIRYEAR']."' AND id='$key'");
mysql_query("UPDATE dates SET date='$v' WHERE year='".$config['FAIRYEAR']."' AND conferences_id='".$conference['id']."' AND id='$key'");
}
}
echo happy(i18n("Dates successfully saved"));
@ -63,10 +63,10 @@ $error_ids = array();
echo "<form method=\"post\" action=\"dates.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>";
echo "<tr><td colspan=\"3\"><h3>".i18n("Dates for fair year %1",array($config['FAIRYEAR']),array("fair year"))."</h3></td></tr>";
echo "<tr><td colspan=\"3\"><h3>".i18n("Dates for %1",array($conference['name']),array("conference name"))."</h3></td></tr>";
/* List the dates in the order we would like them to appear */
$dates = array('fairdate' => array() ,
$possibledates['sciencefair'] = array('fairdate' => array() ,
'regopen' => array(),
'regclose' => array(),
'postparticipants' => array(),
@ -77,9 +77,27 @@ $dates = array('fairdate' => array() ,
'specawardregopen' => array(),
'specawardregclose' => array());
$possibledates['scienceolympics'] = array('fairdate' => array() ,
'regopen' => array(),
'regclose' => array(),
'postparticipants' => array(),
'postwinners' => array());
$dates=$possibledates[$conference['type']];
/* Now copy the SQL data into the above array */
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."' ORDER BY date");
if($conference['id']>0) {
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."' ORDER BY date");
}
else {
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."' ORDER BY date");
}
while($r=mysql_fetch_object($q)) {
//check if its a date we dont care about
if(!is_array($dates[$r->name]))
continue;
$dates[$r->name]['description'] = $r->description;
$dates[$r->name]['id'] = $r->id;
$dates[$r->name]['date'] = $r->date;
@ -124,11 +142,12 @@ foreach($dates as $dn=>$d) {
if(!$d['id']) {
$def=$defaultdates[$dn];
//hmm if we dont have a record for this date this year, INSERT the sql from the default
mysql_query("INSERT INTO dates (date,name,description,year) VALUES (
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
'".mysql_real_escape_string($def->date)."',
'".mysql_real_escape_string($dn)."',
'".mysql_real_escape_string($def->description)."',
'".$config['FAIRYEAR']."'
'".$config['FAIRYEAR']."',
'".$conference['id']."'
)");
$d['id']=mysql_insert_id();
$d['description']=$def->description;