forked from science-ation/science-ation
Add judging timeslots
Add emit_date and emit_time functions
This commit is contained in:
parent
2f8921a7a0
commit
917e374f0a
@ -32,7 +32,7 @@
|
||||
echo "<hr />";
|
||||
echo "<a href=\"committees.php\">Committee Management</a> <br />";
|
||||
echo "<a href=\"awards.php\">Awards Management</a> <br />";
|
||||
echo "<a href=\"judges.php\">Judges Management</a> <br />";
|
||||
echo "<a href=\"judges.php\">Judging Management</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"communication.php\">Communication (Send Emails)</a> <br />";
|
||||
|
||||
|
@ -30,7 +30,9 @@
|
||||
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo "<a href=\"judges_teams.php\">Judging Teams</a><br />";
|
||||
echo "<a href=\"judges_teams.php\">".i18n("Manage Judging Teams")."</a><br />";
|
||||
echo "<a href=\"judges_timeslots.php\">".i18n("Manage Judging Timeslots")."</a><br />";
|
||||
echo "<a href=\"judges_teams_projects.php\">".i18n("Assign Projects to Teams")."</a><br />";
|
||||
|
||||
send_footer();
|
||||
|
||||
|
186
admin/judges_timeslots.php
Normal file
186
admin/judges_timeslots.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?
|
||||
/*
|
||||
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('admin');
|
||||
send_header("Judging Timeslots");
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||
echo "<a href=\"judges.php\"><< ".i18n("Back to Judges")."</a>\n";
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
if($_POST['action']=="add" || $_POST['action']=="edit")
|
||||
{
|
||||
$err=0;
|
||||
if($_POST['date_year'] && $_POST['date_month'] && $_POST['date_day'])
|
||||
{
|
||||
$date=$_POST['date_year'] ."-". $_POST['date_month'] ."-". $_POST['date_day'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$err=1;
|
||||
echo error(i18n("Date is required"));
|
||||
}
|
||||
|
||||
if($_POST['starttime_hour'] && $_POST['starttime_minute'])
|
||||
{
|
||||
$starttime=$_POST['starttime_hour'] .":". $_POST['starttime_minute'].":00";
|
||||
}
|
||||
else
|
||||
{
|
||||
$err=1;
|
||||
echo error(i18n("Start Time is required"));
|
||||
}
|
||||
|
||||
if($_POST['endtime_hour'] && $_POST['endtime_minute'])
|
||||
{
|
||||
$endtime=$_POST['endtime_hour'] .":". $_POST['endtime_minute'].":00";
|
||||
}
|
||||
else
|
||||
{
|
||||
$err=1;
|
||||
echo error(i18n("End Time is required"));
|
||||
}
|
||||
|
||||
|
||||
if(!$err)
|
||||
{
|
||||
if($_POST['action']=="add")
|
||||
{
|
||||
mysql_query("INSERT INTO judges_timeslots (date,starttime,endtime,year) VALUES ('$date','$starttime','$endtime','".$config['FAIRYEAR']."')");
|
||||
echo happy(i18n("New timeslot successfully added"));
|
||||
}
|
||||
if($_POST['action']=="edit")
|
||||
{
|
||||
mysql_query("UPDATE judges_timeslots SET `date`='$date', starttime='$starttime', endtime='$endtime' WHERE id='".$_POST['edit']."'");
|
||||
echo mysql_error();
|
||||
echo happy(i18n("Timeslot successfully saved"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: only delete if the timeslot is not in use!!!
|
||||
if($_GET['action']=="delete" && $_GET['delete'])
|
||||
{
|
||||
mysql_query("DELETE FROM judges_timeslots WHERE id='".$_GET['delete']."'");
|
||||
echo happy(i18n("Timeslot successfully removed"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($_GET['action']=="add" || $_GET['action']=="edit")
|
||||
{
|
||||
echo "<form method=\"post\" action=\"judges_timeslots.php\">";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
||||
|
||||
if($_GET['action']=="add")
|
||||
{
|
||||
echo "<h3>Add New Judging Timeslot</h3>";
|
||||
$buttontext=i18n("Add Timeslot");
|
||||
$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date DESC LIMIT 1");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
$r=mysql_fetch_object($q);
|
||||
$date=$r->date;
|
||||
$starttime="";
|
||||
$endtime="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$date=$config['dates']['fairdate'];
|
||||
}
|
||||
|
||||
}
|
||||
else if($_GET['action']=="edit")
|
||||
{
|
||||
echo "<input type=\"hidden\" name=\"edit\" value=\"".$_GET['edit']."\">\n";
|
||||
echo "<h3>Edit Judging Timeslot</h3>";
|
||||
$buttontext=i18n("Save Timeslot");
|
||||
$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' AND id='".$_GET['edit']."'");
|
||||
$r=mysql_fetch_object($q);
|
||||
|
||||
$date=$r->date;
|
||||
$starttime=$r->starttime;
|
||||
$endtime=$r->endtime;
|
||||
}
|
||||
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td>Date:</td><td>";
|
||||
emit_date_selector("date",$date);
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "<tr><td>Start Time:</td><td>";
|
||||
emit_time_selector("starttime",$starttime);
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "<tr><td>End Time:</td><td>";
|
||||
emit_time_selector("endtime",$endtime);
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "<input type=\"submit\" value=\"$buttontext\" />";
|
||||
echo "</form>";
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
echo "<A href=\"judges_timeslots.php?action=add\">".i18n("Add new judging timeslot")."</a><br />";
|
||||
echo "<table class=\"summarytable\">";
|
||||
echo "<tr>";
|
||||
echo "<th>".i18n("Date")."</th>";
|
||||
echo "<th>".i18n("Start Time")."</th>";
|
||||
echo "<th>".i18n("End Time")."</th>";
|
||||
echo "<th>".i18n("Actions")."</th>";
|
||||
echo "</tr>";
|
||||
|
||||
$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date,starttime");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<tr>";
|
||||
// echo "<td>$r->id</td>";
|
||||
echo "<td>$r->date</td>";
|
||||
echo "<td align=\"center\">".substr($r->starttime,0,-3)."</td>";
|
||||
echo "<td align=\"center\">".substr($r->endtime,0,-3)."</td>";
|
||||
|
||||
|
||||
echo " <td align=\"center\">";
|
||||
echo "<a href=\"judges_timeslots.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
|
||||
echo " ";
|
||||
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this timeslot?')\" href=\"judges_timeslots.php?action=delete&delete=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
|
||||
echo " </td>\n";
|
||||
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
send_footer();
|
||||
?>
|
@ -442,6 +442,74 @@ function emit_year_selector($name,$selected="",$min=0,$max=0)
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
function emit_date_selector($name,$selected="")
|
||||
{
|
||||
if($selected)
|
||||
{
|
||||
list($year,$month,$day)=split("-",$selected);
|
||||
}
|
||||
echo "<table cellpadding=0>";
|
||||
echo "<tr><td>";
|
||||
emit_year_selector($name."_year",$year);
|
||||
echo "</td><td>";
|
||||
emit_month_selector($name."_month",$month);
|
||||
echo "</td><td>";
|
||||
emit_day_selector($name."_day",$day);
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
function emit_hour_selector($name,$selected="")
|
||||
{
|
||||
if($selected!="") $selected=(int)$selected;
|
||||
echo "<select name=\"$name\">\n";
|
||||
echo "<option value=\"\">HH</option>\n";
|
||||
|
||||
|
||||
for($x=0;$x<=23;$x++)
|
||||
{
|
||||
if($x===$selected)
|
||||
$sel="selected";
|
||||
else
|
||||
$sel="";
|
||||
echo "<option value=\"$x\" $sel>".sprintf("%02d",$x)."</option>\n";
|
||||
}
|
||||
|
||||
echo "</select>\n";
|
||||
|
||||
|
||||
}
|
||||
function emit_minute_selector($name,$selected="")
|
||||
{
|
||||
$mins=array("00","05","10","15","20","25","30","35","40","45","50","55");
|
||||
echo "<select name=\"$name\">\n";
|
||||
echo "<option value=\"\">MM</option>\n";
|
||||
|
||||
for($x=0;$x<count($mins);$x++)
|
||||
echo "<option value=\"".$mins[$x]."\" ".($selected==$mins[$x]?"selected":"").">$mins[$x]</option>\n";
|
||||
|
||||
echo "</select>\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
function emit_time_selector($name,$selected="")
|
||||
{
|
||||
|
||||
if($selected)
|
||||
{
|
||||
list($hour,$minute,$second)=split(":",$selected);
|
||||
}
|
||||
echo "<table cellpadding=0>";
|
||||
echo "<tr><td>";
|
||||
emit_hour_selector($name."_hour",$hour);
|
||||
echo "</td><td>";
|
||||
emit_minute_selector($name."_minute",$minute);
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
}
|
||||
|
||||
function emit_province_selector($name,$selected="",$extra="")
|
||||
{
|
||||
$q=mysql_query("SELECT * FROM provinces ORDER BY province");
|
||||
|
Loading…
Reference in New Issue
Block a user