Merge all changes from branch r1284:1498 into trunk

This commit is contained in:
james 2009-09-09 00:26:12 +00:00
parent 64d3d6022f
commit f963dbf276
121 changed files with 8359 additions and 4479 deletions

7
TODO
View File

@ -1,3 +1,10 @@
- Make auto-logout on email address change work properly on the FIRST submit, not on first action after the submit
- same for judges changing email address
testing commit emails
test two
test three
test four
test five
test six
test seven

View File

@ -32,8 +32,8 @@
'Awards Main' => 'admin/awards.php')
);
if($_GET['award_sponsors_id']) $award_sponsors_id=$_GET['award_sponsors_id'];
else if($_POST['award_sponsors_id']) $award_sponsors_id=$_POST['award_sponsors_id'];
if($_GET['sponsors_id']) $sponsors_id=$_GET['sponsors_id'];
else if($_POST['sponsors_id']) $sponsors_id=$_POST['sponsors_id'];
if($_GET['award_types_id']) $award_types_id=$_GET['award_types_id'];
else if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id'];
@ -77,7 +77,7 @@
}
if($_GET['action']=="create" && $_GET['award_sponsors_id'])
if($_GET['action']=="create" && $_GET['sponsors_id'])
{
$q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`");
$prizes=array();
@ -106,8 +106,8 @@
$c_category=$cat[$c_id];
echo i18n("Creating %1 - %2",array($c_category,$d_division))."<br />";
mysql_query("INSERT INTO award_awards (award_sponsors_id,award_types_id,name,criteria,`order`,year) VALUES (
'{$_GET['award_sponsors_id']}',
mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,`order`,year) VALUES (
'{$_GET['sponsors_id']}',
'1',
'$c_category - $d_division',
'".i18n("Best %1 projects in the %2 division",array($c_category,$d_division))."',
@ -157,13 +157,13 @@
echo "<table>";
echo "<tr><td>".i18n("Sponsor").":</td><td>";
$sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization");
echo "<select name=\"award_sponsors_id\">";
$sq=mysql_query("SELECT id,organization FROM sponsors ORDER BY organization");
echo "<select name=\"sponsors_id\">";
//only show the "choose a sponsor" option if we are adding,if we are editing, then they must have already chosen one.
echo $firstsponsor;
while($sr=mysql_fetch_object($sq))
{
if($sr->id == $award_sponsors_id)
if($sr->id == $sponsors_id)
$sel="selected=\"selected\"";
else
$sel="";

View File

@ -22,10 +22,99 @@
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
switch($_GET['action']) {
case 'getawardinfo':
$id = intval($_GET['id']);
$q=mysql_query("SELECT award_awards.id,
award_awards.name,
award_awards.criteria,
award_awards.description,
award_awards.order,
award_awards.presenter,
award_awards.excludefromac,
award_awards.cwsfaward,
award_awards.self_nominate,
award_awards.schedule_judges,
award_types.id AS award_types_id,
award_types.type,
sponsors.id AS sponsors_id,
sponsors.organization
FROM
award_awards,
award_types,
sponsors
WHERE
award_awards.id='$id'
AND award_awards.sponsors_id=sponsors.id
AND award_awards.award_types_id=award_types.id
");
echo mysql_error();
$r = mysql_fetch_assoc($q);
$ret = array();
$ret['id'] = $r['id'];
$ret['name'] = $r['name'];
$ret['order'] = $r['order'];
$ret['criteria'] = $r['criteria'];
$ret['description'] = $r['description'];
$ret['presenter'] = $r['presenter'];
$ret['award_types_id'] = $r['award_types_id'];
$ret['sponsors_id'] = $r['sponsors_id'];
$ret['excludefromac'] = $r['excludefromac'];
$ret['cwsfaward'] = $r['cwsfaward'];
$ret['self_nominate'] = $r['self_nominate'];
$ret['schedule_judges'] = $r['schedule_judges'];
echo json_encode($ret);
exit;
case 'saveawardinfo':
print_r($_POST);
/*
$r=mysql_fetch_object($q);
$award_awards_id=$r->id;
$award_awards_name=$r->name;
$award_awards_order=$r->order;
$award_awards_criteria=$r->criteria;
$award_awards_description=$r->description;
$award_types_id=$r->award_types_id;
$award_type=$r->type;
$sponsors_id=$r->sponsors_id;
$award_sponsor=$r->organization;
$award_awards_presenter=$r->presenter;
$award_awards_excludefromac=$r->excludefromac;
$award_awards_cwsfaward=$r->cwsfaward;
$award_awards_self_nominate=$r->self_nominate;
$award_awards_schedule_judges=$r->schedule_judges;*/
exit;
case 'geteligibility':
$id = intval($_GET['id']);
//select the current categories that this award is linked to
$reg = array();
$q=mysql_query("SELECT * FROM award_awards_projectcategories WHERE award_awards_id='$id'");
while($r=mysql_fetch_assoc($q)) {
$ret['categories'][] = $r['projectcategories_id'];
}
//select the current categories that this award is linked to
$q=mysql_query("SELECT * FROM award_awards_projectdivisions WHERE award_awards_id='$id'");
while($r=mysql_fetch_assoc($q)) {
$ret['divisions'][] = $r['projectdivisions_id'];
}
echo json_encode($ret);
exit;
case 'orderprizes':
foreach ($_GET['listItem'] as $position => $item) {
$sql[] = "UPDATE `table` SET `position` = $position WHERE `id` = $item";
}
print_r($sql);
exit;
}
if($_GET['action']=="edit" || $_GET['action']=="add") {
send_header(($_GET['action']=="edit") ? "Edit Award" : "Add Award",
array('Committee Main' => 'committee_main.php',
@ -39,33 +128,249 @@
'Awards Main' => 'admin/awards.php') );
}
if($_GET['award_sponsors_id'] && $_GET['award_sponsors_id']!="all")
$_SESSION['award_sponsors_id']=$_GET['award_sponsors_id'];
if($_GET['sponsors_id'] && $_GET['sponsors_id']!="all")
$_SESSION['sponsors_id']=$_GET['sponsors_id'];
else if($_GET['sponsors_id']=="all")
unset($_SESSION['sponsors_id']);
if($_GET['award_types_id'] && $_GET['award_types_id']!="all")
$_SESSION['award_types_id']=$_GET['award_types_id'];
else if($_GET['award_types_id']=="all")
unset($_SESSION['award_types_id']);
/*
if($_GET['award_sponsors_confirmed'] && $_GET['award_sponsors_confirmed']!="all")
$_SESSION['award_sponsors_confirmed']=$_GET['award_sponsors_confirmed'];
if($_GET['award_sponsors_id']=="all")
unset($_SESSION['award_sponsors_id']);
if($_GET['sponsors_id']=="all")
unset($_SESSION['sponsors_id']);
if($_GET['award_types_id']=="all")
unset($_SESSION['award_types_id']);
if($_GET['award_sponsors_confirmed']=="all")
unset($_SESSION['award_sponsors_confirmed']);
*/
$award_types_id=$_SESSION['award_types_id'];
$award_sponsors_id=$_SESSION['award_sponsors_id'];
$award_sponsors_confirmed=$_SESSION['award_sponsors_confirmed'];
$sponsors_id=$_SESSION['sponsors_id'];
//$award_sponsors_confirmed=$_SESSION['award_sponsors_confirmed'];
if($_POST['save']=="edit" || $_POST['save']=="add")
{
function popup_begin($name, $title, $width=0, $height=0)
{
$size= $width ? "style=\"width:$width%; height:$height%\"" : '';
echo "<div id=\"popup_{$name}_background\" class=\"popup_background\"></div>";
echo "<div id=\"popup_$name\" class=\"popup\" $size>
<a id=\"popup_{$name}_close\" class=\"popup_close\">x</a>
<h1>{$title}</h1>
<p id=\"popup_{$name}_body\" class=\"popup_body\">";
}
function popup_end()
{
echo "</p></div>";
}
require_once('../htabs.inc.php');
?>
<script type="text/javascript">
var award_id = 0;
function popup_editor(id)
{
award_id = id;
popup_open("editor");
htabs_open("editortabs");
}
function update_awardinfo()
{
var id = award_id;
// alert("id="+award_id);
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=getawardinfo&id="+id,
function(json){
$("#awardinfo_name").val(json.name);
$("#awardinfo_order").val(json.order);
$("#awardinfo_sponsors_id").val(json.sponsors_id);
$("#awardinfo_presenter").val(json.presenter);
$("#awardinfo_description").val(json.description);
$("#awardinfo_criteria").val(json.criteria);
$("#awardinfo_award_types_id").val(json.award_types_id);
// For some reason, with checkboxes, these have to be arrays
$("#awardinfo_excludefromac").val([json.excludefromac]);
$("#awardinfo_cwsfaward").val([json.cwsfaward]);
$("#awardinfo_selfnominate").val([json.self_nominate]);
$("#awardinfo_schedulejudges").val([json.schedule_judges]);
});
}
function save_awardinfo()
{
$.post("<?$_SERVER['PHP_SELF']?>?action=saveawardinfo", $("#awardinfo").serialize());
return 0;
}
function update_eligibility()
{
var id = award_id;
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=geteligibility&id="+id,
function(json){
$("[name=eligiblecategories]").val(json.categories);
$("[name=eligibledivisions]").val(json.divisions);
});
}
// When the document is ready set up our sortable with it's inherant function(s)
$(document).ready(function() {
$("#test-list").sortable({
handle : '.handle',
update : function () {
var order = $('#test-list').sortable('serialize');
$("#info").load("<?=$_SERVER['PHP_SELF']?>?action=orderprizes&order="+order);
}
});
});
</script>
<?
popup_begin('editor', "Award Editor", 80, 80);
htabs_begin('editortabs', array('awardinfo' => array('label' =>'Award',
'title' => 'Award Info',
'callback' => 'update_awardinfo'),
'eligibility' => array('label' =>'Eligibility',
'title' => 'Eligibility',
'callback' => 'update_eligibility'),
'prizes'=> array('label' => 'Prizes',
'title' => 'Prizes',
'callback' => ''),
),'awardinfo');
htabs_tab_begin('awardinfo');
echo "<form id=\"awardinfo\">";
echo "<table class=\"tableedit\">\n";
// echo "<tr><td class=\"left\"><hr /></td><td class=\"right\"><hr /></td></tr>\n";
echo "<tr><td class=\"left\">".i18n("Name").":</td><td class=\"right\"><input type=\"text\" id=\"awardinfo_name\" name=\"name\" value=\"Loading...\" size=\"50\" maxlength=\"128\"><script type=\"text/javascript\">translateButton('name');</script></td></tr>\n";
echo "<tr><td class=\"left\">".i18n("Order").":</td><td class=\"right\"><input type=\"text\" id=\"awardinfo_order\" name=\"order\" value=\"\" size=\"5\" maxlength=\"5\" />(".i18n("presentation order").")</td></tr>\n";
echo "<tr><td class=\"left\">".i18n("Sponsor").":</td><td class=\"right\">";
$sq=mysql_query("SELECT id,organization FROM sponsors ORDER BY organization");
echo "<select id=\"awardinfo_sponsors_id\" name=\"sponsors_id\">";
//only show the "choose a sponsor" option if we are adding,if we are editing, then they must have already chosen one.
echo $firstsponsor;
while($sr=mysql_fetch_object($sq)) {
echo "<option value=\"$sr->id\">".i18n($sr->organization)."</option>";
}
echo "</select></td></tr>";
echo "<tr><td class=\"left\">".i18n("Presenter").":</td><td class=\"right\"><input type=\"text\" id=\"awardinfo_presenter\" name=\"presenter\" value=\"Loading...\" size=\"50\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><td class=\"left\">".i18n("Type").":</td><td class=\"right\">";
$tq=mysql_query("SELECT id,type FROM award_types WHERE year='{$config['FAIRYEAR']}' ORDER BY type");
echo "<select id=\"awardinfo_award_types_id\" name=\"award_types_id\">";
//only show the "choose a type" option if we are adding,if we are editing, then they must have already chosen one.
echo $firsttype;
while($tr=mysql_fetch_object($tq)) {
echo "<option value=\"$tr->id\">".i18n($tr->type)."</option>";
}
echo "</select>";
echo "</td></tr>";
echo "<tr><td class=\"left\">".i18n("Criteria").":</td><td class=\"right\"><textarea id=\"awardinfo_criteria\" name=\"criteria\" rows=\"3\" cols=\"50\">Loading...</textarea><script type=\"text/javascript\">translateButton('criteria');</script></td></tr>\n";
echo "<tr><td class=\"left\">".i18n("Description").":</td><td class=\"right\"><textarea id=\"awardinfo_description\" name=\"description\" rows=\"3\" cols=\"50\">Loading...</textarea><script type=\"text/javascript\">translateButton('description');</script></td></tr>\n";
echo "</table>";
echo "<h1>Options</h1>";
echo '<table class="tableedit">';
echo "<tr><td class=\"left\">";
echo "<input type=\"checkbox\" id=\"awardinfo_excludefromac\" name=\"excludefromac\" value=\"1\"></td><td class=\"right\">".i18n("Exclude this award from the award ceremony script")."</td></tr>";
echo "<tr><td class=\"left\">";
echo "<input type=\"checkbox\" id=\"awardinfo_cwsfaward\" name=\"cwsfaward\" value=\"1\"></td><td class=\"right\">".i18n("This award identifies the students that will be attending the Canada-Wide Science Fair")."</td></tr>";
echo "<tr><td class=\"left\">";
echo "<input type=\"checkbox\" id=\"awardinfo_selfnominate\" name=\"self_nominate\" value=\"yes\"></td><td class=\"right\">".i18n("Students can self-nominate for this award (this is usually checked for special awards)")."</td></tr>";
echo "<tr><td class=\"left\">";
echo "<input type=\"checkbox\" id=\"awardinfo_schedulejudges\" name=\"schedule_judges\" value=\"yes\"></td><td class=\"right\">".i18n("Allow the Automatic Judge Scheduler to assign judges to this award (usually checked)")."</td></tr>";
echo "</table>";
echo "</form>";
echo "<input type=\"submit\" onClick=\"save_awardinfo();\" value=\"Save\" />\n";
htabs_tab_end();
htabs_tab_begin('eligibility');
echo "<table class=\"tableedit\">";
echo "<tr><td class=\"left\">".i18n("Age Categories").":</td><td class=\"right\">";
// if(count($currentcategories)==0) $class="class=\"error\""; else $class="";
//now select all the categories so we can list them all
$cq=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY mingrade");
echo mysql_error();
while($cr=mysql_fetch_object($cq)) {
echo "<input type=\"checkbox\" id=\"eligibility_categories_{$cr->id}\" name=\"eligiblecategories\" value=\"$cr->id\" />".i18n($cr->category)."<br />";
}
echo "</td></tr>";
echo "<tr><td class=\"left\">".i18n("Divisions").":</td><td class=\"right\">";
$dq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
echo mysql_error();
while($dr=mysql_fetch_object($dq)) {
echo "<input type=\"checkbox\" id=\"eligibility_divisions_{$dr->id}\" name=\"eligibledivisions\" value=\"$dr->id\" />".i18n($dr->division)."<br />";
}
echo "</td>";
echo "</tr>";
// if(count($currentcategories)==0 || count($currentdivisions)==0)
// echo "<tr><td colspan=\"2\" class=\"error\">".i18n("At least one age category and one division must be selected")."</td></tr>";
echo "</table>";
htabs_tab_end();
htabs_tab_begin('prizes');
?>
<pre>
<div id="info">Waiting for update</div>
</pre>
<ul id="test-list">
<li id="listItem_1">
<img src="arrow.png" alt="move" width="16" height="16" class="handle" />
<strong>Item 1 </strong>with a link to <a href="http://www.google.co.uk/" rel="nofollow">Google</a>
</li>
<li id="listItem_2">
<img src="arrow.png" alt="move" width="16" height="16" class="handle" />
<strong>Item 2</strong>
</li>
<li id="listItem_3">
<img src="arrow.png" alt="move" width="16" height="16" class="handle" />
<strong>Item 3</strong>
</li>
<li id="listItem_4">
<img src="arrow.png" alt="move" width="16" height="16" class="handle" />
<strong>Item 4</strong>
</li>
</ul>
<?
htabs_tab_end();
htabs_end();
popup_end();
if($_POST['save']=="edit" || $_POST['save']=="add")
{
if(!$_POST['award_types_id']) {
echo error(i18n("Award Type is required"));
$_GET['action']=$_POST['save'];
}
else if(!$_POST['award_sponsors_id']) {
else if(!$_POST['sponsors_id']) {
echo error(i18n("Award Sponsor is required"));
$_GET['action']=$_POST['save'];
}
@ -74,7 +379,7 @@
if($_POST['save']=="add")
{
$q=mysql_query("INSERT INTO award_awards (award_sponsors_id,award_types_id,year) VALUES ('".$_POST['award_sponsors_id']."','".$_POST['award_types_id']."','".$config['FAIRYEAR']."')");
$q=mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,year) VALUES ('".$_POST['sponsors_id']."','".$_POST['award_types_id']."','".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
}
else
@ -85,7 +390,7 @@
$exec="UPDATE award_awards SET ".
"name='".mysql_escape_string(stripslashes($_POST['name']))."', ".
"`order`='".mysql_escape_string(stripslashes($_POST['order']))."', ".
"award_sponsors_id='".mysql_escape_string(stripslashes($_POST['award_sponsors_id']))."', ".
"sponsors_id='".mysql_escape_string(stripslashes($_POST['sponsors_id']))."', ".
"award_types_id='".mysql_escape_string(stripslashes($_POST['award_types_id']))."', ".
"presenter='".mysql_escape_string(stripslashes($_POST['presenter']))."', ".
"excludefromac='".mysql_escape_string(stripslashes($_POST['excludefromac']))."', ".
@ -171,17 +476,17 @@
award_awards.schedule_judges,
award_types.id AS award_types_id,
award_types.type,
award_sponsors.id AS award_sponsors_id,
award_sponsors.organization
sponsors.id AS sponsors_id,
sponsors.organization
FROM
award_awards,
award_types,
award_sponsors
sponsors
WHERE
award_awards.year='".$config['FAIRYEAR']."'
AND award_awards.id='".$_GET['edit']."'
AND award_awards.award_sponsors_id=award_sponsors.id
AND award_awards.sponsors_id=sponsors.id
AND award_awards.award_types_id=award_types.id
");
@ -195,7 +500,7 @@ echo mysql_error();
$award_awards_description=$r->description;
$award_types_id=$r->award_types_id;
$award_type=$r->type;
$award_sponsors_id=$r->award_sponsors_id;
$sponsors_id=$r->sponsors_id;
$award_sponsor=$r->organization;
$award_awards_presenter=$r->presenter;
$award_awards_excludefromac=$r->excludefromac;
@ -236,7 +541,7 @@ echo mysql_error();
if($_POST['criteria']) $award_awards_criteria=$_POST['criteria'];
if($_POST['description']) $award_awards_criteria=$_POST['description'];
if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id'];
if($_POST['award_sponsors_id']) $award_sponsors_id=$_POST['award_sponsors_id'];
if($_POST['sponsors_id']) $sponsors_id=$_POST['sponsors_id'];
if($_POST['eligiblecategories']) $currentcategories=$_POST['eligiblecategories'];
if($_POST['eligibledivisions']) $currentdivisions=$_POST['eligibledivisions'];
if($_POST['presenter']) $award_awards_presenter=$_POST['presenter'];
@ -256,13 +561,13 @@ echo mysql_error();
echo "<tr><td>".i18n("Name")."</td><td><input type=\"text\" id=\"name\" name=\"name\" value=\"".htmlspecialchars($award_awards_name)."\" size=\"50\" maxlength=\"128\" /><script type=\"text/javascript\">translateButton('name');</script></td></tr>\n";
echo "<tr><td>".i18n("Order")."</td><td><input type=\"text\" name=\"order\" value=\"".htmlspecialchars($award_awards_order)."\" size=\"5\" maxlength=\"5\" />(".i18n("presentation order").")</td></tr>\n";
echo "<tr><td>".i18n("Sponsor")."</td><td>";
$sq=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization");
echo "<select name=\"award_sponsors_id\">";
$sq=mysql_query("SELECT id,organization FROM sponsors ORDER BY organization");
echo "<select name=\"sponsors_id\">";
//only show the "choose a sponsor" option if we are adding,if we are editing, then they must have already chosen one.
echo $firstsponsor;
while($sr=mysql_fetch_object($sq))
{
if($sr->id == $award_sponsors_id)
if($sr->id == $sponsors_id)
$sel="selected=\"selected\"";
else
$sel="";
@ -362,15 +667,15 @@ echo mysql_error();
echo "<form method=\"get\" action=\"award_awards.php\" name=\"filterchange\">";
echo "<table><tr><td colspan=\"2\">";
$q=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization");
echo "<select name=\"award_sponsors_id\" onchange=\"document.forms.filterchange.submit()\">";
$q=mysql_query("SELECT id,organization FROM sponsors ORDER BY organization");
echo "<select name=\"sponsors_id\" onchange=\"document.forms.filterchange.submit()\">";
echo "<option value=\"all\">".i18n("All Sponsors")."</option>";
while($r=mysql_fetch_object($q))
{
if($r->id == $award_sponsors_id)
if($r->id == $sponsors_id)
{
$sel="selected=\"selected\"";
$award_sponsors_organization=$r->organization;
$sponsors_organization=$r->organization;
}
else
$sel="";
@ -397,6 +702,9 @@ echo mysql_error();
echo "</select>";
echo "</td><td>";
/*
//FIXME: 'confirmed' no longer exists, we need to lookup their sponsorship record and check the status there, either pending, confirmed or received, dunno if it makes sense to put that here or not..
echo "<select name=\"award_sponsors_confirmed\" onchange=\"document.forms.filterchange.submit()\">";
if($award_sponsors_confirmed=="all") $sel="selected=\"selected\""; else $sel="";
echo "<option value=\"all\">".i18n("Any Status")."</option>";
@ -405,6 +713,7 @@ echo mysql_error();
if($award_sponsors_confirmed=="no") $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"no\">".i18n("Unconfirmed Only")."</option>";
echo "</select>";
*/
echo "</form>";
echo "</td></tr>";
echo "</table>";
@ -412,12 +721,12 @@ echo mysql_error();
echo "<br />";
echo "<a href=\"award_awards.php?award_sponsors_id=$award_sponsors_id&award_types_id=$award_types_id&action=add\">".i18n("Add New Award")."</a>\n";
echo "<a href=\"award_awards.php?sponsors_id=$sponsors_id&award_types_id=$award_types_id&action=add\">".i18n("Add New Award")."</a>\n";
echo "<br />";
if($award_sponsors_id) $where_asi="AND award_sponsors_id='$award_sponsors_id'";
if($sponsors_id) $where_asi="AND sponsors_id='$sponsors_id'";
if($award_types_id) $where_ati="AND award_types_id='$award_types_id'";
if($award_sponsors_confirmed) $where_asc="AND award_sponsors.confirmed='$award_sponsors_confirmed'";
// if($award_sponsors_confirmed) $where_asc="AND award_sponsors.confirmed='$award_sponsors_confirmed'";
if(!$orderby) $orderby="order";
@ -425,21 +734,20 @@ echo mysql_error();
award_awards.id,
award_awards.name,
award_awards.order,
award_awards.award_sources_id,
award_awards.award_source_fairs_id,
award_types.type,
award_sponsors.organization,
award_sponsors.confirmed
sponsors.organization
FROM
award_awards,
award_types,
award_sponsors
sponsors
WHERE
award_awards.year='".$config['FAIRYEAR']."'
$where_asi
$where_ati
$where_asc
AND award_awards.award_sponsors_id=award_sponsors.id
AND award_awards.sponsors_id=sponsors.id
AND award_awards.award_types_id=award_types.id
AND award_types.year='".$config['FAIRYEAR']."'
ORDER BY `$orderby`");
@ -465,12 +773,12 @@ echo mysql_error();
$hasexternal=false;
while($r=mysql_fetch_object($q))
{
if($r->award_sources_id){ $cl="class=\"externalaward\""; $hasexternal=true; } else $cl="";
if($r->award_source_fairs_id){ $cl="class=\"externalaward\""; $hasexternal=true; } else $cl="";
echo "<tr $cl>\n";
echo " <td><input type=\"text\" name=\"reorder[$r->id]\" value=\"$r->order\" size=\"3\" /></td>\n";
echo " <td>$r->organization</td>\n";
echo " <td>$r->type</td>\n";
echo " <td>$r->name</td>\n";
echo " <td><a onclick=\"popup_editor({$r->id});\">$r->name</a></td>\n";
$numq=mysql_query("SELECT COUNT(id) AS num FROM award_prizes WHERE award_awards_id='$r->id'");
$numr=mysql_fetch_object($numq);

View File

@ -1,230 +0,0 @@
<?
/*
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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Award Contacts",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php',
'Awards Sponsors' => 'admin/award_sponsors.php'));
if($_GET['award_sponsors_id'])
$award_sponsors_id=$_GET['award_sponsors_id'];
else if($_POST['award_sponsors_id'])
$award_sponsors_id=$_POST['award_sponsors_id'];
?>
<?
$q=mysql_query("SELECT id,organization FROM award_sponsors ORDER BY organization");
echo "<form method=\"get\" action=\"award_contacts.php\" name=\"sponsorchange\">";
echo "<select name=\"award_sponsors_id\" onchange=\"document.forms.sponsorchange.submit()\">";
echo "<option value=\"\">".i18n("Choose a sponsor to view contacts")."</option>";
while($r=mysql_fetch_object($q))
{
if($r->id == $award_sponsors_id)
{
$sel="selected=\"selected\"";
$award_sponsors_organization=$r->organization;
}
else
$sel="";
echo "<option $sel value=\"$r->id\">".i18n($r->organization)."</option>";
}
echo "</select>";
echo "</form>";
if($award_sponsors_id)
{
if($_POST['save']=="edit" || $_POST['save']=="add")
{
$p = ($_POST['primary']=='yes')?'yes':'no';
if($_POST['save']=="add")
{
$q=mysql_query("INSERT INTO award_contacts (award_sponsors_id,year) VALUES ('$award_sponsors_id','".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
}
else
$id=intval($_POST['id']);
if($p == 'no') {
/* Make sure this sponsor ($award_sponsors_id) has a primary */
$q = mysql_query("SELECT id FROM award_contacts WHERE
award_sponsors_id='$award_sponsors_id'
AND year={$config['FAIRYEAR']}
AND `primary`='yes'
AND id!='$id'");
if(mysql_num_rows($q) == 0) {
/* This must be the primary */
$p = 'yes';
}
} else {
/* Unset all other primaries */
mysql_query("UPDATE award_contacts SET `primary`='no'
WHERE award_sponsors_id='$award_sponsors_id'
AND year={$config['FAIRYEAR']}");
}
$exec="UPDATE award_contacts SET ".
"salutation='".mysql_escape_string(stripslashes($_POST['salutation']))."', ".
"firstname='".mysql_escape_string(stripslashes($_POST['firstname']))."', ".
"lastname='".mysql_escape_string(stripslashes($_POST['lastname']))."', ".
"position='".mysql_escape_string(stripslashes($_POST['position']))."', ".
"phonework='".mysql_escape_string(stripslashes($_POST['phonework']))."', ".
"phonecell='".mysql_escape_string(stripslashes($_POST['phonecell']))."', ".
"phonehome='".mysql_escape_string(stripslashes($_POST['phonehome']))."', ".
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
"email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
"notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ".
"`primary`='$p' ".
"WHERE id='$id'";
mysql_query($exec);
if($_POST['save']=="add")
echo happy("Contact successfully added");
else
echo happy("Successfully saved changes to contact");
}
if($_GET['action']=="delete" && $_GET['delete'])
{
mysql_query("DELETE FROM award_contacts WHERE id='".$_GET['delete']."'");
echo happy("Contact successfully deleted");
}
if($_GET['action']=="edit" || $_GET['action']=="add")
{
echo "<a href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id\">&lt;&lt; ".i18n("Back to %1 Contacts",array($award_sponsors_organization))."</a>\n";
if($_GET['action']=="edit")
{
echo "<h3>".i18n("Edit %1 Contact",array($award_sponsors_organization))."</h3>\n";
$buttontext="Save Contact";
$q=mysql_query("SELECT * FROM award_contacts WHERE id='".$_GET['edit']."'");
$r=mysql_fetch_object($q);
}
else if($_GET['action']=="add")
{
echo "<h3>".i18n("Add %1 Contact",array($award_sponsors_organization))."</h3>\n";
$buttontext="Add Contact";
}
$buttontext=i18n($buttontext);
echo "<form method=\"post\" action=\"award_contacts.php\">\n";
echo "<input type=\"hidden\" name=\"award_sponsors_id\" value=\"$award_sponsors_id\">\n";
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
if($_GET['action']=="edit")
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Salutation")."</td><td><input type=\"text\" name=\"salutation\" value=\"".htmlspecialchars($r->salutation)."\" size=\"4\" maxlength=\"8\" /></td></tr>\n";
echo "<tr><td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname\" value=\"".htmlspecialchars($r->firstname)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname\" value=\"".htmlspecialchars($r->lastname)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Position")."</td><td><input type=\"text\" name=\"position\" value=\"".htmlspecialchars($r->position)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone (Work)")."</td><td><input type=\"text\" name=\"phonework\" value=\"".htmlspecialchars($r->phonework)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone (Cell)")."</td><td><input type=\"text\" name=\"phonecell\" value=\"".htmlspecialchars($r->phonecell)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone (Home)")."</td><td><input type=\"text\" name=\"phonehome\" value=\"".htmlspecialchars($r->phonehome)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Fax")."</td><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($r->fax)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Email")."</td><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($r->email)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><td>".i18n("Notes")."</td><td><textarea name=\"notes\" rows=\"8\" cols=\"60\">".htmlspecialchars($r->notes)."</textarea></td></tr>\n";
echo "<tr><td>".i18n("Primary Contact")."</td><td><select name=\"primary\">";
$sel = ($r->primary == 'yes') ? 'selected="selected"': '';
echo "<option value=\"yes\" $sel>".i18n('Yes')."</option>";
$sel = ($r->primary == 'no') ? 'selected="selected"': '';
echo "<option value=\"no\" $sel>".i18n('No')."</option>";
echo "</select></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
else
{
echo "<br />";
echo "<a href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id&action=add\">".i18n("Add New Contact to %1",array($award_sponsors_organization))."</a>\n";
echo "<br />";
$q=mysql_query("SELECT * FROM award_contacts WHERE year='".$config['FAIRYEAR']."' AND award_sponsors_id='$award_sponsors_id' ORDER BY lastname,firstname");
if(mysql_num_rows($q))
{
echo "<table class=\"summarytable\">";
echo "<tr>";
echo " <th>".i18n("Name")."</th>";
echo " <th>".i18n("Email")."</th>";
echo " <th>".i18n("Phone (Work)")."</th>";
echo " <th>".i18n("Phone (Cell)")."</th>";
echo " <th>".i18n("Primary")."</th>";
echo " <th>Actions</th>";
echo "</tr>\n";
while($r=mysql_fetch_object($q))
{
echo "<tr>\n";
echo " <td>";
if($r->salutation) echo $r->salutation." ";
echo "$r->firstname $r->lastname</td>\n";
echo " <td>";
if($r->email)
{
list($eb,$ea)=split("@",$r->email);
echo "<script language=\"javascript\" type=\"text/javascript\">em('$eb','$ea')</script>";
}
else
echo "&nbsp;";
echo "</td>";
echo " <td>$r->phonework</td>\n";
echo " <td>$r->phonecell</td>\n";
$p = i18n(($r->primary=='yes')?'Yes':'');
echo " <td>$p</td>\n";
echo " <td align=\"center\">";
echo "<a href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id&action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this contact?')\" href=\"award_contacts.php?award_sponsors_id=$award_sponsors_id&action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo " </td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
}
}
send_footer();
?>

View File

@ -21,309 +21,220 @@
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
require_once('curl.inc.php');
send_header("Download Awards",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php' ));
function array_remove($needle,&$haystack) {
if(in_array($needle,$haystack))
unset($haystack[array_search($needle,$haystack)]);
}
if($_GET['action']=="check")
function check_source($source)
{
if(count($_GET['check'])) {
require_once("xml.inc.php");
foreach($_GET['check'] AS $checksource) {
$checksource=intval($checksource);
$q=mysql_query("SELECT * FROM award_sources WHERE id='$checksource' AND enabled='yes'");
$r=mysql_fetch_object($q);
if(!($r->username && $r->password)) {
echo error(i18n("Username and Password are not set for source '%1'. Please set them in the SFIAB Configuration/External Award Sources editor first",array($r->name)));
continue;
global $config;
$q=mysql_query("SELECT * FROM fairs WHERE id='$source'");
$fair=mysql_fetch_assoc($q);
if(!($fair['username'] && $fair['password'])) {
echo error(i18n("Username and Password are not set for source '%1'. Please set them in the SFIAB Configuration/External Award Sources editor first",array($r->name)));
return;
}
}
echo i18n("Checking %1 for awards...",array($r->name));
echo "<br />";
echo i18n("Checking %1 for awards...",array($fair['name']));
echo "<br />";
$req=array("awardrequest"=>array(
"username"=>$r->username,
"password"=>$r->password,
"year"=>$config['FAIRYEAR'],
)
);
if($fair['type'] == 'ysf') {
$req=array("awardrequest"=>array(
"username"=>$r->username,
"password"=>$r->password,
"year"=>$config['FAIRYEAR'],
)
);
} else {
$req['getawards'] = array('year'=>$config['FAIRYEAR']);
}
$output="";
xmlCreateRecurse($req);
$xmldata=$output;
$data = curl_query($fair, $req);
$ch = curl_init(); /// initialize a cURL session
curl_setopt ($ch, CURLOPT_URL,"$r->url");
curl_setopt ($ch, CURLOPT_HEADER, 0); /// Header control
curl_setopt ($ch, CURLOPT_POST, 1); /// tell it to make a POST, not a GET
curl_setopt ($ch, CURLOPT_POSTFIELDS, "xml=".$xmldata); /// put the query string here starting with "?"
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); /// This allows the output to be set into a variable $datastream
curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0);
curl_setopt ($ch, CURLOPT_TIMEOUT, 360);
curl_setopt ($ch, CURLOPT_SSLVERSION, 3);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
$datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream
$datastream = str_replace(" standalone=\"yes\"","",$datastream);
// echo "curl close <br />";
curl_close ($ch); /// close the curl session
if($data['error'] != 0) {
echo error("Server said: {$data['message']}<br />");
send_footer();
exit;
}
echo notice(i18n('Server said: Success'));
// echo "sending [".nl2br(htmlspecialchars($xmldata))."]";
echo i18n("The Remote Server said:")."<br />";
$response=xml_parsexml($datastream);
if(is_array($response)) {
$keys=array_keys($response);
if($keys[0]=="awardresponse") {
$keys=array_keys($data);
if(!array_key_exists('awards', $data)) {
echo error(i18n("Invalid XML response. Expecting '%1' in '%2'",array("awards",join(',',array_keys($data)))));
// echo "response=".print_r($datastream);
return;
}
//get a list of all the existing awards for this external source
$aq=mysql_query("SELECT * FROM award_awards WHERE award_sources_id='$checksource' AND year='".$config['FAIRYEAR']."'");
$existingawards=array();
while($ar=mysql_fetch_object($aq)) {
$existingawards[]=$ar->id;
//get a list of all the existing awards for this external source
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$source' AND year='{$config['FAIRYEAR']}'");
$existingawards=array();
while($ar=mysql_fetch_object($aq)) {
$existingawards[$ar->id] = true;
}
echo "<i>";
$ar=$response['awardresponse'][0];
$awards = $data['awards'];
$postback = $data['postback'];
echo i18n("Postback URL: %1",array($postback))." <br />";
$numawards=is_array($awards) ? count($awards) : 0;
echo i18n("Number of Awards: %1",array($numawards))." <br />";
if($numawards == 0) {
echo i18n('No awards to process').'</i> <br />';
return;
}
foreach($awards as $award) {
$identifier=$award['identifier'];
$year=$award['year'];
echo i18n("Award Identifier: %1",array($identifier))." &nbsp; ";
echo i18n("Award Year: %1",array($year))."<br />";
echo i18n("Award Name: %1",array($award['name_en']))."<br />";
if($year != $config['FAIRYEAR']) {
echo error(i18n("Award is not for the current fair year... skipping"));
echo '<br />';
continue;
}
$tq=mysql_query("SELECT * FROM award_awards WHERE
external_identifier='$identifier' AND
award_source_fairs_id='$source' AND
year='$year'");
if(mysql_num_rows($tq) == 0) {
/* Award doesn't exist, create it, then update it with the common code below */
mysql_query("INSERT INTO award_awards (award_types_id,
year, external_identifier,
award_source_fairs_id)
VALUES (2,'{$year}',
'".mysql_escape_string($identifier)."',
'$source')");
$award_id=mysql_insert_id();
} else {
echo i18n("Award already exists, updating info")."<br />";
$awardrecord=mysql_fetch_object($tq);
$award_id = $awardrecord->id;
}
//remove it from the existingawards list
unset($existingawards[$award_id]);
//check if the sponsor exists, if not, add them
$sponsor_str = mysql_escape_string($award['sponsor']);
$sponsorq=mysql_query("SELECT * FROM sponsors WHERE organization='$sponsor_str'");
if($sponsorr=mysql_fetch_object($sponsorq)) {
$sponsor_id=$sponsorr->id;
} else {
mysql_query("INSERT INTO sponsors (organization,year,notes,confirmed)
VALUES ('$sponsor_str','$year','".mysql_escape_string("Imported from external source: $r->name")."','yes')");
$sponsor_id=mysql_insert_id();
}
mysql_query("UPDATE award_awards SET
sponsors_id='$sponsor_id',
name='".mysql_escape_string($award['name_en'])."',
criteria='".mysql_escape_string($award['criteria_en'])."',
external_postback='".mysql_escape_string($postback)."'
WHERE
id='$award_id'
AND external_identifier='".mysql_escape_string($identifier)."'
AND year='$year'
");
echo mysql_error();
//update the prizes
$prizes = $award['prizes'];
if(is_array($prizes) && count($prizes) > 0) {
echo i18n("Number of prizes: %1",array(count($prizes)))."<br />";
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award_id'");
//get a list of all the existing prizes
$existingprizes=array();
while($pr=mysql_fetch_object($pq)) {
$existingprizes[$pr->external_identifier]=$pr;
}
foreach($prizes AS $prize) {
//if it doesn't exist, add it
if(!array_key_exists($prize['identifier'],$existingprizes)) {
/* Add a base entry, then update it below, yes it's two sql queries,
* but it's much shorter code, and means changing things in only
* one spot */
echo "&nbsp;".i18n("Adding prize %1",array($prize['identifier']))."<br />";
mysql_query("INSERT INTO award_prizes (award_awards_id,year,externa_identifier)
VALUES ('$award_id','$year',".mysql_escape_string($prize['identifier'])."')");
} else {
$ep=$existingprizes[$prize['identifier']];
echo "&nbsp;".i18n("Updating prize %1",array($ep->external_identifier))."<br />";
}
echo "<i>";
$ar=$response['awardresponse'][0];
$postback=$ar['postback'][0];
echo i18n("Postback URL: %1",array($postback))." <br />";
if($ar['awards'][0]['award'])
$numawards=count($ar['awards'][0]['award']);
else
$numawards=0;
echo i18n("Number of Awards: %1",array($numawards))." <br />";
if($numawards>0) {
if(!array_key_exists($prize['identifier'],$existingprizes)) {
$ep=$existingprizes[$prize['identifier']];
foreach($ar['awards'][0]['award'] AS $award) {
$identifier=$award['identifier'][0];
$year=$award['year'][0];
echo i18n("Award Identifier: %1",array($identifier))." &nbsp; ";
echo i18n("Award Year: %1",array($year))."<br />";
echo i18n("Award Name: %1",array($award['name_en'][0]))."<br />";
if($year==$config['FAIRYEAR']) {
$tq=mysql_query("SELECT * FROM award_awards WHERE external_identifier='$identifier' AND award_sources_id='$checksource' AND year='$year'");
if($awardrecord=mysql_fetch_object($tq)) {
echo i18n("Award already exists, updating info")."<br />";
//remove it from the existingawards list
array_remove($awardrecord->id,$existingawards);
//check if the sponsor exists, if not, add them
$sponsorq=mysql_query("SELECT * FROM award_sponsors WHERE organization='".mysql_escape_string($award['sponsor'][0])."'");
if($sponsorr=mysql_fetch_object($sponsorq)) {
$sponsor_id=$sponsorr->id;
}
else
{
mysql_query("INSERT INTO award_sponsors (organization,year,notes,confirmed) VALUES ('".mysql_escape_string($award['sponsor'][0])."','$year','".mysql_escape_string("Imported from external source: $r->name")."','yes')");
$sponsor_id=mysql_insert_id();
}
mysql_query("UPDATE award_awards SET
award_sponsors_id='$sponsor_id',
name='".mysql_escape_string($award['name_en'][0])."',
criteria='".mysql_escape_string($award['criteria_en'][0])."',
external_postback='".mysql_escape_string($postback)."'
WHERE
id='$awardrecord->id'
AND external_identifier='".mysql_escape_string($identifier)."'
AND year='$year'
");
echo mysql_error();
//update the prizes
if(is_array($award['prizes'][0]) && count($award['prizes'][0]['prize']>0))
{
$prizes=$award['prizes'][0]['prize'];
$numprizes=count($prizes);
echo i18n("Number of prizes: %1",array($numprizes))."<br />";
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$awardrecord->id'");
//get a list of all the existing prizes
$existingprizes=array();
while($pr=mysql_fetch_object($pq)) {
$existingprizes[$pr->external_identifier]=$pr;
}
foreach($prizes AS $prize) {
//if it exists -> update it
if(array_key_exists($prize['identifier'][0],$existingprizes)) {
$ep=$existingprizes[$prize['identifier'][0]];
echo "&nbsp;".i18n("Updating prize %1",array($ep->external_identifier))."<br />";
mysql_query("UPDATE award_prizes SET
cash='".intval($prize['cash'][0])."',
scholarship='".intval($prize['scholarship'][0])."',
value='".intval($prize['value'][0])."',
prize='".mysql_escape_string($prize['prize_en'][0])."',
number='".intval($prize['number'][0])."',
`order`='".intval($prize['ord'][0])."'
WHERE
id='$ep->id'");
//remove it from the list
unset($existingprizes[$ep->external_identifier]);
}
else { //if it doesnt exist -> add it
echo "&nbsp;".i18n("Adding prize %1",array($prize['identifier'][0]))."<br />";
mysql_query("INSERT INTO award_prizes (
award_awards_id,
cash,
scholarship,
value,
prize,
number,
`order`,
`year`,
external_identifier
) VALUES (
'$awardrecord->id',
'".intval($prize['cash'][0])."',
'".intval($prize['scholarship'][0])."',
'".intval($prize['value'][0])."',
'".mysql_escape_string($prize['prize_en'][0])."',
'".intval($prize['number'][0])."',
'".intval($prize['ord'][0])."',
'$year',
'".mysql_escape_string($prize['identifier'][0])."'
)");
}
}
//if an entry exists thats not in the xml -> delete it
foreach($existingprizes AS $ep) {
echo "&nbsp;".i18n("Removing prize %1",array($ep->external_identifier))."<br />";
mysql_query("DELETE FROM award_prizes WHERE id='$ep->id'");
}
}
//FIXME: update the translations
}
else {
//check if the sponsor exists, if not, add them
$sponsorq=mysql_query("SELECT * FROM award_sponsors WHERE organization='".mysql_escape_string($award['sponsor'][0])."'");
if($sponsorr=mysql_fetch_object($sponsorq)) {
$sponsor_id=$sponsorr->id;
}
else
{
mysql_query("INSERT INTO award_sponsors (organization,year,notes,confirmed) VALUES ('".mysql_escape_string($award['sponsor'][0])."','$year','".mysql_escape_string("Imported from external source: $r->name")."','yes')");
$sponsor_id=mysql_insert_id();
}
echo i18n("Award does not exists, adding...")."<br />";
mysql_query("INSERT INTO award_awards (
award_types_id,
award_sponsors_id,
name,
criteria,
year,
external_identifier,
external_postback,
award_sources_id
)
VALUES (
2,
$sponsor_id,
'".mysql_escape_string($award['name_en'][0])."',
'".mysql_escape_string($award['criteria_en'][0])."',
'".$year."',
'".mysql_escape_string($identifier)."',
'".mysql_escape_string($postback)."',
'$checksource'
)");
$award_id=mysql_insert_id();
//import the prizes
if(is_array($award['prizes'][0]) && count($award['prizes'][0]['prize']>0))
{
$prizes=$award['prizes'][0]['prize'];
$numprizes=count($prizes);
echo i18n("Number of prizes: %1",array($numprizes))."<br />";
foreach($prizes AS $prize) {
mysql_query("INSERT INTO award_prizes (
award_awards_id,
cash,
scholarship,
value,
prize,
number,
`order`,
`year`,
external_identifier
) VALUES (
'$award_id',
'".intval($prize['cash'][0])."',
'".intval($prize['scholarship'][0])."',
'".intval($prize['value'][0])."',
'".mysql_escape_string($prize['prize_en'][0])."',
'".intval($prize['number'][0])."',
'".intval($prize['ord'][0])."',
'$year',
'".mysql_escape_string($prize['identifier'][0])."'
)");
}
}
else
echo error(i18n("No prizes associated with this award"));
//FIXME: import the translations & prize translations
}
}
else
{
echo error(i18n("Award is not for the current fair year... skipping"));
}
echo "<br />";
mysql_query("UPDATE award_prizes SET
cash='".intval($prize['cash'])."',
scholarship='".intval($prize['scholarship'])."',
value='".intval($prize['value'])."',
prize='".mysql_escape_string($prize['prize_en'])."',
number='".intval($prize['number'])."',
`order`='".intval($prize['ord'])."'
WHERE
id='$ep->id'");
//remove it from the list
unset($existingprizes[$ep->external_identifier]);
}
}
echo "</i>";
//remove any awards that are left in the $existingawards array, they must have been removed from the source
foreach($existingawards AS $aid) {
echo i18n("Removing award id %1 that was removed from external source",array($aid))."<br />";
mysql_query("DELETE FROM award_prizes WHERE award_awards_id='$aid'");
mysql_query("DELETE FROM award_awards WHERE id='$aid'");
//if an entry exists thats not in the xml -> delete it
foreach($existingprizes AS $ep) {
echo "&nbsp;".i18n("Removing prize %1",array($ep->external_identifier))."<br />";
mysql_query("DELETE FROM award_prizes WHERE id='$ep->id'");
}
}
else
echo error(i18n("Invalid XML response. Expecting '%1', received '%2'",array("awardresponse",$keys[0])));
}
else
echo error(i18n("Invalid response. Could not parse XML into Array: %1",array($response)));
// echo "response=".print_r($datastream);
echo "<br />";
//FIXME: update the translations
}
}
else
echo error(i18n("No sources available to check"));
}
else
{
echo "<br />";
if(!function_exists('curl_init'))
{
//remove any awards that are left in the $existingawards array, they must have been removed from the source
foreach($existingawards AS $aid) {
echo i18n("Removing award id %1 that was removed from external source",array($aid))."<br />";
mysql_query("DELETE FROM award_prizes WHERE award_awards_id='$aid'");
mysql_query("DELETE FROM award_awards WHERE id='$aid'");
}
echo "</i>";
}
if($_GET['action']=="check") {
if(count($_GET['check'])) {
foreach($_GET['check'] AS $checksource) {
check_source(intval($checksource));
echo "<br />";
}
} else {
echo error(i18n("No sources available to check"));
}
} else {
if(!function_exists('curl_init')) {
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
$links=false;
}
else
} else {
$links=true;
}
$q=mysql_query("SELECT * FROM award_sources WHERE enabled='yes' ORDER BY name");
$q=mysql_query("SELECT * FROM fairs WHERE enable_awards='yes' ORDER BY name");
echo "<table class=\"tableview\">";
echo "<tr><th>".i18n("Source Name")."</th>";
echo "<th>".i18n("Source Location URL")."</th>";
@ -331,16 +242,16 @@ echo mysql_error();
echo "</tr>";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td>$r->name</td>\n";
echo "<td>$r->url</td>";
echo "<td>{$r->name}</td>\n";
echo "<td>{$r->url}</td>";
echo "<td align=\"center\">";
if($links)
echo "<a href=\"award_download.php?action=check&check[]=$r->id\">".i18n("check")."</a>";
echo "<a href=\"award_download.php?action=check&check[]={$r->id}\">".i18n("check")."</a>";
else
echo "n/a";
echo "</td>";
echo "</tr>";
$checkurl.="&check[]=$r->id";
$checkurl.="&check[]={$r->id}";
}
echo "</table>\n";
echo "<br />";

View File

@ -1,195 +0,0 @@
<?
/*
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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Award Sponsors",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php')
);
if($_POST['save']=="edit" || $_POST['save']=="add")
{
if($_POST['save']=="add")
{
$q=mysql_query("INSERT INTO award_sponsors (year) VALUES ('".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
}
else
$id=$_POST['id'];
$exec="UPDATE award_sponsors SET ".
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
"city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
"province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
"phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
"email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
"notes='".mysql_escape_string(stripslashes($_POST['notes']))."' ".
"WHERE id='$id'";
mysql_query($exec);
if($_POST['save']=="add")
echo happy("Sponsor successfully added");
else
echo happy("Successfully saved changes to sponsor");
}
if($_GET['action']=="delete" && $_GET['delete'])
{
mysql_query("DELETE FROM award_sponsors WHERE id='".$_GET['delete']."'");
echo happy("Sponsor successfully deleted");
}
if($_GET['action']=="confirm" && $_GET['confirm'])
{
mysql_query("UPDATE award_sponsors SET confirmed='yes' WHERE id='".$_GET['confirm']."'");
echo happy("Sponsor successfully confirmed");
}
if($_GET['action']=="unconfirm" && $_GET['unconfirm'])
{
mysql_query("UPDATE award_sponsors SET confirmed='no' WHERE id='".$_GET['unconfirm']."'");
echo happy("Sponsor successfully unconfirmed");
}
if($_GET['action']=="edit" || $_GET['action']=="add")
{
echo "<a href=\"award_sponsors.php\">&lt;&lt; ".i18n("Back to Award Sponsors")."</a>\n";
if($_GET['action']=="edit")
{
echo "<h3>".i18n("Edit Award Sponsor")."</h3>\n";
$buttontext="Save Sponsor";
$q=mysql_query("SELECT * FROM award_sponsors WHERE id='".$_GET['edit']."'");
$r=mysql_fetch_object($q);
}
else if($_GET['action']=="add")
{
echo "<h3>".i18n("Add New Award Sponsor")."</h3>\n";
$buttontext="Add Sponsor";
}
$buttontext=i18n($buttontext);
echo "<form method=\"post\" action=\"award_sponsors.php\">\n";
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
if($_GET['action']=="edit")
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Organization Name")."</td><td><input type=\"text\" id=\"organization\" name=\"organization\" value=\"".htmlspecialchars($r->organization)."\" size=\"60\" maxlength=\"128\" /><script type=\"text/javascript\">translateButton('organization');</script></td></tr>\n";
echo "<tr><td>".i18n("Address")."</td><td><input type=\"text\" name=\"address\" value=\"".htmlspecialchars($r->address)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><td>".i18n("City")."</td><td><input type=\"text\" name=\"city\" value=\"".htmlspecialchars($r->city)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n($config['provincestate'])."</td><td>";
emit_province_selector("province_code",$r->province_code);
echo "</td></tr>\n";
echo "<tr><td>".i18n($config['postalzip'])."</td><td><input type=\"text\" name=\"postalcode\" value=\"$r->postalcode\" size=\"8\" maxlength=\"7\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone")."</td><td><input type=\"text\" name=\"phone\" value=\"".htmlspecialchars($r->phone)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Fax")."</td><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($r->fax)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Email")."</td><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($r->email)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><td>".i18n("Notes")."</td><td><textarea name=\"notes\" rows=\"8\" cols=\"60\">".htmlspecialchars($r->notes)."</textarea></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
else
{
echo "<br />";
echo "<a href=\"award_sponsors.php?action=add\">Add New Sponsor</a>\n";
echo "<br />";
echo "<table class=\"summarytable\">";
echo "<tr>";
echo " <th>Confirmed?</th>";
echo " <th>Organization</th>";
echo " <th># of Awards</th>";
echo " <th># of Contacts</th>";
echo " <th>Action</th>";
echo "</tr>\n";
//$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization");
//we want to show all years, infact that year field probably shouldnt even be there.
$q=mysql_query("SELECT * FROM award_sponsors ORDER BY organization");
while($r=mysql_fetch_object($q))
{
echo "<tr>\n";
echo "<td align=\"center\">\n";
if($r->confirmed=='yes')
{
echo "<a href=\"award_sponsors.php?action=unconfirm&unconfirm=$r->id\"><img border=\"0\" alt=\"ok_alt\" src=\"".$config['SFIABDIRECTORY']."/images/16/ok.".$config['icon_extension']."\"></a>\n";
}
else
{
echo "<a title=\"click here to mark this sponsor as confirmed\" href=\"award_sponsors.php?action=confirm&confirm=$r->id\">confirm</a>";
}
echo "</td>\n";
echo " <td>$r->organization</td>\n";
$numq=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE year='".$config['FAIRYEAR']."' AND award_sponsors_id='$r->id'");
$numr=mysql_fetch_object($numq);
$numawards=$numr->num;
$numq=mysql_query("SELECT COUNT(id) AS num FROM award_contacts WHERE year='".$config['FAIRYEAR']."' AND award_sponsors_id='$r->id'");
$numr=mysql_fetch_object($numq);
$numcontacts=$numr->num;
echo " <td align=\"center\" valign=\"top\">";
echo "$numawards &nbsp;";
echo "<a href=\"award_awards.php?award_sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo "</td>";
echo " <td align=\"center\" valign=\"top\">";
echo "$numcontacts &nbsp;";
echo "<a href=\"award_contacts.php?award_sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo "</td>";
echo " <td align=\"center\">";
echo "<a href=\"award_sponsors.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this sponsor?')\" href=\"award_sponsors.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>\n";
}
echo "</table>\n";
}
send_footer();
?>

View File

@ -34,8 +34,8 @@
require_once("rerollprizes.php");
echo "<br />";
echo "<a href=\"award_sponsors.php\">".i18n('Award Sponsors')."</a><br />";
echo "<a href=\"award_contacts.php\">".i18n('Award Sponsors Contacts')."</a><br />";
echo "<a href=\"sponsors.php\">".i18n('Award Sponsors')."</a><br />";
echo "<a href=\"sponsor_contacts.php\">".i18n('Award Sponsors Contacts')."</a><br />";
echo "<a href=\"award_awards.php\">".i18n('Awards Management')."</a><br />";
echo "<br />";
echo "<a href=\"award_prizes.php?award_awards_id=-1\">".i18n('Edit prize template for the divisional awards')."</a>";

View File

@ -28,23 +28,9 @@
user_auth_required('committee', 'admin');
if($_POST['users_id'])
$uid = intval($_POST['users_id']);
if($_POST['users_uid'])
$uid = intval($_POST['users_uid']);
/* Some actions we want to redirect to the personal editor, so deal with those first */
if($_POST['add_member'])
{
$u = user_create('committee');
list($u['firstname'], $u['lastname']) = split(' ', $_POST['add_member']);
user_save($u);
header("location: {$config['SFIABDIRECTORY']}/user_personal.php?edit={$u['id']}");
exit;
}
if($_POST['action'] == 'edit') {
header("location: {$config['SFIABDIRECTORY']}/user_personal.php?edit=$uid");
exit;
}
/* Now, start the output for this page */
send_header("Committee Management",
@ -52,6 +38,7 @@ if($_POST['users_id'])
'Administration' => 'admin/index.php' ),
"committee_management");
$_SESSION['last_page'] = 'committee_management';
?>
@ -59,6 +46,21 @@ if($_POST['users_id'])
<script type="text/javascript">
<!--
function openeditor(id)
{
window.open("user_editor_window.php?id="+id,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
function neweditor()
{
var username = document.forms.addmember.add_member.value;
window.open("user_editor_window.php?type=committee&username="+username,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
document.forms.addmember.add_member.value = "";
return false;
}
function getElement(e,f)
{
if(document.layers)
@ -99,23 +101,30 @@ function actionSubmit()
alert('You must choose an action');
return false;
}
if(document.forms.memberaction.users_id.selectedIndex==0)
if(document.forms.memberaction.users_uid.selectedIndex==0)
{
alert('You must choose a member');
return false;
}
if(document.forms.memberaction.action.selectedIndex == 2) {
// Edit
var id = document.forms.memberaction.users_uid.options[document.forms.memberaction.users_uid.selectedIndex];
openeditor(id.value);
// alert("id="+id.value);
return false;
}
if(document.forms.memberaction.action.selectedIndex==3) //remove
{
return confirmClick('Are you sure you want to completely remove this member?');
}
return true;
}
//-->
</script>
<?
if($_POST['addcommittee'])
{
//add a new committee
@ -150,7 +159,7 @@ if($_POST['committees_id'] && $_POST['committees_ord'])
$t = mysql_escape_string(stripslashes($title));
$u = intval($uid);
$q = "UPDATE committees_link SET title='$t', ord='$o'
WHERE committees_id='$cid' AND users_id='$u'";
WHERE committees_id='$cid' AND users_uid='$u'";
mysql_query($q);
}
@ -161,14 +170,14 @@ if($_POST['committees_id'] && $_POST['committees_ord'])
if($_POST['action']=="assign")
{
if($_POST['committees_id'] && $_POST['users_id'])
if($_POST['committees_id'] && $_POST['users_uid'])
{
$cid = intval($_POST['committees_id']);
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_id='$uid'");
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_uid='$uid'");
if(!mysql_num_rows($q))
{
mysql_query("INSERT INTO committees_link (committees_id,users_id) VALUES ('$cid','$uid')");
mysql_query("INSERT INTO committees_link (committees_id,users_uid) VALUES ('$cid','$uid')");
echo happy(i18n("Successfully added member to committee"));
}
else
@ -189,9 +198,9 @@ if($_GET['deletecommittee'])
if($_POST['action']=="remove")
{
/* user_delete takes care of unlinking the user in other tables */
user_delete($uid, 'committee');
mysql_query("DELETE FROM committees_link WHERE users_id='$uid'");
echo happy(i18n("Committee member removed"));
echo happy(i18n("Committee member deleted"));
}
if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
@ -199,19 +208,10 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
$mem = intval($_GET['unlinkmember']);
$com = intval($_GET['unlinkcommittee']);
//unlink the member from the committee
mysql_query("DELETE FROM committees_link WHERE users_id='$mem' AND committees_id='$com'");
mysql_query("DELETE FROM committees_link WHERE users_uid='$mem' AND committees_id='$com'");
echo happy(i18n("Committee member unlinked from committee"));
}
/* This seems to be unused (there would also be an sql error on the INSERT :p) :
if($_POST['add_member_to_committees_id'])
{
$add = intval($_POST['add_member_to_committees_id']);
mysql_query("INSERT INTO committees_link (committees_id,users_id) VALUES ('$add')");
$edit=$_POST['committees_members_id'];
}
*/
echo "<table>";
echo "<tr><td>";
@ -227,12 +227,12 @@ if($_POST['add_member_to_committees_id'])
echo "</td><td width=\"40\">&nbsp;</td><td>";
echo "<h4>".i18n("Add Committee Member")."</h4>\n";
echo "<form method=\"post\" action=\"committees.php\">\n";
echo "<form method=\"post\" name=\"addmember\" action=\"committees.php\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Member Name").": </td><td>";
echo "<tr><td>".i18n("Member Email").": </td><td>";
echo "<input type=\"text\" size=\"15\" name=\"add_member\" />\n";
echo "</td>\n";
echo " <td><input type=\"submit\" value=\"".i18n("Add")."\" /></td></tr>\n";
echo " <td><input type=\"submit\" onclick=\"neweditor();\" value=\"".i18n("Add")."\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
@ -253,13 +253,14 @@ if($_POST['add_member_to_committees_id'])
echo "</select>";
echo "</td><td>";
$q=mysql_query("SELECT * FROM users WHERE types LIKE '%committee%' ORDER BY firstname");
echo "<select name=\"users_id\">";
$q=mysql_query("SELECT uid,MAX(year),firstname,lastname,deleted FROM users WHERE types LIKE '%committee%' GROUP BY uid ORDER BY firstname");
echo "<select name=\"users_uid\">";
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
while($r=mysql_fetch_object($q))
{
if($r->deleted != 'no') continue;
$displayname = $r->firstname.' '.$r->lastname;
echo "<option value=\"$r->id\">$displayname</option>\n";
echo "<option value=\"$r->uid\">$displayname</option>\n";
}
echo "</select>";
@ -308,56 +309,43 @@ if($_POST['add_member_to_committees_id'])
echo "<input size=\"1\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
echo "&nbsp; <b>$r->name</b>";
$q2=mysql_query("SELECT
users.id,
users.firstname,users.lastname,
users.email,
users_committee.emailprivate,
committees_link.title,
committees_link.ord
FROM
users, users_committee, committees_link
WHERE
users_committee.users_id=users.id
AND committees_link.users_id=users.id
AND committees_link.committees_id='$r->id'
ORDER BY
ord,firstname");
if(mysql_num_rows($q2)==0)
{
$q2=mysql_query("SELECT committees_link.title,committees_link.ord,users.uid,MAX(users.year),users.lastname
FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid
WHERE committees_id='{$r->id}'
GROUP BY users.uid ORDER BY ord,users.lastname ");
if(mysql_num_rows($q2)==0) {
echo "&nbsp; &nbsp;";
echo "<a title=\"Remove Committee\" onclick=\"return confirmClick('Are you sure you want to remove this committee?');\" href=\"committees.php?deletecommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Committee\" /></a>";
}
echo "</td></tr>\n";
echo mysql_error();
while($r2=mysql_fetch_object($q2))
{
while($r2=mysql_fetch_object($q2)) {
$u = user_load_by_uid($r2->uid);
echo "<tr><td align=\"right\">&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a title=\"Edit Member\" href=\"{$config['SFIABDIRECTORY']}/user_personal.php?edit={$r2->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\" border=\"0\" alt=\"Edit\" /></a>";
echo "<a title=\"Edit Member\" href=\"#\" onclick=\"openeditor({$u['id']})\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\" border=\"0\" alt=\"Edit\" /></a>";
echo "&nbsp;";
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember=$r2->id&amp;unlinkcommittee={$r->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/undo.{$config['icon_extension']}\" border=\"0\" alt=\"Unlink\" /></a>";
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember={$u['uid']}&amp;unlinkcommittee={$r->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/undo.{$config['icon_extension']}\" border=\"0\" alt=\"Unlink\" /></a>";
echo "</td>";
echo "<td valign=\"top\">";
echo "<b>{$r2->firstname} {$r2->lastname}</b>";
echo "<b>{$u['name']}</b>";
echo "</td><td>";
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$r2->id}]\" size=\"15\">";
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['id']}]\" size=\"15\">";
echo "</td><td>";
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$r2->id}]\" size=\"2\">";
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['id']}]\" size=\"2\">";
echo "</td><td>";
if($r2->email)
{
list($b,$a)=split("@",$r2->email);
if($u['email']) {
list($b,$a)=split("@",$u['email']);
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
}
if($r2->emailprivate)
{
if($r2->email) echo " <b>/</b> ";
list($b,$a)=split("@",$r2->emailprivate);
if($u['emailprivate']) {
if($u['email']) echo " <b>/</b> ";
list($b,$a)=split("@",$u['emailprivate']);
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
}

View File

@ -1,22 +1,22 @@
<?
$mailqueries=array(
"committee_all"=>array("name"=>"Committee members (all)","query"=>
"SELECT firstname, lastname, organization, email FROM users WHERE types LIKE '%committee' AND deleted='no'"),
"SELECT firstname, lastname, organization, email FROM users WHERE types LIKE '%committee%' AND deleted='no' AND year='{$config['FAIRYEAR']}' "),
"judges_all"=>array("name"=>"Judges from all years","query"=>
"SELECT firstname, lastname, email FROM judges WHERE deleted='no' ORDER BY email"),
"judges_all"=>array("name"=>"(BROKEN, DO NOT USE) Judges from all years","query"=>
"SELECT firstname, lastname, email FROM users WHERE 0 ORDER BY email"),
"judges_active_thisyear"=>array("name"=>"Judges active for this year", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges,judges_years WHERE judges.deleted='no' AND judges_years.year='".$config['FAIRYEAR']."' AND judges.id=judges_years.judges_id ORDER BY email"),
"SELECT firstname, lastname, email FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id WHERE types LIKE '%judge%' AND year='{$config['FAIRYEAR']}' AND deleted='no' AND users_judge.judge_active='yes' ORDER BY email"),
"judges_inactive"=>array("name"=>"Judges not active for this year", "query"=>
"judges_inactive"=>array("name"=>"(BROKEN, DO NOT USE) Judges not active for this year", "query"=>
"SELECT judges.id, firstname, lastname, email FROM judges WHERE id NOT IN (SELECT judges_id FROM judges_years WHERE year='".$config['FAIRYEAR']."') AND judges.deleted='no' ORDER BY email"),
"judges_active_complete_thisyear"=>array("name"=>"Judges active for this year and complete", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges,judges_years WHERE judges.deleted='no' AND judges_years.year='".$config['FAIRYEAR']."' AND judges.id=judges_years.judges_id AND judges.complete='yes' ORDER BY email"),
"SELECT firstname, lastname, email FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id WHERE types LIKE '%judge%' AND year='{$config['FAIRYEAR']}' AND users_judge.judge_complete='yes' AND deleted='no' AND users_judge.judge_active='yes' ORDER BY email"),
"judges_active_incomplete_thisyear"=>array("name"=>"Judges active for this year but not complete", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges,judges_years WHERE judges.deleted='no' AND judges_years.year='".$config['FAIRYEAR']."' AND judges.id=judges_years.judges_id AND judges.complete!='yes' ORDER BY email"),
"SELECT firstname, lastname, email FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id WHERE types LIKE '%judge%' AND year='{$config['FAIRYEAR']}' AND users_judge.judge_complete='no' AND deleted='no' AND users_judge.judge_active='yes' ORDER BY email"),
"participants_complete_thisyear"=>array("name"=>"Participants complete this year","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"),
@ -51,5 +51,12 @@
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year='".($config['FAIRYEAR']-1)."' AND teacheremail!=''"),
"school_teachers_allyears"=>array("name"=>"Teachers (as entered by students) all years","query"=>
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE teacheremail!=''"),
/* Volunteers */
"volunteers_active_complete_thisyear"=>array("name"=>"Volunteers active for this year and complete", "query"=>
"SELECT id, firstname, lastname, email FROM users LEFT JOIN users_volunteer ON users_volunteer.users_id=users.id WHERE users.year='{$config['FAIRYEAR']}' AND users_volunteer.volunteer_complete='yes' AND users_volunteer.volunteer_active='yes' AND users.deleted='no' AND types LIKE '%volunteer%' ORDER BY email"),
"volunteers_active_incomplete_thisyear"=>array("name"=>"Volunteers active for this year but not complete", "query"=>
"SELECT id, firstname, lastname, email FROM users LEFT JOIN users_volunteer ON users_volunteer.users_id=users.id WHERE users.year='{$config['FAIRYEAR']}' AND users_volunteer.volunteer_complete='no' AND users_volunteer.volunteer_active='yes' AND users.deleted='no' AND users.types LIKE '%volunteer%' ORDER BY email"),
);
?>

86
admin/curl.inc.php Normal file
View File

@ -0,0 +1,86 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2007 James Grant <james@lightbox.org>
Copyright (C) 2009 David Grant <dave@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_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
require_once('xml.inc.php');
function curl_query($fair, $data, $ysf_url='')
{
global $output;
switch($fair['type']) {
case 'sfiab':
$url = $fair['url'].'/xmltransport.php';
$var = 'json';
$d = array();
$d['auth'] = array('username' => $fair['username'],
'password' => $fair['password']);
$str = json_encode(array_merge($d, $data));
break;
case 'ysf':
if($ysf_url == '')
$url = $fair['url'];
else
$url = $ysf_url;
$var = 'xml';
$output="";
xmlCreateRecurse($data);
$str = $output;
break;
}
echo "<pre>Curl Send: $str</pre>";
$ch = curl_init(); /// initialize a cURL session
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0); /// Header control
curl_setopt ($ch, CURLOPT_POST, 1); /// tell it to make a POST, not a GET
curl_setopt ($ch, CURLOPT_POSTFIELDS, "$var=".urlencode($str)); /// put the query string here starting with "?"
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); /// This allows the output to be set into a variable $datastream
curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0);
curl_setopt ($ch, CURLOPT_TIMEOUT, 360);
curl_setopt ($ch, CURLOPT_SSLVERSION, 3);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
$datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream
curl_close ($ch); /// close the curl session
// echo "<pre>Server Returned: ".urldecode($datastream)."</pre>";
switch($fair['type']) {
case 'sfiab':
$ret=json_decode(urldecode($datastream), true);
break;
case 'ysf':
$datastream = str_replace(" standalone=\"yes\"","",$datastream);
/* Return is plaintext, make a return array */
$ret['error'] = 0;
$ret['message'] = $datastream;
break;
}
echo "<pre>Server Returned: ";print_r($ret);echo "</pre><br>";
return $ret;
}
?>

513
admin/fair_stats.php Normal file
View File

@ -0,0 +1,513 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2007 James Grant <james@lightbox.org>
Copyright (C) 2009 David Grant <dave@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_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
require_once('xml.inc.php');
require_once('stats.inc.php');
require_once('curl.inc.php');
function stats_to_ysf($fair, $stats)
{
if($fair['type'] == 'ysf') {
/* Map data into YSF tags */
$y=array();
$y["numschoolstotal"]=$stats['schools_total'];
$y["numschoolsactive"]=$stats['schools_active'];
$y["numstudents"]=$stats['students_total'];
$y["numk6m"]=$stats['male_1'] + $stats['male_4'];
$y["numk6f"]=$stats['female_1'] + $stats['female_4'];
$y["num78m"]=$stats['male_7'];
$y["num78f"]=$stats['female_7'];
$y["num910m"]=$stats['male_9'];
$y["num910f"]=$stats['female_9'];
$y["num11upm"]=$stats['male_11'];
$y["num11upf"]=$stats['female_11'];
$y["projk6"]=$stats['projects_1'] + $stats['projects_4'];
$y["proj78"]=$stats['projects_7'];
$y["proj910"]=$stats['projects_9'];
$y["proj11up"]=$stats['projects_11'];
$y["committee"]=$stats['committee_members'];
$y["judges"]=$stats['judges'];
return $y;
}
return $stats;
}
send_header("Fair Stats",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"one-click_ysf_affiliation_stats"
);
echo "<br />";
/* SFIAB config options server side */
$server_config = array();
$server_config['fair_stats_participation'] = 'no';
$server_config['fair_stats_schools_ext'] = 'no';
$server_config['fair_stats_minorities'] = 'no';
$server_config['fair_stats_guests'] = 'no';
$server_config['fair_stats_sffbc_misc'] = 'no';
$server_config['fair_stats_info'] = 'no';
$server_config['fair_stats_next_chair'] = 'no';
$server_config['fair_stats_scholarships'] = 'no';
$server_config['fair_stats_delegates'] = 'no';
if($_GET['year']) $year=intval($_GET['year']);
else $year=$config['FAIRYEAR'];
if($_GET['id']) $fairs_id=intval($_GET['id']);
else if($_POST['id']) $fairs_id=intval($_POST['id']);
else $fairs_id = -1;
if($fairs_id != -1) {
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'");
$fair = mysql_fetch_assoc($q);
}
$action = $_POST['action'];
if($action == 'sendstats') {
foreach(array_keys($stats_data) as $k) {
$stats[$k] = $_POST[$k];
}
$stats['year'] = $year;
if($fair['type'] == 'ysf') {
$st = stats_to_ysf($fair, $stats);
$req = array('affiliation' => array(
"ysf_region_id"=>$fair['username'],
"ysf_region_password"=>$fair['password'],
"year"=>$year,
'stats'=>$st)
);
} else {
$req = array('stats'=>$stats);
}
if(function_exists('curl_init')) {
$r = curl_query($fair, $req,
'https://secure.ysf-fsj.ca/registration/xmlaffiliation.php');
if($r['error'] == 0)
echo happy(i18n("The %1 Server said:", array($fair['name'])).' '.$r['message']);
else
echo error(i18n("The %1 Server said:", array($fair['name'])).' '.$r['message']);
// $fairs_id = -1;
// $year = $config['FAIRYEAR'];
} else {
echo error("CURL Support Missing");
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSF system as the regional coodinator and upload the XML data manually");
send_footer();
exit;
}
}
echo "<form name=\"fairselect\" action=\"$PHPSELF\" method=\"get\">";
$q=mysql_query("SELECT * FROM fairs WHERE `type`='sfiab' OR `type`='ysf'");
echo "<select name=\"id\" \">";
echo "<option value=\"\">".i18n("Choose a fair")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($fairs_id==$r->id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"{$r->id}\">{$r->name} ({$r->abbrv})</option>\n";
}
$q=mysql_query("SELECT DISTINCT(year) AS year FROM config WHERE year>0 ORDER BY year");
echo "<select name=\"year\" >";
echo "<option value=\"\">".i18n("Choose a year")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($year==$r->year) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->year\">$r->year</option>\n";
}
echo "</select>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"".i18n('Prepare Stats')."\" />";
echo "</form>";
echo "<br />";
echo "<hr />";
if($fairs_id == -1) {
echo i18n('Statistics will be shown below this line before being sent. Please select a fair and year first.');
/* Wait for them to select somethign before generating stats */
send_footer();
exit;
}
if($fair['type'] == 'ysf') {
$data['statconfig'] = array('fair_stats_participation');
} else {
echo notice(i18n('Getting stats request and downloading existing stats from server %1', array($fair['url'])));
/* Query the server to see what stats we need */
$q=array('getstats' => array('year' => $year));
$data = curl_query($fair, $q);
if($data['error'] != 0) {
echo error("Server said: {$data['message']}<br />");
send_footer();
exit;
}
echo notice(i18n('Server said: Success'));
}
echo '<hr />';
echo i18n('This server has requested the following stats for your %1 fair:', array($year));
echo '<br /><br />';
foreach($server_config as $k=>$v) {
$server_config[$k] = $data['statconfig'][$k];
}
/* Gather all stats, then we'll decide what to send */
$stats = array();
$stats['year'] = $year;
/* Now, overwrite all the stats with what we pulled down from the server */
if(is_array($data['stats'])) {
foreach($data['stats'] as $k=>$v) {
$stats[$k] = $v;
}
}
// print_r($data['stats'][0]);
/* And now, overwrite all the stuff we pulled down with stats we can compute */
//number of schools
$q=mysql_query("SELECT COUNT(id) AS num FROM schools WHERE year='$year'");
$r=mysql_fetch_object($q);
$stats['schools_total']=$r->num;
//number of schools participating
$q=mysql_query("SELECT DISTINCT(students.schools_id) AS sid, schools.*
FROM students
LEFT JOIN registrations ON students.registrations_id=registrations.id
LEFT JOIN schools ON students.schools_id=schools.id
WHERE students.year='$year'
AND registrations.year='$year'
AND (registrations.status='complete' OR registrations.status='paymentpending')");
$stats['schools_active']=mysql_num_rows($q);
$stats['schools_public'] = 0;
$stats['schools_private'] = 0;
$stats['schools_atrisk'] = 0;
$districts = array();
while($si=mysql_fetch_assoc($q)) {
if($si['designate'] == 'public')
$stats['schools_public']++;
if($si['designate'] == 'independent')
$stats['schools_private']++;
if($si['atrisk'] == 'yes')
$stats['schools_atrisk']++;
$bd = $si['board'].'~'.$si['district'];
if(!in_array($bd, $districts)) $districts[] =$bd;
}
$stats['schools_districts'] = count($districts);
//numbers of students:
$q=mysql_query("SELECT students.*,schools.*
FROM students
LEFT JOIN registrations ON students.registrations_id=registrations.id
LEFT JOIN schools on students.schools_id=schools.id
WHERE students.year='$year'
AND registrations.year='$year'
AND (registrations.status='complete' OR registrations.status='paymentpending')");
echo mysql_error();
$stats['students_total'] = mysql_num_rows($q);
$stats['students_public'] = 0;
$stats['students_private'] = 0;
$stats['students_atrisk'] = 0;
$grademap = array(1=>1, 2=>1, 3=>1, 4=>4, 5=>4, 6=>4, 7=>7, 8=>7,
9=>9, 10=>9, 11=>11, 12=>11, 13=>11);
foreach($grademap as $k=>$g) {
$stats["male_$g"] = 0;
$stats["female_$g"] = 0;
$stats["projects_$g"] = 0;
}
$unknown = array();
while($s=mysql_fetch_assoc($q)) {
if(!in_array($s['sex'], array('male','female')))
$unknown[$grademap[$s['grade']]]++;
else
$stats["{$s['sex']}_{$grademap[$s['grade']]}"]++;
if($s['designate'] == 'public')
$stats['students_public']++;
if($s['designate'] == 'independent')
$stats['students_private']++;
if($s['atrisk'] == 'yes')
$stats['students_atrisk']++;
}
foreach($unknown as $g=>$a) {
$m = round($a/2);
$f = $a - $m;
$stats["male_$g"] += $m;
$stats["female_$g"] += $f;
}
//projects
$q=mysql_query("SELECT MAX(students.grade) AS grade FROM students
LEFT JOIN registrations ON students.registrations_id=registrations.id
LEFT JOIN projects ON projects.registrations_id=registrations.id
WHERE students.year='$year'
AND registrations.year='$year'
AND projects.year='$year'
AND (registrations.status='complete' OR registrations.status='paymentpending')
GROUP BY projects.id");
echo mysql_error();
while($r=mysql_fetch_assoc($q)) {
$stats["projects_{$grademap[$r['grade']]}"]++;
}
$q=mysql_query("SELECT COUNT(id) AS num FROM users
LEFT JOIN users_committee ON users_committee.users_id=users.id
WHERE types LIKE '%committee%'
AND year='$year'
AND users_committee.committee_active='yes'
AND deleted='no'");
$r = mysql_fetch_object($q);
$stats['committee_members'] = $r->num;
$q=mysql_query("SELECT COUNT(id) AS num FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id
WHERE users.year='$year'
AND users.types LIKE '%judge%'
AND users.deleted='no'
AND users_judge.judge_complete='yes'
AND users_judge.judge_active='yes'");
$r=mysql_fetch_object($q);
$stats['judges'] = $r->num;
/* All stats have been gathered, print them */
/* Print all blocks the server requests */
echo "<form method=\"POST\" action=\"$PHPSELF\">";
echo "<input type=\"hidden\" name=\"action\" value=\"sendstats\" />";
if($server_config['fair_stats_info'] == 'yes') {
echo '<h3>'.i18n('%1 Fair information', array($year)).'</h3>';
echo '<table>';
echo '<tr><td>'.i18n('Fair Start Date').':</td>';
echo "<td><input type=\"text\" size=\"12\" name=\"start_date\" value=\"{$stats['start_date']}\">(YYYY-MM-DD)</td></tr>";
echo '<tr><td>'.i18n('Fair End Date').':</td>';
echo "<td><input type=\"text\" size=\"12\" name=\"end_date\" value=\"{$stats['end_date']}\">(YYYY-MM-DD)</td></tr>";
echo '<tr><td>'.i18n('Fair Location/Address').':</td>';
echo '<td><textarea name="address" rows="4" cols="60">'.htmlspecialchars($stats['address']).'</textarea></td>';
echo '<tr><td>'.i18n('Fair Budget').':</td>';
echo "<td>$<input type=text name=\"budget\" value=\"{$stats['budget']}\"></td></tr>";
echo '<tr><td>'.i18n('YSF Affiliation Complete').'?</td>';
echo '<td><select name="ysf_affiliation_complete">';
$sel = $stats['ysf_affiliation_complete'] == 'N' ? 'selected="selected"' : '';
echo " <option value=\"N\" $sel >No</option>";
$sel = $stats['ysf_affiliation_complete'] == 'Y' ? 'selected="selected"' : '';
echo " <option value=\"Y\" $sel >Yes</option>";
echo '</select></td></tr>';
echo '<tr><td>'.i18n('Charity Number or Information').'?</td>';
echo "<td><input type=text size=\"40\" name=\"charity\" value=\"{$stats['charity']}\"></td></tr>";
echo '</table>';
echo '<br />';
echo '<br />';
}
if($server_config['fair_stats_next_chair'] == 'yes') {
echo '<h3>'.i18n('%1 - %2 Chairperson (if known)', array($year, $year+1)).'</h3>';
echo '<table>';
echo '<tr><td>'.i18n('Name').': </td>';
echo "<td><input type=text name=\"chair_name\" value=\"{$stats['name']}\"></td>";
echo '<td>'.i18n('Email').': </td>';
echo "<td><input type=text name=\"chair_email\" value=\"{$stats['email']}\"></td></tr>";
echo '<tr><td>'.i18n('Tel. Bus').': </td>';
echo "<td><input type=text name=\"chair_bphone\" value=\"{$stats['bphone']}\"></td>";
echo '<td>'.i18n('Tel. Home').': </td>';
echo "<td><input type=text name=\"chair_hphone\" value=\"{$stats['hphone']}\"></td></tr>";
echo '<tr><td>'.i18n('Fax').': </td>';
echo "<td><input type=text name=\"chair_fax\" value=\"{$stats['fax']}\"></td>";
echo '</tr>';
echo '</table>';
echo '<br /><br />';
}
if($server_config['fair_stats_delegates'] == 'yes') {
echo '<h3>'.i18n('%1 CWSF Delegates and Alternatives', array($year)).'</h3>';
echo '<table>';
echo '<tr><td>'.i18n('Delegate Name(s)').'</td><td>'.i18n('Email').'</td><td>'.i18n('Jacket Size').'<td></tr>';
for($x=1;$x<=3;$x++) {
$sizes = array('small'=>'Small', 'medium'=>'Medium', 'large'=>'Large', 'xlarge'=>'X-Large');
echo "<td><input type=text size=\"25\" name=\"delegate$x\" value=\"{$stats["delegate$x"]}\"></td>";
echo "<td><input type=text size=\"25\" name=\"delegate{$x}_email\" value=\"{$stats["delegate{$x}_email"]}\"></td>";
echo "<td><select name=\"delegate{$x}_size\">";
$sz = $stats["delegate{$x}_size"];
foreach($sizes as $s=>$t) {
$sel = ($sz == $s) ? 'selected="selected"' : '';
echo " <option value=\"$s\" $sel >".i18n($t).'</option>';
}
echo '</select></td></tr>';
}
echo '</table>';
echo i18n('Remember, the jackets fit smaller than normal sizes.');
echo '<br /><br />';
}
if($server_config['fair_stats_scholarships'] == 'yes') {
echo '<h3>'.i18n('%1 Scholarships', array($year)).'</h3>';
echo 'How many university/college scholarships are available at your fair? (use a format like: <br /><b>6 - University of British Columbia - Entrance Scholarships</b><br />';
echo '<textarea name="scholarships" rows="4\" cols="80">'.htmlspecialchars($stats['scholarships']).'</textarea>';
echo '<br /><br />';
}
if($server_config['fair_stats_participation'] == 'yes') {
$rangemap = array(1=>'1-3', 4=>'4-6', 7=>'7-8', 9=>'9-10', 11=>'11-12');
echo '<h3>'.i18n('%1 Fair participation', array($year)).'</h3>';
echo '<br />';
echo i18n("Number of students").": <b>{$stats['students_total']}</b>";
echo '<table><tr><td></td><td></td><td></td><td align=\"center\">'.i18n('Grade').'</td><td></td><td></td></tr>';
echo '<tr><td></td>';
foreach($rangemap as $k=>$v) echo "<td align=\"center\" width=\"50px\" >$v</td>";
echo '</tr><tr>';
echo '<td>'.i18n('Male').'</td>';
foreach($rangemap as $k=>$v) echo "<td align=\"right\"><b>{$stats["male_$k"]}</b></td>";
echo '</tr><tr>';
echo '<td>'.i18n('Female').'</td>';
foreach($rangemap as $k=>$v) echo "<td align=\"right\"><b>{$stats["female_$k"]}</b></td>";
echo '</tr><tr>';
echo '<td>'.i18n('Projects').'</td>';
foreach($rangemap as $k=>$v) echo "<td align=\"right\"><b>{$stats["projects_$k"]}</b></td>";
echo '</tr>';
echo '</table>';
echo '<br />';
echo i18n("Number of schools").": <b>{$stats['schools_total']}</b>";
echo '<br />';
echo i18n("Number of active schools").": <b>{$stats['schools_active']}</b>";
echo '<br />';
echo '<br />';
echo i18n("Number of committee members: <b>%1</b> (note: this is number of committee members who logged in to SFIAB for the year, anyone who was active but didn't log in to SFIAB will NOT be counted)",array($stats['committee_members']));
echo '<br />';
echo i18n("Number of judges").": <b>{$stats['judges']}</b>";
echo '<br />';
echo '<br />';
echo '<br />';
}
if($server_config['fair_stats_schools_ext'] == 'yes') {
echo '<h3>'.i18n('%1 Extended School/Participant data', array($year)).'</h3>';
echo '<br />';
echo i18n('Public schools: <b>%1</b> (<b>%2</b> students).',array(
$stats['schools_public'], $stats['students_public']));
echo '<br />';
echo i18n('Private/Independent schools: <b>%1</b> (<b>%2</b> students).',array(
$stats['schools_private'], $stats['students_private']));
echo '<br />';
echo i18n('At-risk/inner city schools: <b>%1</b> (<b>%2</b> students).',array(
$stats['schools_atrisk'], $stats['students_atrisk']));
echo '<br />';
echo i18n('Number of school boards/distrcits: <b>%1</b>',array(
$stats['schools_districts']));
echo '<br />';
echo '<br />';
echo '<br />';
}
if($server_config['fair_stats_minorities'] != '') {
echo '<h3>'.i18n('%1 Data on minority groups', array($year)).'</h3>';
echo '<br />';
echo '<table>';
if(strstr('firstnations',$server_config['fair_stats_minorities']) != false) {
echo '<tr><td>'.i18n('Number of First Nations students');
echo ": </td><td><input type=\"text\" name=\"firstnations\" value=\"{$stats['firstnations']}\" size=\"5\" />";
echo '</td></tr>';
}
echo '</table>';
echo '<br />';
echo '<br />';
}
if($server_config['fair_stats_guests'] == 'yes' ) {
echo '<h3>'.i18n('%1 Guests visiting the fair', array($year)).'</h3>';
echo '<br />';
echo '<table>';
echo '<tr><td>'.i18n('Number of Students that visited the fair (tours, etc.)');
echo ": </td><td><input type=\"text\" name=\"studentsvisiting\" value=\"{$stats['studentsvisiting']}\" size=\"5\" />";
echo '</td></tr>';
echo '<tr><td>'.i18n('Number of Public Guests that visited the fair');
echo ": </td><td><input type=\"text\" name=\"publicvisiting\" value=\"{$stats['publicvisiting']}\" size=\"5\" />";
echo '</td></tr>';
echo '</table>';
echo '<br />';
echo '<br />';
}
if($server_config['fair_stats_sffbc_misc'] == 'yes') {
echo '<h3>'.i18n('%1 Misc. SFFBC Questions', array($year)).'</h3>';
echo '<br />';
echo '<table>';
echo '<tr><td>'.i18n('Number of Teachers supporting student projects');
echo ": </td><td><input type=\"text\" name=\"teacherssupporting\" value=\"{$stats['teacherssupporting']}\" size=\"5\" />";
echo '</td></tr>';
echo '<tr><td>'.i18n('Number of Students indicating increased interest in science & technology');
echo ": </td><td><input type=\"text\" name=\"increasedinterest\" value=\"{$stats['increasedinterest']}\" size=\"5\" />";
echo '</td></tr>';
echo '<tr><td>'.i18n('Number of Students considering careers in science & technology');
echo ": </td><td><input type=\"text\" name=\"consideringcareer\" value=\"{$stats['consideringcareer']}\" size=\"5\" />";
echo '</td></tr>';
echo '</table>';
echo '<br />';
echo '<br />';
}
$keys = array_keys($stats_data);
foreach($keys as $k) {
if($stats_data[$k]['manual'] == true) continue;
echo "<input type=\"hidden\" name=\"$k\" value=\"{$stats[$k]}\" />";
}
echo "<input type=\"submit\" value=\"".i18n('Send stats to')." {$fair['name']}\">";
echo '</form>';
echo "<br />";
echo "<br />";
/* Format XML output, and print it, last chance for the user to edit it */
/*
$xml = stats_to_xml($fair, $stats);
echo '<hr />';
echo "<h3>".i18n("The following data will be sent to")." {$fair['name']}</h3>";
echo "<form method=\"post\" action=\"$PHPSELF\">";
echo "<input type=\"hidden\" name=\"action\" value=\"sendstats\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$fairs_id\">";
echo "<textarea rows=\"15\" cols=\"80\" name=\"xml\">";
echo $xml;
echo "</textarea>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Send stats to")." {$fair['name']}\">";
echo "</form>";
*/
echo "<hr /><pre>";
print_r($fair);
print_r($server_config);
print_r($stats);
echo "</pre>";
send_footer();
?>

138
admin/fundraising.php Normal file
View File

@ -0,0 +1,138 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 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");
require("../tableeditor.class.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
include ("fundraising_sponsorship_handler.inc.php");
include ("fundraising_types_handler.inc.php");
send_header("Fundraising",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"fundraising"
);
require_once("../dialog.inc.php");
//first, insert any defaults
$q=mysql_query("SELECT * FROM fundraising WHERE year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM fundraising WHERE year='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO fundraising (`type`,`name`,`description`,`system`,`goal`,`year`) VALUES ('$r->type','".mysql_real_escape_string($r->name)."','".mysql_real_escape_string($r->description)."','$r->system','$r->goal','".$config['FAIRYEAR']."')");
}
}
//this table is eventually going to be massive, and probably not in a tableview format, it'll show goals as well as all ongoing fund pledges, probabilities, etc as well as over/under, etc, all prettily colour coded.. basically a good overview of the total fundraising status of the fair.
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY system DESC,type");
echo "<table class=\"fundraisingtable\">";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
if($r->system=="no") {
echo "<a title=\"".i18n("Remove Fund")."\" onclick=\"return confirmClick('Are you sure you want to remove this fund and all sponsorships inside it?')\" href=\"fundraising.php?action=funddelete&delete=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
}
echo "</th>\n";
echo "<th colspan=\"5\">".i18n($r->name)."</th>\n";
echo "<th style=\"text-align: right\">".format_money($r->goal)."</th>\n";
echo "</tr>\n";
if($r->type=="general")
$orsql.="OR fundraising_type IS NULL";
$typetotal=0;
$sq=mysql_query("SELECT sponsorships.id, sponsors.organization, sponsorships.value, sponsorships.status, sponsorships.probability
FROM sponsorships
JOIN sponsors ON sponsorships.sponsors_id=sponsors.id
WHERE (sponsorships.fundraising_type='$r->type' $orsql)
AND sponsorships.year='{$config['FAIRYEAR']}'
ORDER BY status DESC, probability DESC, organization");
while($sr=mysql_fetch_object($sq)) {
echo "<tr id=\"sponsorships_$sr->id\" class=\"fundraising{$sr->status}\">";
echo "<td><a title=\"".i18n("Edit sponsorship details")."\" onclick=\"return SFIABDialog(event,'fundraising_sponsorship.php?id=$sr->id&fundraising_type=$r->type',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "<a title=\"".i18n("Remove sponsorship")."\" onclick=\"return confirmClick('Are you sure you want to remove this sponsorship?')\" href=\"fundraising.php?action=sponsorshipdelete&delete=$sr->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td>";
echo "<td>$sr->organization</td>\n";
/*
echo "<a href=\"communication.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
//only user emails can be deleted, system ones are required and cannot be removed
if($r->type=="user")
{
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove email?')\" href=\"communication.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a href=\"communication.php?action=send&send=$r->id\">Send</a>";
}
*/
echo "<td>$sr->status</td>";
echo "<td>";
if($sr->status=="pending")
{
echo "$sr->probability%";
echo "</td>";
echo "<td>".format_money($sr->value)."</td>";
}
else
echo "</td><td></td>\n";
$probval=$sr->probability/100*$sr->value;
echo "<td style=\"text-align: right\">".format_money($probval)."</td>";
echo "<td></td>\n";
echo "</tr>\n";
$typetotal+=$probval;
}
echo "<tr>";
echo "<td><a onclick=\"return SFIABDialog(event,'fundraising_sponsorship.php?fundraising_type=$r->type',400,250)\" href=\"#\">add</a></td>";
echo "<td colspan=\"4\" style=\"text-align: right; font-weight: bold;\">".i18n("%1 Total",array($r->name),array("Fundraising type total, eg) Award Sponsorship Total"))."</td>\n";
echo "<td style=\"font-weight: bold; text-align: right;\">".format_money($typetotal)."</td>\n";
$typediff=$typetotal-$r->goal;
echo "<td style=\"font-weight: bold; text-align: right;\">".format_money($typediff)."</td>\n";
echo "</tr>\n";
$totalgoal+=$r->goal;
$totaldiff+=$typediff;
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>\n";
}
echo "<tr>";
echo "<td colspan=\"2\"><a onclick=\"return SFIABDialog(event,'fundraising_types.php',400,250)\" href=\"#\">add fund type</a></td>";
echo "<td colspan=\"4\" style=\"font-weight: bold; text-align: right;\">".i18n("Total Net Position")."</td><td style=\"text-align: right; font-weight: bold;\">".format_money($totaldiff)."</td></tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<br />\n";
echo "<a href=\"sponsorship_levels.php\">Manage Sponsorship Levels</a>\n";
echo "<br />\n";
echo "<a href=\"sponsors.php\">Manage Sponsors</a>\n";
echo "<br />\n";
send_footer();
?>

View File

@ -0,0 +1,105 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
if($_GET['id']) {
$id=intval($_GET['id']);
$q=mysql_query("SELECT sponsorships.*, sponsors.organization FROM sponsorships,sponsors WHERE sponsorships.id='$id' AND sponsorships.sponsors_id=sponsors.id");
echo "<h2>Edit Sponsorship</h2>";
$sponsorship=mysql_fetch_object($q);
$formaction="sponsorshipedit";
}
else
{
echo "<h2>Create New Sponsorship</h2>";
$formaction="sponsorshipadd";
$fundraising_type=$_GET['fundraising_type'];
}
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
echo "<input type=\"hidden\" name=\"sponsorships_id\" value=\"$id\">";
echo "<table cellspacing=0 cellpadding=0 class=\"SFIABDialogTable\">";
echo "<tr><th>".i18n("Sponsor")."</th>";
echo "<td>";
if($formaction=="sponsorshipadd") {
$q=mysql_query("SELECT * FROM sponsors ORDER BY organization");
echo mysql_error();
echo "<select name=\"sponsors_id\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($r->id==$sponsorship->sponsors_id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">$r->organization</option>\n";
}
echo "</select>&nbsp;<a href=\"sponsors.php?action=add\">".i18n("Add")."</a>\n";
}
else {
echo $sponsorship->organization;
}
echo "</td></tr>\n";
echo "<tr><th>".i18n("Type")."</th>";
echo "<td>";
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY name");
echo mysql_error();
echo "<select name=\"fundraising_type\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($r->type==$sponsorship->fundraising_type || $r->type==$fundraising_type) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->type\">$r->name</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><th>".i18n("Amount")."</th><td><input type=\"text\" name=\"value\" value=\"$sponsorship->value\"></td></tr>\n";
echo "<tr><th>".i18n("Status")."</th>";
echo "<td>";
echo "<select name=\"status\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
$statuses=array("pending","confirmed","received");
foreach($statuses AS $status) {
if($sponsorship->status==$status) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$status\">".i18n(ucfirst($status))."</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><th>".i18n("Probability")."</th>";
echo "<td>";
echo "<select name=\"probability\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
$probs=array("25","50","75","90","95","99","100");
foreach($probs AS $prob) {
if($sponsorship->probability==$prob) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$prob\">$prob%</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "</table>\n";
?>

View File

@ -0,0 +1,80 @@
<?
if($_GET['action']=="sponsorshipdelete") {
mysql_query("DELETE FROM sponsorships WHERE id='".intval($_GET['delete'])."'");
if(mysql_affected_rows())
message_push(happy(i18n("Successfully removed sponsorship")));
}
if($_POST['action']=="sponsorshipedit" || $_POST['action']=="sponsorshipadd") {
$sponsors_id=intval($_POST['sponsors_id']);
$sponsorships_id=intval($_POST['sponsorships_id']);
$fundraising_type=mysql_real_escape_string($_POST['fundraising_type']);
$value=mysql_real_escape_string($_POST['value']);
$status=mysql_real_escape_string($_POST['status']);
$probability=mysql_real_escape_string($_POST['probability']);
if($status=="confirmed" || $status=="received") $probability="100";
if($probability==100 && $status=="pending") $status="confirmed";
}
if($_POST['action']=="sponsorshipedit") {
if($sponsorships_id && $fundraising_type && $value) {
$q=mysql_query("SELECT * FROM sponsorships WHERE id='$sponsorships_id'");
$current=mysql_fetch_object($q);
unset($log);
$log=array();
if($current->fundraising_type!=$fundraising_type)
$log[]="Changed sponsorship type from $current->fundraising_type to $fundraising_type";
if($current->value!=$value)
$log[]="Changed sponsorship value from $current->value to $value";
if($current->status!=$status)
$log[]="Changed sponsorship status from $current->status to $status";
if($current->probability!=$probability)
$log[]="Changed sponsorship probability from $current->probability to $probability";
if(count($log)) {
mysql_query("UPDATE sponsorships SET fundraising_type='$fundraising_type', value='$value', status='$status', probability='$probability' WHERE id='$sponsorships_id'");
foreach($log AS $l) {
mysql_query("INSERT INTO sponsors_logs (sponsors_id,dt,users_id,log) VALUES (
'$current->sponsors_id',
NOW(),
'".$_SESSION['users_id']."',
'".mysql_real_escape_string($l)."')");
}
if(mysql_error())
message_push(error(mysql_error()));
else
message_push(happy(i18n("Saved sponsorship changes")));
}
else
message_push(happy(i18n("No changes were made")));
}
else {
message_push(error(i18n("Required fields were missing, please try again")));
}
}
if($_POST['action']=="sponsorshipadd") {
if($sponsors_id && $fundraising_type && $value) {
mysql_query("INSERT INTO sponsorships (sponsors_id,fundraising_type,value,status,probability,year) VALUES ('$sponsors_id','$fundraising_type','$value','$status','$probability','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO sponsors_logs (sponsors_id,dt,users_id,log) VALUES (
'$sponsors_id',
NOW(),
'".$_SESSION['users_id']."',
'".mysql_real_escape_string("Created sponsorship: type=$fundraising_type, value=\$$value, status=$status, probability=$probability%")."')");
message_push(happy(i18n("Added new sponsorship")));
}
else
message_push(error(i18n("Required fields were missing, please try again")));
if(mysql_error())
message_push(error(mysql_error()));
}
?>

View File

@ -0,0 +1,59 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
if($_GET['id']) {
$id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising WHERE id='$id'");
echo "<h2>Edit Fund</h2>";
$fund=mysql_fetch_object($q);
$formaction="fundedit";
}
else {
echo "<h2>Create New Fund</h2>";
$formaction="fundadd";
}
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
echo "<input type=\"hidden\" name=\"fundraising_id\" value=\"$id\">";
echo "<table class=\"SFIABDialogTable\">";
if($fund->system=="yes") {
echo "<tr><th>".i18n("Type")."</th><td>".i18n("System (non-editable)")."</td></tr>\n";
echo "<tr><th>".i18n("Name")."</th><td>".htmlspecialchars($fund->name)."</td></tr>\n";
echo "<tr><th>".i18n("Key")."</th><td>".htmlspecialchars($fund->type)."</td></tr>\n";
}
else {
echo "<tr><th>".i18n("Type")."</th><td>".i18n("Custom (editable)")."</td></tr>\n";
echo "<tr><th>".i18n("Name")."</th><td><input type=\"text\" name=\"name\" value=\"".htmlspecialchars($fund->name)."\"></td></tr>\n";
echo "<tr><th>".i18n("Key")."</th><td><input type=\"text\" name=\"type\" value=\"".htmlspecialchars($fund->type)."\"></td></tr>\n";
}
echo "<tr><th>".i18n("Description")."</th><td><textarea style=\"width: 100%; height: 4em;\" name=\"description\">".htmlspecialchars($fund->description)."</textarea></td></tr>\n";
echo "<tr><th>".i18n("Goal")."</th><td><input type=\"text\" size=\"8\" name=\"goal\" value=\"$fund->goal\"></td></tr>\n";
echo "</table>\n";
?>

View File

@ -0,0 +1,62 @@
<?
if($_GET['action']=="funddelete" && $_GET['delete']) {
//first lookup all the sponsorships inside the fund
$id=intval($_GET['delete']);
$q=mysql_query("SELECT * FROM fundraising WHERE id='$id' AND year='".$config['FAIRYEAR']."'");
$f=mysql_fetch_object($q);
//hold yer horses, no deleting system funds!
if($f) {
if($f->system=="no") {
mysql_query("DELETE FROM sponsorships WHERE fundraising_type='".mysql_real_escape_string($f->type)."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM fundraising WHERE id='$id'");
if(mysql_affected_rows())
message_push(happy(i18n("Successfully removed fund %1",array($f->name))));
}
else {
message_push(error(i18n("Cannot remove system fund")));
}
}
}
if($_POST['action']=="fundedit" || $_POST['action']=="fundadd") {
$fundraising_id=intval($_POST['fundraising_id']);
if($fundraising_id) {
$q=mysql_query("SELECT * FROM fundraising WHERE id='$fundraising_id'");
$f=mysql_fetch_object($q);
$system=$f->system;
}
$name=mysql_real_escape_string($_POST['name']);
$type=mysql_real_escape_string($_POST['type']);
$description=mysql_real_escape_string($_POST['description']);
$goal=intval($_POST['goal']);
}
if($_POST['action']=="fundedit") {
if( ($system=="yes" && $goal) || ($system=="no" && $goal && $type && $name) ) {
if($system=="yes") {
mysql_query("UPDATE fundraising SET goal='$goal', description='$description' WHERE id='$fundraising_id'");
}
else {
mysql_query("UPDATE fundraising SET goal='$goal', description='$description', type='$type', name='$name' WHERE id='$fundraising_id'");
}
if(mysql_error())
message_push(error(mysql_error()));
else
message_push(happy(i18n("Saved fund changes")));
}
else {
message_push(error(i18n("Required fields were missing, please try again")));
}
}
if($_POST['action']=="fundadd") {
if( $goal && $type && $name) {
mysql_query("INSERT INTO fundraising (type,name,description,system,goal,year) VALUES ('$type','$name','$description','no','$goal','{$config['FAIRYEAR']}')");
message_push(happy(i18n("Added new fund")));
}
else
message_push(error(i18n("Required fields were missing, please try again")));
if(mysql_error())
message_push(error(mysql_error()));
}
?>

View File

@ -42,8 +42,12 @@
echo "<a href=\"volunteers.php\">".theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."</a>";
else
echo theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " </tr>";
echo '</td></tr><tr>';
echo " <td><a href=\"sciencefairs.php\">".theme_icon("sciencefair_management")."<br />".i18n("Science Fair Management")."</a></td>";
echo '<td></td>';
echo '<td></td>';
echo '<td></td></tr>';
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
@ -93,6 +97,7 @@
echo " <td><a href=\"communication.php\">".theme_icon("communication")."<br />".i18n("Communication (Send Emails)")."</a></td>";
echo " <td><a href=\"documents.php\">".theme_icon("internal_document_management")."<br />".i18n("Internal Document Management")."</a></td>";
echo " <td><a href=\"cms.php\">".theme_icon("website_content_management")."<br />".i18n("Website Content Management")."</a></td>";
echo " <td><a href=\"fundraising.php\">".theme_icon("fundraising")."<br />".i18n("Fundraising")."</a></td>";
echo " <td></td>";
echo " </tr>\n";
echo "</table>\n";

View File

@ -28,16 +28,16 @@ function getJudgingTeams()
//get the members for this team
$mq=mysql_query("SELECT
judges.id AS judges_id,
judges.firstname,
judges.lastname,
users.id AS judges_id,
users.firstname,
users.lastname,
judges_teams_link.captain
FROM
judges,
users,
judges_teams_link
WHERE
judges_teams_link.judges_id=judges.id AND
judges_teams_link.users_id=users.id AND
judges_teams_link.judges_teams_id='$r->id'
ORDER BY
captain DESC,
@ -49,16 +49,9 @@ function getJudgingTeams()
$teamlangs=array();
while($mr=mysql_fetch_object($mq))
{
$lq=mysql_query("SELECT * FROM judges_languages WHERE judges_id='$mr->judges_id'");
$judgelangs="";
if(mysql_num_rows($lq)) {
while($lr=mysql_fetch_object($lq)) {
$judgelangs.="$lr->languages_lang/";
if(!in_array($lr->languages_lang,$teamlangs))
$teamlangs[]=$lr->languages_lang;
}
$judgelangs=substr($judgelangs,0,-1);
}
$u = user_load($mr->judges_id, false);
$judgelangs = join('/', $u['languages']);
$teams[$lastteamid]['members'][]=array(
"id"=>$mr->judges_id,
"firstname"=>$mr->firstname,
@ -130,16 +123,16 @@ function getJudgingTeam($teamid)
//get the members for this team
$mq=mysql_query("SELECT
judges.id AS judges_id,
judges.firstname,
judges.lastname,
users.id AS judges_id,
users.firstname,
users.lastname,
judges_teams_link.captain
FROM
judges,
users,
judges_teams_link
WHERE
judges_teams_link.judges_id=judges.id AND
judges_teams_link.users_id=users.id AND
judges_teams_link.judges_teams_id='$r->id'
ORDER BY
captain DESC,
@ -208,4 +201,23 @@ function getJudgingEligibilityCode() {
}
}
function judges_load_all()
{
global $config;
$ret = array();
$query = "SELECT id FROM users WHERE types LIKE '%judge%'
AND year='{$config['FAIRYEAR']}'
AND deleted='no'";
$r = mysql_query($query);
while($i = mysql_fetch_assoc($r)) {
$u = user_load($i['id']);
if($u['judge_complete'] == 'no') continue;
$ret[$i['id']] = $u;
}
return $ret;
}
?>

View File

@ -33,12 +33,8 @@
);
echo "<br />";
echo '<b>'.i18n('Judges').'</b><ul>';
if($config['judge_registration_type']=="invite")
{
echo "<li><a href=\"judges_invite.php\">".i18n("Invite Judges")."</a></li></li>";
}
echo "<li><a href=\"judges_manager.php\">".i18n("Manage Judges")."</a> - ".i18n("Add, Delete, Edit, and List judges").'</li>';
echo "<li><a href=\"judges_judges.php\">".i18n("List Judges")."</a></li>";
echo "<li><a href=\"../user_invite.php?type=judge\">".i18n("Invite Judges")."</a></li></li>";
echo "<li><a href=\"user_list.php?show_types[]=judge\">".i18n("Manage Judges")."</a> - ".i18n("Add, Delete, Edit, and List judges").'</li>';
echo '</ul>';
echo '<b>'.i18n('Create the Judging Schedule').'</b><ul>';
echo "<li><a href=\"judges_timeslots.php\">".i18n("Create/Edit Judging Timeslots")."</a></li>";

View File

@ -40,167 +40,175 @@ $preferencechoices=array(
);
if($_GET['id'])
{
//include "../register_judges.inc.php";
$id = intval($_GET['id']);
$q=mysql_query("SELECT
judges.*
FROM
judges
WHERE
judges.id='".$_GET['id']."'");
echo mysql_error();
$judgeinfo=mysql_fetch_object($q);
send_popup_header(i18n("Judge Information - %1 %2",array($judgeinfo->firstname,$judgeinfo->lastname)));
echo "Complete for {$config['FAIRYEAR']}: ".(($judgeinfo->complete=="yes") ? "Yes" : "No");
echo "<br />";
echo "<h3>".i18n("Personal Info")."</h3>";
echo "<table class=\"viewtable\">\n";
echo "<tr>\n";
echo " <th>".i18n("First Name")."</th><td>$judgeinfo->firstname</td>\n";
echo " <th>".i18n("Last Name")."</th><td>$judgeinfo->lastname</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n("Email Address")."</th><td>$judgeinfo->email</td>\n";
echo " <th>".i18n("City")."</th><td>$judgeinfo->city</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n("Address 1")."</th><td>$judgeinfo->address</td>\n";
echo " <th>".i18n($config['provincestate'])."</th><td>$judgeinfo->province";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n("Address 2")."</th><td>$judgeinfo->address2</td>\n";
echo " <th>".i18n("Phone (Home)")."</th><td>$judgeinfo->phonehome</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n($config['postalzip'])."</th><td>$judgeinfo->postalcode</td>\n";
echo " <th>".i18n("Phone (Work)")."</th><td>$judgeinfo->phonework&nbsp;ext $judgeinfo->phoneworkext</td>\n";
echo "</tr>";
echo "<tr>\n";
echo " <th>".i18n("Organization")."</th><td>$judgeinfo->organization</td>\n";
echo " <th>".i18n("Phone (Cell)")."</th><td>$judgeinfo->phonecell</td>\n";
echo "</tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "<tr>\n";
echo " <th valign=\"top\"colspan=\"2\">".i18n("Age category preference")."</th><td colspan=\"2\">";
$q=mysql_query("SELECT judges_catpref.*,projectcategories.category FROM judges_catpref,projectcategories WHERE judges_id='{$_GET['id']}' AND judges_catpref.year='".$config['FAIRYEAR']."' AND projectcategories.year='".$config['FAIRYEAR']."' AND judges_catpref.projectcategories_id=projectcategories.id");
echo mysql_error();
while($r=mysql_fetch_object($q))
echo i18n($r->category).": ".$preferencechoices[$r->rank]." <br />";
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th colspan=\"2\">".i18n("Highest post-secondary degree")."</th>";
echo " <td colspan=\"2\">$judgeinfo->highest_psd</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th colspan=\"2\">".i18n("Other professional qualifications")."</th>";
echo " <td colspan=\"2\">$judgeinfo->professional_quals</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th colspan=\"2\" valign=\"top\">".i18n("Languages")."</th>";
echo " <td colspan=\"2\">";
$q=mysql_query("SELECT languages_lang FROM judges_languages WHERE judges_id='$judgeinfo->id'");
while($r=mysql_fetch_object($q))
{
echo $r->languages_lang;
echo "<br />";
}
echo " </td>\n";
echo "</tr>\n";
questions_print_answers('judgereg',$judgeinfo->id, $config['FAIRYEAR']);
echo "</table>";
echo "<hr />";
echo "<br />";
echo "<h3>Areas of Expertise</h3>";
echo "<table class=\"viewtable\">";
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$divs=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divnames[$r->id]=$r->division;
}
$subdivq=mysql_query("SELECT judges_expertise.*,
projectsubdivisions.subdivision,
projectsubdivisions.projectdivisions_id AS parent_id
FROM judges_expertise
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
WHERE judges_id='$judgeinfo->id'
AND judges_expertise.year='".$config['FAIRYEAR']."'
ORDER BY projectdivisions_id, projectsubdivisions_id");
echo mysql_error();
$judge_divs=array();
$judge_subdivs=array();
$divdata=array();
while($subdivr=mysql_fetch_object($subdivq))
{
if($subdivr->projectdivisions_id)
{
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
}
else
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
}
foreach($divs as $div)
{
echo "<tr><th>".i18n($divnames[$div])."</th>";
echo " <td>".$judge_divs[$div]."/5</td>";
echo "<td>";
if(count($judge_subdivs[$div]))
{
$divdata=implode(", ",$judge_subdivs[$div]);
echo "$divdata";
}
else
echo "&nbsp;";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
send_popup_header("Judge Information");
send_popup_header("Judge Information");
if($id < 1) {
echo error(i18n("No Judge ID passed to Judges Info"));
send_popup_footer();
exit;
}
$judgeinfo = user_load($id);
send_popup_header(i18n("Judge Information - %1 %2",array($judgeinfo['firstname'],$judgeinfo['lastname'])));
echo "Complete for {$config['FAIRYEAR']}: ".(($judgeinfo['complete']=="yes") ? "Yes" : "No");
echo "<br />";
echo "<h3>".i18n("Personal Info")."</h3>";
echo "<table class=\"viewtable\">\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("First Name").": </th><td>{$judgeinfo['firstname']}</td>\n";
echo " <th align=\"right\">".i18n("Last Name").":</th><td>{$judgeinfo['lastname']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Email Address").":</th><td>{$judgeinfo['email']}</td>\n";
echo " <th align=\"right\">".i18n("City").":</th><td>{$judgeinfo['city']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Address 1").":</th><td>{$judgeinfo['address']}</td>\n";
echo " <th align=\"right\">".i18n($config['provincestate']).": </th><td>{$judgeinfo['province']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Address 2").":</th><td>{$judgeinfo['address2']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Home)").":</th><td>{$judgeinfo['phonehome']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n($config['postalzip']).":</th><td>{$judgeinfo['postalcode']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Work)").":</th><td>{$judgeinfo['phonework']}</td>\n";
echo "</tr>";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Organization").":</th><td>{$judgeinfo['organization']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Cell)").":</th><td>{$judgeinfo['phonecell']}</td>\n";
echo "</tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "</table>";
echo "<table>";
echo "<tr>\n";
echo " <th valign=\"top\" align=\"right\" colspan=\"2\">".i18n("Time Availability").":</th><td colspan=\"2\">";
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$judgeinfo['id']}\" ORDER BY `start`");
$sel = array();
while($r=mysql_fetch_object($q)) {
$st = substr($r->start, 0, 5);
$end = substr($r->end, 0, 5);
echo "$st - $end<br />";
}
echo "</td></tr>";
echo "<tr>";
echo " <th valign=\"top\" align=\"right\" colspan=\"2\">".i18n("Age category preference").":</th><td colspan=\"2\">";
$q=mysql_query("SELECT * FROM projectcategories
WHERE year='{$config['FAIRYEAR']}'");
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$p = intval($judgeinfo['cat_prefs'][$r->id]);
echo i18n($r->category).": {$preferencechoices[$p]}<br />";
}
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\" colspan=\"2\">".i18n("Highest post-secondary degree").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['highest_psd']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\" colspan=\"2\" valign=\"top\">".i18n("Languages").":</th>";
echo " <td colspan=\"2\">".join(', ', $judgeinfo['languages']). "<br />";
echo " </td>\n";
echo "</tr>\n";
//questions_print_answers('judgereg',$judgeinfo['id'], $config['FAIRYEAR']);
echo "</table>";
echo "<hr />";
echo "<br />";
echo "<h3>Areas of Expertise</h3>";
echo "<table class=\"viewtable\">";
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
$divs=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divnames[$r->id]=$r->division;
}
/*
$subdivq=mysql_query("SELECT judges_expertise.*,
projectsubdivisions.subdivision,
projectsubdivisions.projectdivisions_id AS parent_id
FROM judges_expertise
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
WHERE judges_id='{$judgeinfo['id']}'
AND judges_expertise.year='".$config['FAIRYEAR']."'
ORDER BY projectdivisions_id, projectsubdivisions_id");
echo mysql_error();
$judge_divs=array();
$judge_subdivs=array();
$divdata=array();
*/
/*
while($subdivr=mysql_fetch_object($subdivq))
{
if($subdivr->projectdivisions_id)
{
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
}
else
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
}
*/
foreach($divs as $div)
{
$p = $judgeinfo['div_prefs'][$div];
echo "<tr><th align=\"right\" >".i18n($divnames[$div]).":</th>";
echo " <td>$p/5</td>";
echo "<td>";
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE
projectdivisions_id='$div' AND year='{$config['FAIRYEAR']}' ORDER BY subdivision");
$sd = array();
while($subr=mysql_fetch_object($subq)) {
if($u['div_prefs_sub'][$subr->id] == 1) {
$sd[] = $subdivr->subdivision;
}
}
/* Only show subdiv if main div >=3 */
if($p >= 3) echo implode(", ",$sd);
else echo "&nbsp;";
echo "</td>";
echo "</tr>";
}
echo "<tr>\n";
echo " <th align=\"right\" valign=\"top\">".i18n("Other").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['expertise_other']}<br />";
echo " </td>\n";
echo "</tr>\n";
echo "</table>";
send_popup_footer();
send_popup_footer();
?>

View File

@ -1,132 +0,0 @@
<?
/*
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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
include "judges.inc.php";
send_header("Judge List",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php')
);
?>
<script language="javascript" type="text/javascript">
function openjudgeinfo(id)
{
if(id)
currentid=id;
else
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
window.open("judges_info.php?id="+currentid,"JudgeInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
</script>
<?
if($_GET['action']=="remove" && $_GET['remove'])
{
//we need to remove them from:
// judges_teams
// judges_years
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_GET['remove']."' AND year=".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_years WHERE judges_id='".$_GET['remove']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Successfully removed judge from this year's fair"));
}
echo "<h3>".i18n("Active Judges list for %1",array($config['FAIRYEAR']))."</h3>";
echo "<table class=\"viewtable\">";
$querystr="SELECT
judges.id,
judges.firstname,
judges.lastname,
judges.email,
judges.complete,
judges_years.year
FROM
judges
JOIN judges_years ON judges.id=judges_years.judges_id
WHERE
judges_years.year='".$config['FAIRYEAR']."'
AND judges.deleted='no'
ORDER BY
lastname,
firstname";
$q=mysql_query($querystr);
$num=mysql_num_rows($q);
echo i18n("Listing %1 judges total. See the bottom for breakdown of judges by complete status",array($num),array("the number of judges"));
echo mysql_error();
echo "<tr>";
echo " <th>".i18n("Judge Name")."</th>";
echo " <th>".i18n("Email Address")."</th>";
echo " <th>".i18n("Complete")."</th>";
echo " <th>".i18n("Actions")."</th>";
echo "</tr>";
$completeyes=0;
$completeno=0;
while($r=mysql_fetch_object($q))
{
echo "<tr><td>";
echo "<a href=\"\" onclick=\"return openjudgeinfo($r->id)\">$r->firstname $r->lastname</a>";
echo "</td>";
echo "<td>$r->email</td>";
if($r->complete=="yes" && $r->year)
{
echo "<td class=\"happy\" align=\"center\">".i18n("yes")."</td>";
$completeyes++;
}
else
{
echo "<td class=\"error\" align=\"center\">".i18n("no")."</td>";
$cl="error";
$completeno++;
}
echo "<td align=\"center\">";
echo "<a onclick=\"return confirmClick('Are you sure you want to deactivate this judge from this years fair?')\" href=\"judges_judges.php?action=remove&remove=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo i18n("Note: Deleting judges from this list only deactivates the judge for this year's fair. To completely delete a judge, use the 'Manage Judges' page");
echo "<br />";
echo "<br />";
echo i18n("There are %1 total active judges.",array($num),array("the number of judges"));
echo "<br />";
echo i18n("There are %1 complete judges.",array($completeyes),array("the number of judges"));
echo "<br />";
echo i18n("There are %1 incomplete judges.",array($completeno),array("the number of judges"));
echo "<br />";
echo "<br />";
echo "<br />";
send_footer();
?>

View File

@ -1,100 +0,0 @@
<?
/*
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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
include "judges.inc.php";
require("../tableeditor.class.php");
require("../judge.class.php");
send_header("Judge Manager",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php') );
?>
<script language="javascript" type="text/javascript">
function openjudgeinfo(id)
{
if(id)
currentid=id;
else
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
window.open("judges_info.php?id="+currentid,"JudgeInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
</script>
<?
$icon_path = $config['SFIABDIRECTORY']."/images/16/";
$icon_exitension = $config['icon_extension'];
print("<br />");
if(isset($_GET['show_what'])) {
$_SESSION['judgesmanager_show_what']=$_GET['show_what'];
}
if($_SESSION['judgesmanager_show_what']) {
$show_what = $_SESSION['judgesmanager_show_what'];
} else {
$show_what = "cy_complete";
}
print("<form name=\"ShowJudges\" method=\"get\" action=\"{$_SERVER['PHP_SELF']}\">");
print("<select id=\"show_what\" name=\"show_what\">");
$s = ($show_what == 'all') ? " selected=\"selected\" " : "";
print("<option value=\"all\" $s>All Judges</option>");
$s = ($show_what == 'cy_active') ? " selected=\"selected\" " : "";
print("<option value=\"cy_active\" $s>All {$config['FAIRYEAR']} Judges (complete and incomplete)</option>");
$s = ($show_what == 'cy_complete') ? " selected=\"selected\" " : "";
print("<option value=\"cy_complete\" $s>All {$config['FAIRYEAR']} Judges (only complete)</option>");
print("</select>");
print("<input type=submit value=\"".i18n("Show")."\">");
print("</form>");
// echo i18n("Note: Deleting a judge from this screen only unlinks them from the current fairyear");
$editor = new TableEditor('judge');
// $editor->setDebug(true);
switch($show_what) {
case "all":
$editor->setOption('judges_show_what', 'all');
break;
case "cy_active":
$editor->setOption('judges_show_what', 'current_year_active');
break;
case "cy_complete":
$editor->setOption('judges_show_what', 'current_year_complete');
break;
}
$editor->execute();
send_footer();
?>

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ function judges_scheduler_check_timeslots()
$q=mysql_query("SELECT * FROM judges_timeslots WHERE ".
" year='".$config['FAIRYEAR']."'".
" AND allowdivisional='yes'" );
" AND `type`='divisional1'" );
$rows = mysql_num_rows($q);
return $rows;
@ -172,9 +172,12 @@ function judges_scheduler_check_judges()
echo "<br />";
echo "<br />";
$jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id");
/* $jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id");
$jr=mysql_fetch_object($jq);
$currentjudges=$jr->num;
$currentjudges=$jr->num;*/
/* FIXME: this his highly inefficient :), but won't be done very often */
$judges = judges_load_all();
$currentjudges = count($judges);
echo "Current number of registered judges: $currentjudges";
echo "</b>";
echo "<br />";

View File

@ -27,23 +27,6 @@
user_auth_required('committee', 'admin');
include "judges.inc.php";
send_header("Manage Judging Teams",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php')
);
?>
<script language="javascript" type="text/javascript">
function addclicked()
{
document.forms.judges.action.value="assign";
document.forms.judges.submit();
}
</script>
<?
if($_GET['edit']) $edit=$_GET['edit'];
if($_POST['edit']) $edit=$_POST['edit'];
if($_GET['action']) $action=$_GET['action'];
@ -57,7 +40,7 @@ function addclicked()
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Judge team successfully removed, and all of its corresponding members, timeslots, projects and awards unlinked from team"));
message_push(happy(i18n("Judge team successfully removed, and all of its corresponding members, timeslots, projects and awards unlinked from team")));
}
if($action=="deletealldivisional")
@ -83,9 +66,9 @@ function addclicked()
$numdeleted++;
}
if($numdeleted)
echo happy(i18n("Successfully deleted %1 auto-created divisional team(s)",array($numdeleted)));
message_push(happy(i18n("Successfully deleted %1 auto-created divisional team(s)",array($numdeleted))));
else
echo error(i18n("There were no auto-created divisional teams to delete"));
message_push(error(i18n("There were no auto-created divisional teams to delete")));
}
if($action=="deleteall")
@ -108,9 +91,9 @@ function addclicked()
$numdeleted++;
}
if($numdeleted)
echo happy(i18n("Successfully deleted %1 team(s)",array($numdeleted)));
message_push(happy(i18n("Successfully deleted %1 team(s)",array($numdeleted))));
else
echo error(i18n("There were no teams to delete"));
message_push(error(i18n("There were no teams to delete")));
}
if(($action=="save" || $action=="assign") && $edit)
@ -123,7 +106,7 @@ function addclicked()
if(mysql_error())
{
$err=true;
echo error(mysql_error());
message_push(error(mysql_error()));
}
if($_POST['award'])
@ -154,7 +137,7 @@ function addclicked()
if($r->num)
{
$addaward=false;
echo error(i18n("Sorry, only one Special Award can be assigned to a judging team"));
message_push(error(i18n("Sorry, only one Special Award can be assigned to a judging team")));
}
else
{
@ -166,7 +149,7 @@ function addclicked()
{
//link up the award
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('".$_POST['award']."','$edit','".$config['FAIRYEAR']."')");
echo happy(i18n("Award assigned to team"));
message_push(happy(i18n("Award assigned to team")));
}
}
@ -179,7 +162,7 @@ function addclicked()
$action="edit";
else
{
echo happy(i18n("Team successfully saved"));
message_push(happy(i18n("Team successfully saved")));
unset($action);
unset($edit);
}
@ -189,7 +172,7 @@ function addclicked()
if($action=="unassign")
{
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='".$_GET['unassign']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Award unassigned from judge team"));
message_push(happy(i18n("Award unassigned from judge team")));
//keep editing the same team
$action="edit";
}
@ -201,7 +184,7 @@ function addclicked()
$r=mysql_fetch_object($q);
if($r->c)
{
echo error(i18n("Cannot 'Create All' teams when any divisional teams currently exist. Try deleting all existing non-divisional teams first."));
message_push(error(i18n("Cannot 'Create All' teams when any divisional teams currently exist. Try deleting all existing non-divisional teams first.")));
}
else
{
@ -232,7 +215,7 @@ function addclicked()
$team_id=mysql_insert_id();
//now link the new team to the award
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','".$config['FAIRYEAR']."')");
echo happy(i18n("Created team #%1: %2",array($num,$name)));
message_push(happy(i18n("Created team #%1: %2",array($num,$name))));
$num++;
}
}
@ -248,8 +231,24 @@ function addclicked()
if($action=="edit" && $edit)
{
echo "<a href=\"judges_teams.php\">&lt;&lt; ".i18n("Back to Judging Teams")."</a>\n";
echo "<br />";
send_header("Edit Judging Team",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php',
'Manage Judging Teams' => 'admin/judges_teams.php'));
?>
<script language="javascript" type="text/javascript">
function addclicked()
{
document.forms.judges.action.value="assign";
document.forms.judges.submit();
}
</script>
<?
echo "<br />";
$team=getJudgingTeam($edit);
@ -359,6 +358,10 @@ function addclicked()
}
else
{
send_header("Manage Judging Teams",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php'));
echo "<br />";
$teams=getJudgingTeams();

View File

@ -22,10 +22,10 @@
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
include "judges.inc.php";
require_once('judges.inc.php');
send_header("Judging Team Members",
array('Committee Main' => 'committee_main.php',
@ -98,7 +98,7 @@ function switchjudgeinfo()
{
//before we insert them, we need to make sure they dont already belong to this team. We can not have the same judge assigned to the same team multiple times.
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_id='$selectedjudge' AND judges_teams_id='$team_id'");
$q=mysql_query("SELECT * FROM judges_teams_link WHERE users_id='$selectedjudge' AND judges_teams_id='$team_id'");
if(mysql_num_rows($q))
{
echo notice(i18n("Judge (%1) already belongs to judging team: %2",array($selectedjudge,$team_name)));
@ -107,7 +107,7 @@ function switchjudgeinfo()
else
{
//lets make the first one we add a captain, the rest, non-captains :)
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO judges_teams_link (users_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
$added++;
}
//if this is alreayd no, then who cares, but if its the first one that is going into the new team, then
@ -122,9 +122,9 @@ function switchjudgeinfo()
echo happy(i18n("%1 %2 added to team #%3 (%4)",array($added,$j,$_POST['team_num'],$team_name)));
}
if($_GET['action']=="del" && $_GET['team_num'] && $_GET['team_id'] && $_GET['judges_id'])
if($_GET['action']=="del" && $_GET['team_num'] && $_GET['team_id'] && $_GET['users_id'])
{
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_GET['judges_id']."' AND judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_link WHERE users_id='".$_GET['users_id']."' AND judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Removed judge from team #%1 (%2)",array($_GET['team_num'],$_GET['team_name'])));
//if there is still members left in the team, make sure we have a captain still
@ -139,7 +139,7 @@ function switchjudgeinfo()
{
if($first)
{
$firstjudge=$r->judges_id;
$firstjudge=$r->users_id;
$first=false;
}
@ -152,7 +152,7 @@ function switchjudgeinfo()
if(!$gotcaptain)
{
//make the first judge the captain
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
echo notice(i18n("Team captain was removed. A new team captain has been automatically assigned"));
}
}
@ -181,7 +181,7 @@ function switchjudgeinfo()
{
//teams can have as many captains as they want, so just add it.
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='".$_GET['judge_id']."'");
echo happy(i18n("Team captain assigned"));
}
@ -195,7 +195,7 @@ function switchjudgeinfo()
}
else
{
mysql_query("UPDATE judges_teams_link SET captain='no' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
mysql_query("UPDATE judges_teams_link SET captain='no' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='".$_GET['judge_id']."'");
echo happy(i18n("Team captain removed"));
}
}
@ -211,7 +211,7 @@ function switchjudgeinfo()
echo "<input type=\"hidden\" name=\"team_id\">";
echo "<input type=\"hidden\" name=\"team_num\">";
echo "<input type=\"hidden\" name=\"team_name\">";
echo "<input type=\"hidden\" name=\"judges_id\">";
echo "<input type=\"hidden\" name=\"users_id\">";
echo "<table>";
echo "<tr>";
echo "<th>".i18n("Judges List");
@ -236,81 +236,46 @@ function switchjudgeinfo()
echo "</tr></table>";
/*
//mysql 4.0 does not support subqueries - it is supported as of mysql 4.1
//this means we cant use NOT IN (SELECT..) so, we will have to workaround this
//at least for now.
/* Load all the judges (judge_complete=yes, deleted=no, year=fairyear) */
$judgelist = judges_load_all();
$querystr="SELECT
judges.id,
judges.firstname,
judges.lastname
FROM
judges,
judges_years
WHERE
judges_years.year='".$config['FAIRYEAR']."' AND
judges.id=judges_years.judges_id AND
judges.id NOT IN (SELECT judges_id AS id FROM judges_teams_link WHERE judges_teams_link.year='".$config['FAIRYEAR']."')
ORDER BY
lastname,
firstname";
*/
$querystr="SELECT
judges.id,
judges.firstname,
judges.lastname
FROM
judges,
judges_years
WHERE
judges_years.year='".$config['FAIRYEAR']."' AND
judges.id=judges_years.judges_id AND
judges.complete='yes'
ORDER BY
lastname,
firstname";
$q=mysql_query($querystr);
$judgelist=array();
while($r=mysql_fetch_object($q)) {
$judgelist[$r->id]=$r;
/* Load all the teams */
$teams = array();
$q = mysql_query("SELECT * FROM judges_teams WHERE year='{$config['FAIRYEAR']}'");
while($i = mysql_fetch_assoc($q)) {
$teams[$i['id']] = $i;
}
if($_SESSION['viewstate']['judges_teams_list_show']=='unassigned')
{
$querystr="SELECT
judges.id,
judges.firstname,
judges.lastname
FROM
judges,
judges_teams_link,
judges_years
WHERE
judges_years.year='".$config['FAIRYEAR']."'
AND judges_teams_link.year='".$config['FAIRYEAR']."'
AND judges.id=judges_years.judges_id
AND judges.id=judges_teams_link.judges_id
AND judges.complete='yes'
ORDER BY
lastname,
firstname";
$q=mysql_query($querystr);
while($r=mysql_fetch_object($q)) {
//remove anyone we find here from the list of all judges
unset($judgelist[$r->id]);
/* And the links */
$links = array();
$q = mysql_query("SELECT * FROM judges_teams_link WHERE year='{$config['FAIRYEAR']}'");
while($i = mysql_fetch_assoc($q)) {
$judgelist[$i['users_id']]['teams_links'][] = $i;
}
$jlist = array();
if($_SESSION['viewstate']['judges_teams_list_show']=='unassigned') {
/* Remove all judges that have a link */
foreach($judgelist as $j) {
if(count($j['teams_links']) == 0) $jlist[] = $j['id'];
}
} else {
$jlist = array_keys($judgelist);
}
echo "<center>";
echo i18n("Listing %1 judges",array(count($judgelist)));
echo i18n("Listing %1 judges",array(count($jlist)));
echo "<br />";
echo "</center>";
echo mysql_error();
echo "<select name=\"judgelist[]\" onchange=\"switchjudgeinfo()\" multiple=\"multiple\" style=\"width: 250px; height: 600px;\">";
foreach($judgelist AS $r) {
if($r->firstname && $r->lastname)
echo "<option value=\"$r->id\">$r->firstname $r->lastname</option>\n";
foreach($jlist as $jid) {
$u = &$judgelist[$jid];
if($u['firstname'] && $u['lastname'])
echo "<option value=\"$jid\">{$u['firstname']} {$u['lastname']}</option>\n";
}
unset($u);
echo "</select>";
echo "</td>";
@ -318,8 +283,7 @@ function switchjudgeinfo()
$teams=getJudgingTeams();
foreach($teams AS $team)
{
foreach($teams AS $team) {
echo "<hr>";
echo "<table width=\"100%\">";
@ -336,8 +300,9 @@ function switchjudgeinfo()
{
foreach($team['members'] AS $member)
{
$j = &$judgelist[$member['id']];
echo "<tr><td>";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this judge from this team?')\" href=\"judges_teams_members.php?action=del&team_id=".$team['id']."&team_num=".$team['num']."&judges_id=".$member['id']."&team_name=".rawurlencode($team['name'])."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this judge from this team?')\" href=\"judges_teams_members.php?action=del&team_id=".$team['id']."&team_num=".$team['num']."&users_id=".$member['id']."&team_name=".rawurlencode($team['name'])."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td><td width=\"100%\">";
if($member['captain']=="yes")
{
@ -355,7 +320,10 @@ function switchjudgeinfo()
}
echo "<a href=\"\" onclick=\"return openjudgeinfo(".$member['id'].");\">";
echo $member['firstname']." ".$member['lastname'];
echo "</a> (".$member['languages'].")";
if(is_array($j['languages']))
$l = is_array($j['languages']) ? join(' ',$j['languages']) : '';
echo "</a> (<font size=-1>$l</font>)";
echo "</td></tr>";
}

View File

@ -22,22 +22,64 @@
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
require("judges.inc.php");
require_once('judges.inc.php');
send_header("Judging Teams Timeslots",
$round_str = array('timeslot' => 'Judging Timeslot',
'divisional1' => 'Divisional Round 1',
'divisional2' => 'Divisional Round 2',
'grand' => 'Grand Awards',
'special' => 'Special Awards' );
if(array_key_exists('action',$_GET))
$action = $_GET['action'];
if(array_key_exists('action',$_POST))
$action = $_POST['action'];
if($action == 'delete' && array_key_exists('delete', $_GET)) {
$id = intval($_GET['delete']);
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE id='$id'");
message_push(happy(i18n("Judging team timeslot successfully removed")));
}
if($action == 'empty' && array_key_exists('empty',$_GET)) {
$id = intval($_GET['empty']);
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id'");
message_push(happy(i18n("Judging team timeslots successfully removed")));
}
if($action == 'assign') {
//the db handles the uniqueness (to ensure the same timeslot isnt assigned to the same team more than once)
//so all we'll do here is just mass insert without regards for whats already there.
if(count($_POST['teams']) && count($_POST['timeslots'])) {
foreach($_POST['teams'] AS $tm) {
foreach($_POST['timeslots'] AS $ts) {
mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,year)
VALUES ('$tm','$ts','{$config['FAIRYEAR']}')");
}
}
message_push(happy(i18n("%1 Timeslots assigned to %2 teams",array(count($_POST['timeslots']),count($_POST['teams'])))));
} else {
message_push(error(i18n("You must select both team(s) and timeslot(s) to assign")));
}
}
send_header("Judging Teams Timeslots",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php')
);
?>
<script language="javascript" type="text/javascript">
function checkall(what)
{
for(i=0;i<document.forms.teamstimeslots.elements.length;i++)
{
for(i=0;i<document.forms.teamstimeslots.elements.length;i++) {
if(document.forms.teamstimeslots.elements[i].name==what+"[]")
document.forms.teamstimeslots.elements[i].checked=true;
@ -48,8 +90,7 @@ function checkall(what)
}
function checknone(what)
{
for(i=0;i<document.forms.teamstimeslots.elements.length;i++)
{
for(i=0;i<document.forms.teamstimeslots.elements.length;i++) {
if(document.forms.teamstimeslots.elements[i].name==what+"[]")
document.forms.teamstimeslots.elements[i].checked=false;
@ -60,8 +101,7 @@ function checknone(what)
function checkinvert(what)
{
for(i=0;i<document.forms.teamstimeslots.elements.length;i++)
{
for(i=0;i<document.forms.teamstimeslots.elements.length;i++) {
if(document.forms.teamstimeslots.elements[i].name==what+"[]")
document.forms.teamstimeslots.elements[i].checked=!document.forms.teamstimeslots.elements[i].checked;
@ -71,44 +111,10 @@ function checkinvert(what)
}
</script>
<?
echo "<br />";
if($_GET['action']=="delete" && $_GET['delete'])
{
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE id='".$_GET['delete']."'");
echo happy(i18n("Judging team timeslot successfully removed"));
}
if($_GET['action']=="empty" && $_GET['empty'])
{
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['empty']."'");
echo happy(i18n("Judging team timeslots successfully removed"));
}
if($_POST['action']=="assign")
{
//the db handles the uniqueness (to ensure the same timeslot isnt assigned to the same team more than once)
//so all we'll do here is just mass insert without regards for whats already there.
if(count($_POST['teams']) && count($_POST['timeslots']))
{
foreach($_POST['teams'] AS $tm)
{
foreach($_POST['timeslots'] AS $ts)
{
mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,year) VALUES ('$tm','$ts','".$config['FAIRYEAR']."')");
}
}
echo happy(i18n("%1 Timeslots assigned to %2 teams",array(count($_POST['timeslots']),count($_POST['teams']))));
}
else
echo error(i18n("You must select both team(s) and timeslot(s) to assign"));
}
echo "<form name=\"teamstimeslots\" method=\"post\" action=\"judges_teams_timeslots.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"assign\">";
@ -134,15 +140,23 @@ function checkinvert(what)
echo "<th>".i18n("End Time")."</th>";
echo "</tr>\n";
$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date,starttime");
while($r=mysql_fetch_object($q))
{
$q=mysql_query("SELECT * FROM judges_timeslots
WHERE year='{$config['FAIRYEAR']}'
AND round_id='0' ORDER BY date,starttime");
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td><input type=\"checkbox\" name=\"timeslots[]\" value=\"$r->id\" /></td>";
if($show_date) 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 "</tr>\n";
$span = $show_date ? 4 : 3;
echo "<td colspan=\"$span\">{$r->name} (".$round_str[$r->type].")</td>";
$qq = mysql_query("SELECT * FROM judges_timeslots
WHERE round_id='{$r->id}' ORDER BY date,starttime");
while($rr = mysql_fetch_object($qq)) {
echo "<tr>";
echo "<td><input type=\"checkbox\" name=\"timeslots[]\" value=\"{$rr->id}\" /></td>";
if($show_date) echo "<td>{$r->date}</td>";
echo "<td align=\"center\">".substr($rr->starttime,0,-3)."</td>";
echo "<td align=\"center\">".substr($rr->endtime,0,-3)."</td>";
echo "</tr>\n";
}
}
echo "</table>";

View File

@ -22,290 +22,378 @@
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
send_header("Judging Timeslots",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php')
);
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"));
$round_str = array('timeslot' => 'Judging Timeslot',
'divisional1' => 'Divisional Round 1',
'divisional2' => 'Divisional Round 2',
'grand' => 'Grand Awards',
'special' => 'Special Awards' );
if(array_key_exists('action',$_POST)) $action = $_POST['action'];
else if(array_key_exists('action',$_GET)) $action = $_GET['action'];
else $action = '';
if(array_key_exists('round_id',$_POST)) $round_id = intval($_POST['round_id']);
else if(array_key_exists('round_id',$_GET)) $round_id = intval($_GET['round_id']);
else $round_id = 0;
if(array_key_exists('timeslot_id',$_POST)) $timeslot_id = intval($_POST['timeslot_id']);
else if(array_key_exists('timeslot_id',$_GET)) $timeslot_id = intval($_GET['timeslot_id']);
else $timeslot_id = 0;
if($action == 'saveround') {
$save = true;
/* Sanity check all the values */
$y = intval($_POST['date_year']);
$m = intval($_POST['date_month']);
$d = intval($_POST['date_day']);
if($y && $m && $d) $date = "$y-$m-$d";
else {
$save = false;
message_push(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(array_key_exists('starttime_hour', $_POST) && array_key_exists('starttime_minute', $_POST)) {
$starttime = sprintf("%02d:%02d:00", intval($_POST['starttime_hour']), intval($_POST['starttime_minute']));
} else {
$save = false;
message_push( 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(array_key_exists('endtime_hour', $_POST) && array_key_exists('endtime_minute', $_POST)) {
$endtime = sprintf("%02d:%02d:00", intval($_POST['endtime_hour']), intval($_POST['endtime_minute']));
} else {
$save = false;
message_push( error(i18n("End Time is required")));
}
$allowdivisional=$_POST['allowdivisional'];
if(!$allowdivisional) $allowdivisional="no";
$type = $_POST['type'];
if(!array_key_exists($type, $round_str)) {
$save = false;
message_push(error(i18n('Invalid type specified')));
}
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"));
$name = mysql_escape_string(stripslashes($_POST['name']));
if($save == true) {
if($round_id == 0) {
/* New entry */
mysql_query("INSERT INTO judges_timeslots (round_id,year) VALUES('0','{$config['FAIRYEAR']}')");
$round_id = mysql_insert_id();
}
if($_POST['action']=="edit")
{
mysql_query("UPDATE judges_timeslots SET `date`='$date', starttime='$starttime', endtime='$endtime', allowdivisional='$allowdivisional' WHERE id='".$_POST['edit']."'");
echo mysql_error();
echo happy(i18n("Timeslot successfully saved"));
mysql_query("UPDATE judges_timeslots SET `date`='$date',
starttime='$starttime', endtime='$endtime',
`name`='$name',
`type`='$type' WHERE id='$round_id'");
echo mysql_error();
message_push(happy(i18n("Round successfully saved")));
$action = '';
}
}
if($action == 'deleteround') {
mysql_query("DELETE FROM judges_timeslots WHERE id='$round_id'");
/* Also delete all timeslots */
mysql_query("DELETE FROM judges_timeslots WHERE round_id='$round_id'");
message_push(happy(i18n("Round successfully removed")));
$action = '';
}
if($action == 'deletetimeslot') {
mysql_query("DELETE FROM judges_timeslots WHERE id='$timeslot_id'");
message_push(happy(i18n("Timeslot successfully removed")));
$action = '';
}
if($action == 'savetimeslot') {
$save = true;
$q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'");
$round_data = mysql_fetch_assoc($q);
$date = $round_data['date'];
if(array_key_exists('starttime_hour', $_POST) && array_key_exists('starttime_minute', $_POST)) {
$starttime = sprintf("%02d:%02d:00", intval($_POST['starttime_hour']), intval($_POST['starttime_minute']));
} else {
$save = false;
message_push( error(i18n("Start Time is required")));
}
if(array_key_exists('endtime_hour', $_POST) && array_key_exists('endtime_minute', $_POST)) {
$endtime = sprintf("%02d:%02d:00", intval($_POST['endtime_hour']), intval($_POST['endtime_minute']));
} else {
$save = false;
message_push( error(i18n("End Time is required")));
}
if($save == true) {
if($timeslot_id == 0) {
/* New entry */
mysql_query("INSERT INTO judges_timeslots (round_id,date,type,year) VALUES('$round_id',
'$date','timeslot','{$config['FAIRYEAR']}')");
$timeslot_id = mysql_insert_id();
}
mysql_query("UPDATE judges_timeslots SET starttime='$starttime', endtime='$endtime'
WHERE id='$timeslot_id'");
echo mysql_error();
message_push(happy(i18n("Timeslot successfully saved")));
$action = '';
}
}
else if($_POST['action']=="addmultiple")
{
if($_POST['addnum'] && $_POST['date_day'] && $_POST['date_month'] && $_POST['date_year'] && $_POST['starttime_hour'] && $_POST['starttime_minute'] && $_POST['duration'] && $_POST['break'])
{
$date=$_POST['date_year']."-".$_POST['date_month']."-".$_POST['date_day'];
$hr=$_POST['starttime_hour'];
$min=$_POST['starttime_minute'];
$dur=$_POST['duration'];
$brk=$_POST['break'];
$tt=$dur+$brk;
if($action=='savemultiple') {
$save = true;
$addnum = intval($_POST['addnum']);
$duration = intval($_POST['duration'] );
$break = intval($_POST['break']);
if($_POST['allowdivisional']=="yes") $ad="yes"; else $ad="no";
if(array_key_exists('starttime_hour', $_POST) && array_key_exists('starttime_minute',$_POST) && $addnum && $duration) {
$q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'");
$round_data = mysql_fetch_assoc($q);
for($x=0;$x<$_POST['addnum'];$x++)
{
$q=mysql_query("SELECT DATE_ADD('$date $hr:$min:00', INTERVAL $dur MINUTE) AS endtime,
DATE_ADD('$date $hr:$min:00', INTERVAL $tt MINUTE) AS startnext
");
echo mysql_error();
$date = $round_data['date'];
$hr=intval($_POST['starttime_hour']);
$min=intval($_POST['starttime_minute']);
$tt=$duration+$break;
for($x=0;$x<$addnum;$x++) {
$q=mysql_query("SELECT DATE_ADD('$date $hr:$min:00', INTERVAL $duration MINUTE) AS endtime,
DATE_ADD('$date $hr:$min:00', INTERVAL $tt MINUTE) AS startnext ");
echo mysql_error();
$r=mysql_fetch_object($q);
list($ed,$et)=split(" ",$r->endtime);
list($nd,$nt)=split(" ",$r->startnext);
mysql_query("INSERT INTO judges_timeslots (date,starttime,endtime,allowdivisional,year) VALUES (
'$date',
'$hr:$min:00',
'$et',
'$ad',
'".$config['FAIRYEAR']."')");
echo mysql_Error();
$starttime = sprintf("%02d:%02d:00", $hr, $min);
mysql_query("INSERT INTO judges_timeslots (date,type,round_id,starttime,endtime,year) VALUES (
'$date','timeslot','{$round_data['id']}',
'$starttime', '$et',
'{$config['FAIRYEAR']}')");
echo mysql_error();
$date=$nd;
list($s_h,$s_m,$s_s)=split(":",$nt);
list($e_h,$e_m,$e_s)=split(":",$et);
echo happy(i18n("Adding timeslot: %1",array($date." ".$hr.":".$min." - ".$e_h.":".$e_m)));
message_push(happy(i18n("Adding timeslot: %1",array("$date $hr:$min - $e_h:$e_m"))));
$hr=$s_h;
$min=$s_m;
}
$action = '';
} else {
message_push(error(i18n("All fields are required to add multiple timeslots")));
}
else
echo error(i18n("All fields are required to add multiple timeslots"));
}
if($action == '') {
send_header("Judging Rounds and Timeslots",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php'));
} else {
send_header("Judging Rounds and Timeslots",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php',
'Judging Rounds and Timeslots' => 'admin/judges_timeslots.php'));
}
echo "<br />";
if($action == 'addround' || $action == 'editround') {
echo "<form method=\"post\" action=\"judges_timeslots.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"saveround\">\n";
echo "<input type=\"hidden\" name=\"round_id\" value=\"$round_id\">\n";
if($action == 'addround') {
echo "<h3>Add New Judging Round</h3>";
$r = array();
$r['date'] = $config['dates']['fairdate'];
} else {
echo "<h3>Edit Judging Round</h3>";
$q=mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'");
if(mysql_num_rows($q) != 1) {
echo "UNKNOWN ROUND $round_id";
exit;
}
$r = mysql_fetch_assoc($q);
}
echo "<table>";
echo "<tr><td>".i18n('Round Type').":</td><td>";
echo "<select name=\"type\">";
foreach($round_str as $k=>$v) {
if($k == 'timeslot') continue; /* Don't let them add a timeslot directly */
$s = ($r['type'] == $k) ? 'selected="selected"' : '';
echo "<option value=\"$k\" $s>$v</option>";
}
echo "</select>";
echo "<tr><td>".i18n("Name").":</td><td>";
echo "<input type=\"textbox\" name=\"name\" value=\"{$r['name']}\" width=\"60\" /></td></tr>";
echo "<tr><td>".i18n("Date").":</td><td>";
emit_date_selector("date",$r['date']);
echo "</td></tr>";
echo "<tr><td>".i18n("Start Time").":</td><td>";
emit_time_selector("starttime",$r['starttime']);
echo "</td></tr>";
echo "<tr><td>".i18n("End Time").":</td><td>";
emit_time_selector("endtime",$r['endtime']);
echo "</td></tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n('Save')."\" />";
echo "</form>";
}
//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($action == 'addtimeslot' || $action == 'edittimeslot') {
echo "<form method=\"post\" action=\"judges_timeslots.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"savetimeslot\">\n";
echo "<input type=\"hidden\" name=\"round_id\" value=\"$round_id\">\n";
echo "<input type=\"hidden\" name=\"timeslot_id\" value=\"$timeslot_id\">\n";
$q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'");
$round_data = mysql_fetch_assoc($q);
if($action == 'addtimeslot') {
echo "<h3>Add New Judging Timeslot</h3>";
$r = array();
$r['date'] = $round_data['date'];
} else {
echo "<h3>Edit Judging Timeslot</h3>";
$q=mysql_query("SELECT * FROM judges_timeslots WHERE id='$timeslot_id'");
if(mysql_num_rows($q) != 1) {
echo "UNKNOWN ROUND $round_id";
exit;
}
$r = mysql_fetch_assoc($q);
}
echo "<table>";
echo "<tr><td>".i18n('Round Type').":</td><td>{$round_str[$round_data['type']]}</td></tr>";
echo "<tr><td>".i18n("Name").":</td><td>{$round_data['name']}</td></tr>";
echo "<tr><td>".i18n("Start Time").":</td><td>";
emit_time_selector("starttime",$r['starttime']);
echo "</td></tr>";
echo "<tr><td>".i18n("End Time").":</td><td>";
emit_time_selector("endtime",$r['endtime']);
echo "</td></tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n('Save')."\" />";
echo "</form>";
}
if($_GET['action']=="addmultiple")
{
if($action == 'addmultiple') {
echo "<h3>Add Multiple New Judging Timeslots</h3>";
echo "<a href=\"judges_timeslots.php\">&lt;&lt; ".i18n("Back to Judging Timeslots")."</a>\n";
$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;
}
else
{
$date=$config['dates']['fairdate'];
}
echo "<form method=\"post\" action=\"judges_timeslots.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"addmultiple\">\n";
echo "<table border=0>";
echo "<tr><td>";
echo i18n("Add");
echo "</td><td width=\"50\">";
echo "<input type=\"text\" name=\"addnum\" size=\"4\">";
echo "</td><td>";
echo "<input type=\"hidden\" name=\"action\" value=\"savemultiple\">\n";
echo "<input type=\"hidden\" name=\"round_id\" value=\"$round_id\">\n";
echo "<input type=\"hidden\" name=\"timeslot_id\" value=\"$timeslot_id\">\n";
$q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'");
$round_data = mysql_fetch_assoc($q);
echo "<table border=\"0\">";
echo "<tr><td>".i18n('Round Type').":</td><td>{$round_str[$round_data['type']]}</td></tr>";
echo "<tr><td>".i18n("Name").":</td><td>{$round_data['name']}</td></tr>";
echo "<tr><td>".i18n("Add")."</td><td>";
echo "<input type=\"text\" name=\"addnum\" size=\"4\">&nbsp;";
echo i18n("new timeslots");
echo "</td></tr><tr><td>";
echo i18n("On date");
echo "</td><td colspan=\"2\">";
emit_date_selector("date",$date);
echo "</td></tr><tr><td>";
echo i18n("Starting timeslots at");
echo "</td><td colspan=\"2\">";
echo "</td></tr>";
echo "<tr><td>".i18n("Starting timeslots at")."</td><td>";
emit_time_selector("starttime");
echo "</td></tr>";
echo "<tr><td>";
echo i18n("With a duration of");
echo "</td><td>";
echo "<input type=\"text\" name=\"duration\" size=\"4\">";
echo "</td><td>";
echo i18n("minutes");
echo "</td></tr>";
echo "<tr><td>";
echo i18n("And a break of");
echo "</td><td>";
echo "<input type=\"text\" name=\"break\" size=\"4\">";
echo "</td><td>";
echo i18n("minutes");
echo "</td></tr>";
echo "<tr><td>".i18n("With a duration of")."</td><td>";
echo "<input type=\"text\" name=\"duration\" size=\"4\">&nbsp;";
echo i18n("minutes")."</td></tr>";
echo "<tr><td>".i18n("And a break of")."</td><td>";
echo "<input type=\"text\" name=\"break\" size=\"4\">&nbsp;";
echo i18n("minutes")."</td></tr>";
echo "<tr><td align=\"center\">";
if($allowdivisional=="yes") $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"allowdivisional\" value=\"yes\">";
echo "</td><td colspan=\"2\">";
echo i18n("Allow this timeslot to be used by the automatic judges scheduler for divisional awards");
echo "</td></tr>";
echo "<tr><td colspan=\"3\">";
echo "<tr><td colspan=\"2\">";
echo "<input type=\"submit\" value=\"".i18n("Add these timeslots")."\">";
echo "</td></tr>";
echo "</table>";
echo "</form>";
$showlist=false;
}
else 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");
//get a default date, either the date from a different timeslot, or the date of the fair, whichever.
$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;
}
else
{
$date=$config['dates']['fairdate'];
}
$starttime="";
$endtime="";
$allowdivisional="yes";
}
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;
$allowdivisional=$r->allowdivisional;
}
echo "<table>";
echo "<tr><td>".i18n("Date").":</td><td>";
emit_date_selector("date",$date);
echo "</td></tr>";
echo "<tr><td>".i18n("Start Time").":</td><td>";
emit_time_selector("starttime",$starttime);
echo "</td></tr>";
echo "<tr><td>".i18n("End Time").":</td><td>";
emit_time_selector("endtime",$endtime);
echo "</td></tr>";
echo "<tr><td align=\"center\">";
if($allowdivisional=="yes") $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"allowdivisional\" value=\"yes\">";
echo "</td><td>";
echo i18n("Allow this timeslot to be used by the automatic judges scheduler for divisional awards");
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 "<A href=\"judges_timeslots.php?action=addmultiple\">".i18n("Add multiple new judging timeslots")."</a><br />";
if($action == '') {
echo "<A href=\"judges_timeslots.php?action=addround&round_id=0\">".i18n("Add new round")."</a> <br />";
echo "<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("Div OK?")."</th>";
echo "<th>".i18n("Judging Round")."</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))
{
$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='{$config['FAIRYEAR']}' AND `type`!='timeslot' 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\">$r->allowdivisional</td>";
$qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r->id}' ORDER BY `date`,`starttime`");
$c = mysql_num_rows($qq) +1;
echo "<td rowspan=\"$c\"><b>$r->date</b></td>";
echo "<td align=\"center\"><b>".substr($r->starttime,0,-3)."</b><br/>";
echo "</td>";
echo "<td align=\"center\"><b>".substr($r->endtime,0,-3)."</b></td>";
echo "<td align=\"center\"><b>{$r->name} (".i18n($round_str[$r->type]).")</b></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 "<a href=\"judges_timeslots.php?action=editround&round_id={$r->id}\"><img border=\"0\" src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\"></a>";
echo "&nbsp;";
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 "<a onclick=\"return confirmClick('Are you sure you want to remove this round?')\" href=\"judges_timeslots.php?action=deleteround&round_id={$r->id}\"><img border=\"0\" src=\"{$config['SFIABDIRECTORY']}/images/16/button_cancel.{$config['icon_extension']}\"></a>";
echo "<A href=\"judges_timeslots.php?action=addtimeslot&round_id={$r->id}\">(new)</a> ";
echo "<A href=\"judges_timeslots.php?action=addmultiple&round_id={$r->id}\">(multiple)</a><br />";
echo " </td>\n";
echo "</tr>";
while($rr = mysql_fetch_object($qq)) {
echo "<tr>";
// echo "<td></td>";
echo "<td align=\"right\">".substr($rr->starttime,0,-3)."</td>";
echo "<td align=\"right\">".substr($rr->endtime,0,-3)."</td>";
echo "<td align=\"center\">".i18n($round_str[$rr->type])."</td>";
echo " <td align=\"center\">";
echo "<a href=\"judges_timeslots.php?action=edittimeslot&round_id={$r->id}&timeslot_id={$rr->id}\"><img border=\"0\" src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\"></a>";
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this timeslot?')\" href=\"judges_timeslots.php?action=deletetimeslot&timeslot_id={$rr->id}\"><img border=\"0\" src=\"{$config['SFIABDIRECTORY']}/images/16/button_cancel.{$config['icon_extension']}\"></a>";
echo " </td>\n";
echo "</tr>";
}
}
echo "</table>";
echo "</table>";
}
send_footer();

View File

@ -48,6 +48,7 @@
array('key' => 'project', 'val' => "Project")
) );
$editor->setFieldInputType("per", 'select');
$editor->filterList('year',$config['FAIRYEAR']);
$editor->execute();

View File

@ -667,6 +667,10 @@ foreach($report_stock as $n=>$v) {
}
$t = $filter_ops[$d['x']];
$filter[] = "{$fields[$f]['table']} $t '{$d['value']}'";
if(is_array($fields[$f]['components'])) {
$components = array_merge($components,
$fields[$f]['components']);
}
}
$sel = implode(",", $sel);
$order = implode(",", $order);

View File

@ -40,7 +40,7 @@
if($action == 'unlink') {
$id = intval($_GET['id']);
mysql_query("DELETE FROM reports_committee WHERE
users_id='{$_SESSION['users_id']}' AND id='$id'");
users_id='{$_SESSION['users_uid']}' AND id='$id'");
$_SESSION['messages'][] = 'unlinked';
header("Location: reports.php?edit=1");
exit;
@ -87,7 +87,7 @@
mysql_query("INSERT INTO `reports_committee`
(`id`, `users_id` , `reports_id` , `category` , `comment` , `format` , `stock`)
VALUES (
NULL , '{$_SESSION['users_id']}',
NULL , '{$_SESSION['users_uid']}',
'$reports_id', '$category', '$comment',
'$type', '$stock' );");
$_SESSION['messages'][] = 'added';
@ -139,7 +139,7 @@
$q = mysql_query("SELECT reports_committee.*,reports.name
FROM reports_committee
LEFT JOIN reports ON reports.id=reports_committee.reports_id
WHERE users_id='{$_SESSION['users_id']}'
WHERE users_id='{$_SESSION['users_uid']}'
ORDER BY category,id");
echo mysql_error();
if(mysql_num_rows($q) == 0) {
@ -354,7 +354,7 @@
echo "<tr><td>".i18n("Category").":</td><td>";
$q = mysql_query("SELECT DISTINCT category FROM reports_committee
WHERE users_id='{$_SESSION['users_id']}'
WHERE users_id='{$_SESSION['users_uid']}'
ORDER BY category");
echo i18n("Existing Category").": <select name=\"category_exist\">";

View File

@ -55,16 +55,16 @@
award_awards.description,
award_awards.order AS awards_order,
award_types.type,
award_sponsors.organization
sponsors.organization
FROM
award_awards,
award_types,
award_sponsors
sponsors
WHERE
award_awards.year='$foryear'
AND award_types.year='$foryear'
AND award_awards.award_types_id=award_types.id
AND award_awards.award_sponsors_id=award_sponsors.id
AND award_awards.sponsors_id=sponsors.id
AND award_awards.excludefromac='0'
$awardtype
ORDER BY awards_order");

View File

@ -63,88 +63,88 @@ $report_awards_fields = array(
'name' => 'Sponsor -- Organization',
'header' => 'Sponsor Organization',
'width' => 2.0,
'table' => 'award_sponsors.organization' ),
'table' => 'sponsors.organization' ),
'sponsor_phone' => array(
'name' => 'Sponsor -- Phone',
'header' => 'Sp. Phone',
'width' => 1,
'table' => 'award_sponsors.phone' ),
'table' => 'sponsors.phone' ),
'sponsor_fax' => array(
'name' => 'Sponsor -- Fax',
'header' => 'Sp. Fax',
'width' => 1,
'table' => 'award_sponsors.fax' ),
'table' => 'sponsors.fax' ),
'sponsor_address' => array(
'name' => 'Sponsor -- Street Address',
'header' => 'Sponsor Address',
'width' => 2.0,
'table' => 'award_sponsors.address'),
'table' => 'sponsors.address'),
'sponsor_city' => array(
'name' => 'Sponsor -- City',
'header' => 'Sp. City',
'width' => 1.5,
'table' => 'award_sponsors.city' ),
'table' => 'sponsors.city' ),
'sponsor_province' => array(
'name' => 'Sponsor -- '.$config['provincestate'],
'header' => 'Sp. '.$config['provincestate'],
'width' => 0.75,
'table' => 'award_sponsors.province_code' ),
'table' => 'sponsors.province_code' ),
'sponsor_postal' => array(
'name' => 'Sponsor -- '.$config['postalzip'],
'header' => 'Sp. '.$config['postalzip'],
'width' => 0.75,
'table' => 'award_sponsors.postalcode' ),
'table' => 'sponsors.postalcode' ),
'sponsor_notes' => array(
'name' => 'Sponsor -- Notes',
'header' => 'Sponsor Notes',
'width' => 3,
'table' => 'award_sponsors.notes' ),
'table' => 'sponsors.notes' ),
'sponsor_confirmed' => array(
'name' => 'Sponsor -- Confirmed',
'header' => 'Sp. Confirmed',
'sponsorship_status' => array(
'name' => 'Sponsorship -- Status',
'header' => 'Sp. Status',
'width' => .5,
'table' => 'award_sponsors.confirmed',
'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
'table' => 'sponsorships.status',
'value_map' => array ('pending' => 'Pending', 'confirmed' => 'Confirmed'), "received"=>"Received"),
'pcontact_salutation' => array(
'name' => 'Primary Contact -- Salutation',
'header' => 'Cnct. Salutation',
'width' => 1.0,
'table' => 'PRIMARYCONTACT.salutation' ),
'table' => 'PRIMARYCONTACTUSER.salutation' ),
'pcontact_last_name' => array(
'name' => 'Primary Contact -- Last Name',
'header' => 'Cnct. Last Name',
'width' => 1.0,
'table' => 'PRIMARYCONTACT.lastname' ),
'table' => 'PRIMARYCONTACTUSER.lastname' ),
'pcontact_first_name' => array(
'name' => 'Primary Contact -- First Name',
'header' => 'Cnct. First Name',
'width' => 1.0,
'table' => 'PRIMARYCONTACT.firstname' ),
'table' => 'PRIMARYCONTACTUSER.firstname' ),
'pcontact_name' => array(
'name' => 'Primary Contact -- Full Name (last, first)',
'header' => 'Contact Name',
'width' => 1.75,
'table' => "CONCAT(PRIMARYCONTACT.lastname, ', ', PRIMARYCONTACT.firstname)",
'table_sort'=> 'PRIMARYCONTACT.lastname' ),
'table' => "CONCAT(PRIMARYCONTACTUSER.lastname, ', ', PRIMARYCONTACTUSER.firstname)",
'table_sort'=> 'PRIMARYCONTACTUSER.lastname' ),
'pcontact_namefl' => array(
'name' => 'Primary Contact -- Full Name (salutation first last)',
'header' => 'Contact Name',
'width' => 1.75,
'table' => "CONCAT(PRIMARYCONTACT.salutation, ' ', PRIMARYCONTACT.firstname, ' ', PRIMARYCONTACT.lastname)",
'table_sort'=> 'PRIMARYCONTACT.lastname' ),
'table' => "CONCAT(PRIMARYCONTACTUSER.salutation, ' ', PRIMARYCONTACTUSER.firstname, ' ', PRIMARYCONTACTUSER.lastname)",
'table_sort'=> 'PRIMARYCONTACTUSER.lastname' ),
'pcontact_position' => array(
'name' => 'Primary Contact -- Position',
@ -156,37 +156,37 @@ $report_awards_fields = array(
'name' => 'Primary Contact -- Email',
'header' => 'Cnct. Email',
'width' => 2.0,
'table' => 'PRIMARYCONTACT.email'),
'table' => 'PRIMARYCONTACTUSER.email'),
'pcontact_hphone' => array(
'name' => 'Primary Contact -- Home Phone',
'header' => 'Cnct. Home',
'width' => 1,
'table' => 'PRIMARYCONTACT.phonehome' ),
'table' => 'PRIMARYCONTACTUSER.phonehome' ),
'pcontact_wphone' => array(
'name' => 'Primary Contact -- Work Phone',
'header' => 'Cnct. Work',
'width' => 1,
'table' => 'PRIMARYCONTACT.phonework' ),
'table' => 'PRIMARYCONTACTUSER.phonework' ),
'pcontact_cphone' => array(
'name' => 'Primary Contact -- Cell Phone',
'header' => 'Cnct. Cell',
'width' => 1,
'table' => 'PRIMARYCONTACT.phonecell' ),
'table' => 'PRIMARYCONTACTUSER.phonecell' ),
'pcontact_fax' => array(
'name' => 'Primary Contact -- Fax',
'header' => 'Cnct. Fax',
'width' => 1,
'table' => 'PRIMARYCONTACT.fax' ),
'table' => 'PRIMARYCONTACTUSER.fax' ),
'pcontact_notes' => array(
'name' => 'Primary Contact -- Notes',
'header' => 'Contact Notes',
'width' => 3,
'table' => 'PRIMARYCONTACT.notes' ),
'table' => 'PRIMARYCONTACTUSER.notes' ),
'judgeteamname' => array(
'components' => array('judgingteam'),
@ -248,12 +248,14 @@ $report_awards_fields = array(
$q = " FROM award_awards
LEFT JOIN award_sponsors ON (
award_sponsors.id=award_awards.award_sponsors_id)
LEFT JOIN sponsors ON (
sponsors.id=award_awards.sponsors_id)
LEFT JOIN award_types ON award_types.id=award_types_id
LEFT JOIN award_contacts AS PRIMARYCONTACT ON (
PRIMARYCONTACT.award_sponsors_id=award_sponsors.id
LEFT JOIN users_sponsor AS PRIMARYCONTACT ON (
PRIMARYCONTACT.sponsors_id=sponsors.id
AND PRIMARYCONTACT.`primary`='yes')
LEFT JOIN users AS PRIMARYCONTACTUSER ON (
PRIMARYCONTACT.users_id=PRIMARYCONTACTUSER.id)
$judges_join
$judges_members_join
WHERE

View File

@ -73,7 +73,7 @@
echo '<tr><td colspan="2"><hr /></td></tr>';
/* See if the report is in this committee member's list */
$q = mysql_query("SELECT * FROM reports_committee
WHERE users_id='{$_SESSION['users_id']}'
WHERE users_id='{$_SESSION['users_uid']}'
AND reports_id='{$report['id']}'");
echo "<tr><td colspan=\"2\"><h4>".i18n('My Reports Info')."</h4></td></tr>";
if(mysql_num_rows($q) > 0) {

View File

@ -21,6 +21,17 @@
Boston, MA 02111-1307, USA.
*/
/* Take the language array in users_judge, unserialize it, and join it
* with a space */
function report_judges_languages(&$report, $text)
{
$l = unserialize($text);
return join(' ', $l);
}
/* Components: languages, teams */
$report_judges_fields = array(
@ -28,90 +39,91 @@ $report_judges_fields = array(
'name' => 'Judge -- Last Name',
'header' => 'Last Name',
'width' => 1.0,
'table' => 'judges.lastname' ),
'table' => 'users.lastname' ),
'first_name' => array(
'name' => 'Judge -- First Name',
'header' => 'First Name',
'width' => 1.0,
'table' => 'judges.firstname' ),
'table' => 'users.firstname' ),
'name' => array(
'name' => 'Judge -- Full Name (last, first)',
'header' => 'Name',
'width' => 1.75,
'table' => "CONCAT(judges.lastname, ', ', judges.firstname)",
'table_sort'=> 'judges.lastname' ),
'table' => "CONCAT(users.lastname, ', ', users.firstname)",
'table_sort'=> 'users.lastname' ),
'namefl' => array(
'name' => 'Judge -- Full Name (first last)',
'header' => 'Name',
'width' => 1.75,
'table' => "CONCAT(judges.firstname, ' ', judges.lastname)",
'table_sort'=> 'judges.lastname' ),
'table' => "CONCAT(users.firstname, ' ', users.lastname)",
'table_sort'=> 'users.lastname' ),
'email' => array(
'name' => 'Judge -- Email',
'header' => 'Email',
'width' => 2.0,
'table' => 'judges.email'),
'table' => 'users.email'),
'address' => array(
'name' => 'Judge -- Address Street',
'header' => 'Address',
'width' => 2.0,
'table' => "CONCAT(judges.address, ' ', judges.address2)"),
'table' => "CONCAT(users.address, ' ', users.address2)"),
'city' => array(
'name' => 'Judge -- Address City',
'header' => 'City',
'width' => 1.5,
'table' => 'judges.city' ),
'table' => 'users.city' ),
'province' => array(
'name' => 'Judge -- Address '.$config['provincestate'],
'header' => $config['provincestate'],
'width' => 0.75,
'table' => 'judges.province' ),
'table' => 'users.province' ),
'postal' => array(
'name' => 'Judge -- Address '.$config['postalzip'],
'header' => $config['postalzip'],
'width' => 0.75,
'table' => 'judges.postalcode' ),
'table' => 'users.postalcode' ),
'phone_home' => array(
'name' => 'Judge -- Phone (Home)',
'header' => 'Phone(Home)',
'width' => 1,
'table' => 'judges.phonehome'),
'table' => 'users.phonehome'),
'phone_work' => array(
'name' => 'Judge -- Phone (Work)',
'header' => 'Phone(Work)',
'width' => 1.25,
'table' => "CONCAT(judges.phonework, ' ', judges.phoneworkext)"),
'table' => "users.phonework"),
'organization' => array(
'name' => 'Judge -- Organization',
'header' => 'Organization',
'width' => 2,
'table' => 'judges.organization'),
'table' => 'users.organization'),
'languages' => array(
'name' => 'Judge -- Languages (REQUIRES MySQL 5.0)',
'name' => 'Judge -- Languages',
'header' => 'Lang',
'width' => 0.75,
'table' => "GROUP_CONCAT(judges_languages.languages_lang ORDER BY judges_languages.languages_lang SEPARATOR ' ')",
'group_by' => array('judges.id'),
'components' => array('languages')),
'table' => 'users_judge.languages',
'exec_function' => 'report_judges_languages',
'components' => array('users_judge')),
'complete' => array(
'name' => 'Judge -- Registration Complete',
'header' => 'Cmpl',
'width' => 0.4,
'table' => 'judges.complete',
'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
'table' => 'users_judge.judge_complete',
'value_map' => array ('no' => 'No', 'yes' => 'Yes'),
'components' => array('users_judge')),
'typepref' => array(
'name' => 'Judge -- Type Preference',
@ -123,7 +135,7 @@ $report_judges_fields = array(
'name' => 'Judge -- Year',
'header' => 'Year',
'width' => 0.5,
'table' => 'judges_years.year'),
'table' => 'users.year'),
'captain' => array(
'name' => 'Judge Team -- Captain?',
@ -180,7 +192,7 @@ $report_judges_fields = array(
'header' => 'Student(s)',
'width' => 3.0,
'table' => "GROUP_CONCAT(students.firstname, ' ', students.lastname ORDER BY students.lastname SEPARATOR ', ')",
'group_by' => array('judges.id','judges_teams_timeslots_projects_link.id'),
'group_by' => array('users.id','judges_teams_timeslots_projects_link.id'),
'components' => array('teams', 'projects', 'students')),
'project_timeslot_start' => array(
@ -226,17 +238,14 @@ $report_judges_fields = array(
$fields = $report_judges_fields;
$year = $report['year'];
/* For now languages is a module, doesn't duplicate rows, but it requries mysql 5 for
* a GROUP_CONCAT */
$languages_from = '';
if(in_array('languages', $components)) {
$languages_from = 'LEFT JOIN judges_languages ON judges_languages.judges_id=judges.id';
if(in_array('users_judge', $components)) {
$uj_from = 'LEFT JOIN users_judge ON users_judge.users_id=users.id';
}
$teams_from = '';
$teams_where = '';
if(in_array('teams', $components)) {
$teams_from = "LEFT JOIN judges_teams_link ON judges_teams_link.judges_id=judges.id
$teams_from = "LEFT JOIN judges_teams_link ON judges_teams_link.users_id=users.id
LEFT JOIN judges_teams ON judges_teams.id=judges_teams_link.judges_teams_id";
$teams_where = "AND judges_teams_link.year='$year'
AND judges_teams.year='$year'";
@ -261,22 +270,21 @@ $report_judges_fields = array(
}
/* Search the report for a filter based on judge year */
$year_where = "judges_years.year='$year'";
$year_where = "AND users.year='$year'";
foreach($report['filter'] as $d) {
if($d['field'] == 'year') {
/* Don't interally filter on year, we'll do it
* externally */
$year_where = '1';
/* Don't interally filter on year, we'll do it externally */
$year_where = '';
}
}
$q = " FROM judges
LEFT JOIN judges_years ON judges_years.judges_id = judges.id
$languages_from
$q = " FROM users
$teams_from
$projects_from
$students_from
$uj_from
WHERE
users.types LIKE '%judge%'
$year_where
$teams_where
$projects_where

View File

@ -213,6 +213,12 @@ $report_students_fields = array(
'width' => 2.0,
'table' => 'students.foodreq'),
'registrations_num' => array(
'name' => 'Student -- Registration Number',
'header' => 'RegNum',
'width' => 1,
'table' => 'registrations.num' ),
'title' => array(
'name' => 'Project -- Title',
'header' => 'Project Title',
@ -232,6 +238,12 @@ $report_students_fields = array(
'width' => 3.0,
'table' => 'projectdivisions.division' ),
'div' => array(
'name' => 'Project -- Division Short Form' ,
'header' => 'Div',
'width' => 0.4,
'table' => 'projectdivisions.division_shortform' ),
'fr_division' => array(
'name' => 'Project -- Division (French)',
'header' => i18n('Division', array(), array(), 'fr'),
@ -239,12 +251,6 @@ $report_students_fields = array(
'table' => 'projectdivisions.division',
'exec_function' => 'report_students_i18n_fr'),
'div' => array(
'name' => 'Project -- Division Short Form' ,
'header' => 'Div',
'width' => 0.4,
'table' => 'projectdivisions.division_shortform' ),
'category' => array(
'name' => 'Project -- Category',
'header' => 'Category',
@ -252,6 +258,12 @@ $report_students_fields = array(
'table_sort' => 'projectcategories.id',
'table' => 'projectcategories.category' ),
'cat' => array(
'name' => 'Project -- Category Short Form' ,
'header' => 'cat',
'width' => 0.4,
'table' => 'projectcategories.category_shortform' ),
'fr_category' => array(
'name' => 'Project -- Category (French)',
'header' => i18n('Category', array(), array(), 'fr'),
@ -267,6 +279,13 @@ $report_students_fields = array(
'table_sort' => 'projectcategories.id',
'table' => "CONCAT(projectcategories.category,' - ', projectdivisions.division)"),
'divisioncategory' => array(
'name' => 'Project -- Division and Category',
'header' => 'Division/Category',
'width' => 3.5,
'table_sort' => 'projectdivisions.id',
'table' => "CONCAT(projectdivisions.division,' - ',projectcategories.category)"),
'summary' => array(
'name' => 'Project -- Summary',
'header' => 'Project Summary',
@ -500,6 +519,28 @@ $report_students_fields = array(
OR award_prizes.trophyschoolreturn=1, 'Yes', 'No')",
'components' => array('awards')),
'award_prize_trophy_return' => array(
'name' => 'Award -- Annual Trophy (\'Yes\' if the award has a school or student trophy that isn\'t a keeper)',
'header' => 'Trophy',
'width' => 0.5,
'table' => "IF ( award_prizes.trophystudentreturn=1
OR award_prizes.trophyschoolreturn=1, 'Yes', 'No')",
'components' => array('awards')),
'award_prize_trophy_return_student' => array(
'name' => 'Award -- Annual Student Trophy (\'Yes\' if the award has astudent trophy that isn\'t a keeper)',
'header' => 'Ind.',
'width' => 0.5,
'table' => "IF ( award_prizes.trophystudentreturn=1, 'Yes', 'No')",
'components' => array('awards')),
'award_prize_trophy_return_school' => array(
'name' => 'Award -- Annual School Trophy (\'Yes\' if the award has a school trophy that isn\'t a keeper)',
'header' => 'Sch.',
'width' => 0.5,
'table' => "IF ( award_prizes.trophyschoolreturn=1, 'Yes', 'No')",
'components' => array('awards')),
'nom_awards' => array(
'name' => 'Award Nominations -- Award Name (warning: duplicates student for multiple awards!)',
'header' => 'Award Name',

View File

@ -87,6 +87,14 @@ $report_volunteers_fields = array(
'table' => 'users.cpr',
'value_map' =>array ('no' => 'no', 'yes' => 'YES')),
'complete' => array(
'name' => 'Volunteer -- Registration Complete',
'header' => 'Cmpl',
'width' => 0.4,
'table' => 'users_volunteer.volunteer_complete',
'value_map' => array ('no' => 'No', 'yes' => 'Yes'),
'components' => array('users_volunteer')),
'position_name' => array (
'name' => 'Volunteer Position -- Name',
'header' => 'Position',
@ -94,12 +102,6 @@ $report_volunteers_fields = array(
'table' => 'volunteer_positions.name',
'components' => array('signup')),
/* 'language' => array(
'name' => 'Project -- Language',
'header' => 'Lang',
'width' => 1.00,
'table' => 'projects.language' ),
*/
'fair_year' => array (
'name' => 'Fair -- Year',
'header' => 'Year',
@ -127,6 +129,10 @@ $report_volunteers_fields = array(
$fields = $report_volutneers_fields;
$year = $report['year'];
if(in_array('users_volunteer', $components)) {
$uv_from = 'LEFT JOIN users_volunteer ON users_volunteer.users_id=users.id';
}
$signup_join = '';
$signup_where = '';
@ -135,18 +141,21 @@ $report_volunteers_fields = array(
ON (users.id=volunteer_positions_signup.users_id)
LEFT JOIN volunteer_positions
ON (volunteer_positions_signup.volunteer_positions_id=volunteer_positions.id)";
$signup_where = "AND volunteer_positions_signup.year = '$year'";
$signup_where = "AND (volunteer_positions_signup.year = '$year' OR volunteer_positions_signup.year IS NULL)";
}
$q = " FROM
users
$signup_join
$uv_from
WHERE
users.complete='yes'
users.types LIKE '%volunteer%'
AND users.year='$year'
$signup_where
";
return $q;
}
?>

View File

@ -37,10 +37,12 @@
else
$id=$_POST['id'];
$atrisk = $_POST['atrisk'] == 'yes' ? 'yes' : 'no';
$exec="UPDATE schools SET ".
"school='".mysql_escape_string(stripslashes($_POST['school']))."', ".
"schoollang='".mysql_escape_string(stripslashes($_POST['schoollang']))."', ".
"designate='".mysql_escape_string(stripslashes($_POST['schooldesignate']))."', ".
"schoollevel='".mysql_escape_string(stripslashes($_POST['schoollevel']))."', ".
"school='".mysql_escape_string(stripslashes($_POST['school']))."', ".
"board='".mysql_escape_string(stripslashes($_POST['board']))."', ".
@ -59,7 +61,8 @@
"registration_password='".mysql_escape_string(stripslashes($_POST['registration_password']))."', ".
"projectlimit='".mysql_escape_string(stripslashes($_POST['projectlimit']))."', ".
"projectlimitper='".mysql_escape_string(stripslashes($_POST['projectlimitper']))."', ".
"accesscode='".mysql_escape_string(stripslashes($_POST['accesscode']))."' ".
"accesscode='".mysql_escape_string(stripslashes($_POST['accesscode']))."', ".
"atrisk='$atrisk' ".
"WHERE id='$id'";
mysql_query($exec);
echo mysql_error();
@ -134,6 +137,16 @@
echo "</select>";
echo "</td></tr>\n";
echo "<tr><td>".i18n("School Designation")."</td><td>";
$des = array('' => 'Choose', 'public' => 'Public',
'independent' => 'Independent/Private',
'home' => 'Home School');
echo "<select name=\"schooldesignate\">";
foreach($des as $k=>$v) {
$sel=($r->designate == $k) ?'selected="selected"' : '';
echo "<option $sel value=\"$k\">".i18n($v)."</option>\n";
}
echo "</select></td></tr>\n";
echo "<tr><td>".i18n("School Level")."</td><td><input type=\"text\" name=\"schoollevel\" value=\"".htmlspecialchars($r->schoollevel)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("School Board")."</td><td><input type=\"text\" name=\"board\" value=\"".htmlspecialchars($r->board)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><td>".i18n("School District")."</td><td><input type=\"text\" name=\"district\" value=\"".htmlspecialchars($r->district)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
@ -181,6 +194,10 @@
}
echo "<tr><td colspan=2><br /><b>".i18n("Demographic Information")."</b></td></tr>";
$ch = ($r->atrisk) == 'yes' ? 'checked="checked"' : '';
echo "<tr><td align=\"right\"><input type=\"checkbox\" name=\"atrisk\" value=\"yes\" $ch /></td><td>".i18n("Inner City or At-Risk school")."</td></tr>\n";
echo "<tr><td colspan=\"2\">&nbsp;</td></tr>";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";

39
admin/sciencefairs.php Normal file
View File

@ -0,0 +1,39 @@
<?
/*
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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Science Fair Management",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"sciencefair_management"
);
echo "<br />";
echo "<a href=\"user_list.php?show_types[]=fair\">".i18n("Science Fair Manager")."</a><br />";
send_footer();
?>

230
admin/sponsor_contacts.php Normal file
View File

@ -0,0 +1,230 @@
<?
/*
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-2008 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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Sponsor Contacts",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Sponsors' => 'admin/sponsors.php'));
if($_GET['sponsors_id'])
$sponsors_id=$_GET['sponsors_id'];
else if($_POST['sponsors_id'])
$sponsors_id=$_POST['sponsors_id'];
?>
<?
$q=mysql_query("SELECT id,organization FROM sponsors ORDER BY organization");
echo "<form method=\"get\" action=\"sponsor_contacts.php\" name=\"sponsorchange\">";
echo "<select name=\"sponsors_id\" onchange=\"document.forms.sponsorchange.submit()\">";
echo "<option value=\"\">".i18n("Choose a sponsor to view contacts")."</option>";
while($r=mysql_fetch_object($q))
{
if($r->id == $sponsors_id)
{
$sel="selected=\"selected\"";
$sponsors_organization=$r->organization;
}
else
$sel="";
echo "<option $sel value=\"$r->id\">".i18n($r->organization)."</option>";
}
echo "</select>";
echo "</form>";
if($sponsors_id)
{
if($_POST['save']=="edit" || $_POST['save']=="add")
{
$p = ($_POST['primary']=='yes')?'yes':'no';
if($_POST['save']=="add") {
$u=user_create("sponsor", $_POST['email']);
$id=$u['id'];
}
else {
$u=user_load($_POST['id']);
$id=intval($_POST['id']);
}
if($p == 'no') {
/* Make sure this sponsor ($sponsors_id) has a primary */
$q = mysql_query("SELECT users_id
FROM users_sponsor, users
WHERE
users_sponsor.users_id=users.id
AND sponsors_id='$sponsors_id'
AND `primary`='yes'
AND year='".$config['FAIRYEAR']."'
AND users_id!='$id'");
if(mysql_num_rows($q) == 0) {
/* This must be the primary */
$p = 'yes';
}
} else {
/* Unset all other primaries */
mysql_query("UPDATE users_sponsor SET `primary`='no'
WHERE sponsors_id='$sponsors_id'");
}
$u['primary']=$p;
$u['salutation']=$_POST['salutation'];
$u['firstname']=$_POST['firstname'];
$u['lastname']=$_POST['lastname'];
$u['position']=$_POST['position'];
$u['phonework']=$_POST['phonework'];
$u['phonecell']=$_POST['phonecell'];
$u['phonehome']=$_POST['phonehome'];
$u['fax']=$_POST['fax'];
$u['email']=$_POST['email'];
$u['notes']=$_POST['notes'];
$u['sponsors_id']=$sponsors_id;
user_save($u);
if($_POST['save']=="add")
echo happy(i18n("Contact successfully added"));
else
echo happy(i18n("Successfully saved changes to contact"));
}
if($_GET['action']=="delete" && $_GET['delete']) {
user_delete(intval($_GET['delete']));
echo happy("Contact successfully deleted");
}
if($_GET['action']=="edit" || $_GET['action']=="add")
{
echo "<a href=\"sponsor_contacts.php?sponsors_id=$sponsors_id\">&lt;&lt; ".i18n("Back to %1 Contacts",array($sponsors_organization))."</a>\n";
if($_GET['action']=="edit")
{
echo "<h3>".i18n("Edit %1 Contact",array($sponsors_organization))."</h3>\n";
$buttontext="Save Contact";
// $q=mysql_query("SELECT * FROM sponsor_contacts WHERE id='".$_GET['edit']."'");
// $r=mysql_fetch_object($q);
$u=user_load(intval($_GET['edit']));
}
else if($_GET['action']=="add")
{
echo "<h3>".i18n("Add %1 Contact",array($sponsors_organization))."</h3>\n";
$buttontext="Add Contact";
}
$buttontext=i18n($buttontext);
echo "<form method=\"post\" action=\"sponsor_contacts.php\">\n";
echo "<input type=\"hidden\" name=\"sponsors_id\" value=\"$sponsors_id\">\n";
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
if($_GET['action']=="edit")
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Salutation")."</td><td><input type=\"text\" name=\"salutation\" value=\"".htmlspecialchars($u['salutation'])."\" size=\"4\" maxlength=\"8\" /></td></tr>\n";
echo "<tr><td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname\" value=\"".htmlspecialchars($u['firstname'])."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname\" value=\"".htmlspecialchars($u['lastname'])."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Position")."</td><td><input type=\"text\" name=\"position\" value=\"".htmlspecialchars($u['position'])."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone (Work)")."</td><td><input type=\"text\" name=\"phonework\" value=\"".htmlspecialchars($u['phonework'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone (Cell)")."</td><td><input type=\"text\" name=\"phonecell\" value=\"".htmlspecialchars($u['phonecell'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Phone (Home)")."</td><td><input type=\"text\" name=\"phonehome\" value=\"".htmlspecialchars($u['phonehome'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Fax")."</td><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($u['fax'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><td>".i18n("Email")."</td><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($u['email'])."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><td>".i18n("Notes")."</td><td><textarea name=\"notes\" rows=\"8\" cols=\"60\">".htmlspecialchars($u['notes'])."</textarea></td></tr>\n";
echo "<tr><td>".i18n("Primary Contact")."</td><td><select name=\"primary\">";
$sel = ($u['primary'] == 'yes') ? 'selected="selected"': '';
echo "<option value=\"yes\" $sel>".i18n('Yes')."</option>";
$sel = ($u['primary'] == 'no') ? 'selected="selected"': '';
echo "<option value=\"no\" $sel>".i18n('No')."</option>";
echo "</select></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
else
{
echo "<br />";
echo "<a href=\"sponsor_contacts.php?sponsors_id=$sponsors_id&action=add\">".i18n("Add New Contact to %1",array($sponsors_organization))."</a>\n";
echo "<br />";
$q=mysql_query("SELECT * FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
WHERE year='".$config['FAIRYEAR']."'
AND sponsors_id='$sponsors_id'
AND deleted='no'
ORDER BY lastname,firstname");
echo mysql_Error();
if(mysql_num_rows($q))
{
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>".i18n("Name")."</th>";
echo " <th>".i18n("Email")."</th>";
echo " <th>".i18n("Phone (Work)")."</th>";
echo " <th>".i18n("Phone (Cell)")."</th>";
echo " <th>".i18n("Primary")."</th>";
echo " <th>Actions</th>";
echo "</tr>\n";
while($r=mysql_fetch_object($q))
{
echo "<tr>\n";
echo " <td>";
if($r->salutation) echo $r->salutation." ";
echo "$r->firstname $r->lastname</td>\n";
echo " <td>";
if($r->email) {
list($eb,$ea)=split("@",$r->email);
echo "<script language=\"javascript\" type=\"text/javascript\">em('$eb','$ea')</script>";
}
else
echo "&nbsp;";
echo " </td>";
echo " <td>$r->phonework</td>\n";
echo " <td>$r->phonecell</td>\n";
$p = i18n(($r->primary=='yes')?'Yes':'No');
echo " <td>$p</td>\n";
echo " <td align=\"center\">";
//FIXME: should we just go to /user_personal.php here instead?
echo "<a href=\"sponsor_contacts.php?sponsors_id=$sponsors_id&action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this contact?')\" href=\"sponsor_contacts.php?sponsors_id=$sponsors_id&action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo " </td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
}
}
send_footer();
?>

210
admin/sponsors.php Normal file
View File

@ -0,0 +1,210 @@
<?
/*
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) 2008 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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Sponsors",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising Main' => 'admin/fundraising.php')
);
if($_POST['save']=="edit" || $_POST['save']=="add")
{
if($_POST['save']=="add")
{
$q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
}
else
$id=$_POST['id'];
$exec="UPDATE sponsors SET ".
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
"city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
"province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
"phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
"tollfree='".mysql_escape_string(stripslashes($_POST['tollfree']))."', ".
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
"email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
"website='".mysql_escape_string(stripslashes($_POST['website']))."', ".
"notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ".
"donationpolicyurl='".mysql_escape_string(stripslashes($_POST['donationpolicyurl']))."', ".
"fundingselectiondate='".mysql_escape_string(stripslashes($_POST['fundingselectiondate']))."', ".
"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
"waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."', ".
"taxreceiptrequired='".mysql_escape_string(stripslashes($_POST['taxreceiptrequired']))."' ".
"WHERE id='$id'";
mysql_query($exec);
if($_POST['save']=="add")
echo happy("Sponsor successfully added");
else
echo happy("Successfully saved changes to sponsor");
}
if($_GET['action']=="delete" && $_GET['delete'])
{
//dont allow any deleting until we figure out what we need to do, infact, i think we never should hard delete
//this should only soft-delete so things like awards from previous years are still all linked correctly.
// mysql_query("DELETE FROM sponsors WHERE id='".$_GET['delete']."'");
// echo happy("Sponsors cannot be deleted");
}
if($_GET['action']=="edit" || $_GET['action']=="add")
{
echo "<a href=\"sponsors.php\">&lt;&lt; ".i18n("Back to Award Sponsors")."</a>\n";
if($_GET['action']=="edit")
{
echo "<h3>".i18n("Edit Award Sponsor")."</h3>\n";
$buttontext="Save Sponsor";
$q=mysql_query("SELECT * FROM sponsors WHERE id='".$_GET['edit']."'");
$r=mysql_fetch_object($q);
}
else if($_GET['action']=="add")
{
echo "<h3>".i18n("Add New Award Sponsor")."</h3>\n";
$buttontext="Add Sponsor";
}
$buttontext=i18n($buttontext);
echo "<form method=\"post\" action=\"sponsors.php\">\n";
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
if($_GET['action']=="edit")
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
echo "<table class=\"tableedit\">\n";
echo "<tr><th>".i18n("Organization Name")."</th><td><input type=\"text\" id=\"organization\" name=\"organization\" value=\"".htmlspecialchars($r->organization)."\" size=\"60\" maxlength=\"128\" /><script type=\"text/javascript\">translateButton('organization');</script></td></tr>\n";
echo "<tr><th>".i18n("Address")."</th><td><input type=\"text\" name=\"address\" value=\"".htmlspecialchars($r->address)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
echo "<tr><th>".i18n("City")."</th><td><input type=\"text\" name=\"city\" value=\"".htmlspecialchars($r->city)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><th>".i18n($config['provincestate'])."</th><td>";
emit_province_selector("province_code",$r->province_code);
echo "</td></tr>\n";
echo "<tr><th>".i18n($config['postalzip'])."</th><td><input type=\"text\" name=\"postalcode\" value=\"$r->postalcode\" size=\"8\" maxlength=\"7\" /></td></tr>\n";
echo "<tr><th>".i18n("Phone")."</th><td><input type=\"text\" name=\"phone\" value=\"".htmlspecialchars($r->phone)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><th>".i18n("Toll Free")."</th><td><input type=\"text\" name=\"tollfree\" value=\"".htmlspecialchars($r->tollfree)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><th>".i18n("Fax")."</th><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($r->fax)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
echo "<tr><th>".i18n("Email")."</th><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($r->email)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><th>".i18n("Website")."</th><td><input type=\"text\" name=\"website\" value=\"".htmlspecialchars($r->website)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><th>".i18n("Donation Policy URL")."</th><td><input type=\"text\" name=\"donationpolicyurl\" value=\"".htmlspecialchars($r->donationpolicyurl)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
echo "<tr><th>".i18n("Funding Selection Date")."</th><td>";
emit_date_selector("fundingselectiondate",$r->fundingselectiondate);
echo "</td></tr>\n";
echo "<tr><th>".i18n("Logo")."</th><td><input type=\"file\" name=\"logo\" size=\"16\" /></td></tr>\n";
echo "<tr><th>".i18n("Waiver Accepted")."</th><td>";
if($r->waiveraccepted=="no") $ch="checked=\"checked\""; else $ch="";
echo "<input type=\"radio\" $ch name=\"waiveraccepted\" value=\"no\">".i18n("No")." &nbsp;&nbsp;";
if($r->waiveraccepted=="yes") $ch="checked=\"checked\""; else $ch="";
echo "<input type=\"radio\" $ch name=\"waiveraccepted\" value=\"yes\">".i18n("Yes")." &nbsp;&nbsp;";
echo "</td></tr>\n";
echo "<tr><th>".i18n("Tax Receipt Required")."</th><td>";
if($r->taxreceiptrequired=="no") $ch="checked=\"checked\""; else $ch="";
echo "<input type=\"radio\" $ch name=\"taxreceiptrequired\" value=\"no\">".i18n("No")." &nbsp;&nbsp;";
if($r->taxreceiptrequired=="yes") $ch="checked=\"checked\""; else $ch="";
echo "<input type=\"radio\" $ch name=\"taxreceiptrequired\" value=\"yes\">".i18n("Yes")." &nbsp;&nbsp;";
echo "</td></tr>\n";
echo "<tr><th>".i18n("Notes")."</th><td><textarea name=\"notes\" rows=\"4\" cols=\"60\">".htmlspecialchars($r->notes)."</textarea></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
else
{
echo "<a href=\"sponsors.php?action=add\">Add New Sponsor</a>\n";
echo "<br />";
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>Organization</th>";
echo " <th># of Sponsorships</th>";
echo " <th># of Awards</th>";
echo " <th># of Contacts</th>";
echo " <th>Action</th>";
echo "</tr>\n";
//$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization");
//we want to show all years, infact that year field probably shouldnt even be there.
$q=mysql_query("SELECT * FROM sponsors ORDER BY organization");
while($r=mysql_fetch_object($q))
{
echo "<tr>\n";
echo " <td>$r->organization</td>\n";
$numq=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE year='".$config['FAIRYEAR']."' AND sponsors_id='$r->id'");
$numr=mysql_fetch_object($numq);
$numawards=$numr->num;
$numq=mysql_query("SELECT COUNT(id) AS num FROM sponsorships WHERE year='".$config['FAIRYEAR']."' AND sponsors_id='$r->id'");
$numr=mysql_fetch_object($numq);
$numsponsorships=$numr->num;
$numq=mysql_query("SELECT COUNT(users_id) AS num FROM users_sponsor, users WHERE sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.year='".$config['FAIRYEAR']."' and users.deleted='no'");
$numr=mysql_fetch_object($numq);
$numcontacts=$numr->num;
echo " <td align=\"center\" valign=\"top\">";
echo "$numsponsorships &nbsp;";
echo "<a href=\"fundraising.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo "</td>";
echo " <td align=\"center\" valign=\"top\">";
echo "$numawards &nbsp;";
echo "<a href=\"award_awards.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo "</td>";
echo " <td align=\"center\" valign=\"top\">";
echo "$numcontacts &nbsp;";
echo "<a href=\"sponsor_contacts.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo "</td>";
echo " <td align=\"center\">";
echo "<a href=\"sponsors.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
/* cannot delete sponsors, we need to be able to link to them from other years, etc... this could be turned back on as a soft delete eventually
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this sponsor?')\" href=\"sponsors.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>\n";
}
echo "</table>\n";
}
send_footer();
?>

View File

@ -0,0 +1,71 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 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");
require("../tableeditor.class.php");
require_once("../user.inc.php");
//first, insert any defaults
$q=mysql_query("SELECT * FROM sponsorships_levels WHERE year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM sponsorships_levels WHERE year='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO sponsorships_levels (`level`,`min`,`max`,`description`,`year`) VALUES (
'".mysql_real_escape_string($r->level)."',
'".mysql_real_escape_string($r->min)."',
'".mysql_real_escape_string($r->max)."',
'".mysql_real_escape_string($r->description)."',
'".$config['FAIRYEAR']."')");
}
}
user_auth_required('committee', 'admin');
send_header("Sponsorship Levels",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
"internal_document_management"
);
$editor=new TableEditor("sponsorships_levels",
array("level"=>"Level Name",
"min"=>"Minimum Amount",
"max"=>"Maximum Amount",
)
,
array("level"=>"Level Name",
"min"=>"Minimum Amount",
"max"=>"Maximum Amount",
"description"=>"Description / Benefits",
)
,array("year"=>$config['FAIRYEAR'])
);
$editor->setPrimaryKey("id");
$editor->setDefaultSortField("max");
$editor->setRecordType("Level");
$editor->filterList('year',$config['FAIRYEAR']);
$editor->execute();
send_footer();
?>

62
admin/stats.inc.php Normal file
View File

@ -0,0 +1,62 @@
<?
$stats_data = array(
'start_date' => array('manual' => true),
'end_date' => array('manual' => true),
'address' => array('manual' => true),
'budget' => array('manual' => true),
'ysf_affiliation_complete' => array('manual' => true),
'charity' => array('manual' => true),
'male_1' => array(),
'male_4' => array(),
'male_7' => array(),
'male_9' => array(),
'male_11' => array(),
'female_1' => array(),
'female_4' => array(),
'female_7' => array(),
'female_9' => array(),
'female_11' => array(),
'projects_1' => array(),
'projects_4' => array(),
'projects_7' => array(),
'projects_9' => array(),
'projects_11' => array(),
'students_total' => array(),
'schools_total' => array(),
'schools_active' => array(),
'students_public' => array(),
'schools_public' => array(),
'students_private' => array(),
'schools_private' => array(),
'schools_districts' => array(),
'studentsvisiting' => array('manual' => true),
'publicvisiting' => array('manual' => true),
'firstnations' => array('manual' => true),
'students_atrisk' => array(),
'schools_atrisk' => array(),
'teacherssupporting' => array('manual' => true),
'increasedinterest' => array('manual' => true),
'consideringcareer' => array('manual' => true),
'committee_members' => array(),
'judges' => array(),
'next_chair_name' => array('manual' => true),
'next_chairemail' => array('manual' => true),
'next_chair_hphone' => array('manual' => true),
'next_chair_bphone' => array('manual' => true),
'next_chair_fax' => array('manual' => true),
'scholarships' => array('manual' => true),
'delegate1' => array('manual' => true),
'delegate2' => array('manual' => true),
'delegate3' => array('manual' => true),
'delegate4' => array('manual' => true),
'delegate1_email' => array('manual' => true),
'delegate2_email' => array('manual' => true),
'delegate3_email' => array('manual' => true),
'delegate4_email' => array('manual' => true),
'delegate1_size' => array('manual' => true),
'delegate2_size' => array('manual' => true),
'delegate3_size' => array('manual' => true),
'delegate4_size' => array('manual' => true),
);
?>

View File

@ -328,13 +328,13 @@ if($config['participant_student_personal']=="yes")
echo " <td>".i18n("School")."</td><td colspan=\"3\">";
if( $config['participant_registration_type']=="open" || $config['participant_registration_type']=="singlepassword" || ($studentinfo && !$studentinfo->schools_id) )
{
$schoolq=mysql_query("SELECT id,school FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER by school");
$schoolq=mysql_query("SELECT id,school,city FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER by city,school");
echo "<select name=\"schools_id[$x]\">\n";
echo "<option value=\"\">".i18n("Choose School")."</option>\n";
while($r=mysql_fetch_object($schoolq))
{
if($studentinfo->schools_id==$r->id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">".htmlspecialchars($r->school)."</option>\n";
echo "<option $sel value=\"$r->id\">".htmlspecialchars($r->city).' - '.htmlspecialchars($r->school)."</option>\n";
}
echo "</select>".REQUIREDFIELD;

View File

@ -0,0 +1,148 @@
<?
/*
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");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
$tabs = array( 'fairinfo' => array(
'label' => 'Fair Information',
'types' => array('fair'),
'file' => '../fair_info.php',
'enabled' => true,),
'personal' => array(
'label' => 'Personal',
'types' => array('student','judge','committee','volunteer','sponsor','fair'),
'file' => '../user_personal.php',
'enabled' => true),
'roles' => array(
'label' => 'Roles/Account',
'types' => array('student','judge','committee','volunteer','sponsor','fair'),
'file' => '../user_activate.php',
'enabled' => true),
'judgeother' => array(
'label' => 'Judge Other',
'types' => array('judge'),
'file' => '../judge_other.php',
'enabled' => true),
'judgeexpertise' => array(
'label' => 'Expertise',
'types' => array('judge'),
'file' => '../judge_expertise.php',
'enabled' => true),
'judgeavailability' => array(
'label' => 'Time Avail.',
'types' => array('judge'),
'file' => '../judge_availability.php',
'enabled' => $config['judges_availability_enable'] == 'yes' ? true : false),
'judgesa' => array(
'label' => 'Special Awards',
'types' => array('judge'),
'file' => '../judge_special_awards.php',
'enabled' => true,),
'volunteerpos' => array(
'label' => 'Volunteer Positions',
'types' => array('volunteer'),
'file' => '../volunteer_position.php',
'enabled' => true,),
);
if(array_key_exists('username',$_GET)) {
$username = $_GET['username'];
$type = $_GET['type'];
$un = mysql_escape_string($username);
$q = mysql_query("SELECT id,MAX(year),deleted FROM users WHERE username='$un' GROUP BY uid");
echo mysql_error();
if(mysql_num_rows($q)) {
$r = mysql_fetch_object($q);
if($r->deleted == 'no') {
echo "Username already exists.";
exit;
}
}
$u = user_create($type, $username);
$u['email'] = $username;
user_save($u);
$id = $u['id'];
} else {
$id = $_GET['id'];
}
$u = user_load($id);
$selected = $_GET['tab'];
if(!array_key_exists($selected, $tabs)) {
if(in_array('fair', $u['types']) )
$selected = 'fairinfo';
else
$selected = 'personal';
}
send_popup_header(i18n("User Editor").": {$u['name']}");
//require_once('../htabs.inc.php');
echo '<ul class="htabs">';
foreach($tabs as $k=>$t) {
/* Make sure the tab is enabled */
if($t['enabled'] == false) continue;
/* Make sure the user has the right type to see the tab */
$i = array_intersect($t['types'], $u['types']);
if(count($i) == 0) continue;
/* Show the tab */
$sel = ($selected == $k) ? 'htabs_sel' : '';
$href = "{$_SERVER['PHP_SELF']}?id=$id&tab=$k";
echo "<li class=\"$sel\"><a href=\"$href\">".i18n($t['label'])."</a></li>";
}
echo '</ul>';
echo '<span style="clear: both; height: 0; visibility: hidden; display: block;"></span>';
$t = $tabs[$selected];
/* Setup some things */
$_SESSION['embed'] = true;
$_SESSION['embed_submit_url'] = "{$_SERVER['PHP_SELF']}?id=$id&tab=$selected";
$_SESSION['embed_edit_id'] = $id;
echo '<div class="htabs">';
include("{$t['file']}");
echo '</div>';
unset($_SESSION['embed']);
unset($_SESSION['embed_edit_id']);
unset($_SESSION['embed_submit_url']);
$icon_path = $config['SFIABDIRECTORY']."/images/16/";
$icon_exitension = $config['icon_extension'];
send_popup_footer();
?>

View File

@ -1,136 +0,0 @@
<?
/*
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_once("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
$email = stripslashes($_POST['email']);
$type = $_GET['type'];
if(!in_array($type, $user_types)) {
send_header("Registration");
echo i18n("Invalid new registration\n");
send_footer();
exit;
}
switch($type) {
case 'volunteer':
$header_data = array('Volunteer Management' => 'admin/volunteer.php');
break;
case 'judge':
$header_data = array('Judges Management' => 'admin/judges.php');
break;
}
if($_POST['action']=='confirm' && $email != '') {
$header_data = array_merge($header_data,
array("{$user_what[$type]} Invitations" => "admin/user_invite.php?type=$type"));
send_header("{$user_what[$type]} Confirm",
array_merge(array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
$header_data) );
} else {
send_header("{$user_what[$type]} Invitations",
array_merge(array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
$header_data) );
}
$id = intval($_POST['id']);
if($_POST['action']=='confirm' && $id > 0) {
/* Add $type to their types */
$id = intval($_POST['id']);
$u = user_load($id);
$u = user_create($type, $u);
echo happy(i18n("%1 has been added as a {$user_what[$type]}",
array($email)));
email_send("{$type}_add_invite", $email,
array("FAIRNAME"=>$config['fairname']),
array("FAIRNAME"=>$config['fairname'],
"EMAIL"=>$email));
}
if($_POST['action']=="invite" && $email != '') {
$e = mysql_escape_string($email);
$q = mysql_query("SELECT id,types FROM users WHERE email='$e' OR username='$e'");
if(mysql_num_rows($q) > 0) {
/* Check the roles */
$r = mysql_fetch_object($q);
$types = split(',', $r->types);
if(in_array($type, $types)) {
echo notice(i18n("%1 already exists and is already a {$user_what[$type]}",
array($email)));
} else {
echo i18n("%1 already exists with the following roles:", array($email));
echo '<br /><ul>';
foreach($types as $t) {
echo '<li>'.i18n($user_what[$t]).'</li>';
}
echo '</ul>';
echo i18n("Instead of generating a new password and
creating a new account, the role of {$user_what[$type]}
will be added to this account.");
echo "<form method=\"post\" action=\"user_invite.php?type=$type\">";
echo "<input type=\"hidden\" name=\"action\" value=\"confirm\" />\n";
echo "<input type=\"hidden\" name=\"id\" value=\"{$r->id}\" />\n";
echo "<input type=\"hidden\" name=\"email\" value=\"$e\" />\n";
echo "<input type=\"submit\" value=\"".i18n("Add Role of {$user_what[$type]}")."\" />\n";
echo "</form>\n";
send_footer();
exit;
}
} else {
/* They don't exist, create a new account */
$u = user_create($type);
$u['username'] = $email;
$u['password'] = generatePassword(12);
$u['email'] = $email;
user_save($u);
email_send("{$type}_new_invite",$email,
array("FAIRNAME"=>$config['fairname']),
array("FAIRNAME"=>$config['fairname'],
"EMAIL"=>$email,
"PASSWORD"=>$u['password']));
echo happy(i18n("%1 has been invited to be a {$user_what[$type]}",array($email)));
}
}
echo i18n("Enter the {$user_what[$type]} email address to invite them to be a {$user_what[$type]}");
echo "<br />\n";
echo "<br />\n";
echo "<form method=\"post\" action=\"user_invite.php?type=$type\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"invite\" />\n";
echo i18n("Email").": ";
echo "<input type=\"text\" name=\"email\" size=\"40\" />\n";
echo "<input type=\"submit\" value=\"".i18n("Invite {$user_what[$type]}")."\" />\n";
echo "</form>\n";
send_footer();
?>

291
admin/user_list.php Normal file
View File

@ -0,0 +1,291 @@
<?
/*
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_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
require_once('judges.inc.php');
$show_types = $_GET['show_types'];
if(user_valid_type($show_types) == false) $show_types = array('judge');
$show_complete = ($_GET['show_complete'] == 'yes') ? 'yes' : 'no';
$show_year = ($_GET['show_year'] == 'all') ? 'all' : 'current';
$uid = intval($_GET['uid']);
if($_GET['action']=='remove') {
if(!$uid) {
echo "Invalid uid for delete";
exit;
}
user_delete($uid);
message_push(happy(i18n('User deleted.')));
}
send_header("User Editor",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php')
);
?>
<script language="javascript" type="text/javascript">
function openeditor(id)
{
if(id) currentid=id;
window.open("user_editor_window.php?id="+currentid,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=1000,height=640,scrollbars=yes");
return false;
}
function toggleoptions()
{
if(document.getElementById('options').style.display == 'none') {
document.getElementById('options').style.display = 'block';
document.getElementById('optionstext').innerHTML = '- <?=i18n('Hide Display Options')?>';
} else {
document.getElementById('options').style.display = 'none';
document.getElementById('optionstext').innerHTML = '+ <?=i18n('Show Display Options')?>';
}
}
function togglenew()
{
if(document.getElementById('new').style.display == 'none') {
document.getElementById('new').style.display = 'block';
document.getElementById('newtext').innerHTML = '<?=i18n('Cancel New User')?>';
} else {
document.getElementById('new').style.display = 'none';
document.getElementById('newtext').innerHTML = '<?=i18n('Add New User')?>';
}
}
function neweditor()
{
var username = document.forms.newuser.new_email.value;
var usertype = document.forms.newuser.new_type.value;
window.open("user_editor_window.php?type="+usertype+"&username="+username,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
document.forms.newuser.new_email.value = "";
return false;
}
</script>
<?
echo "<div class=\"notice\">";
echo "<a id=\"optionstext\" href=\"javascript:toggleoptions()\">- ".i18n('Hide Display Options')."</a>";
echo "<form method=\"GET\" action=\"$PHP_SELF\">";
echo "<div id=\"options\" style=\"display: block;\" >";
echo "<table><tr><td>".i18n('Type').":</td>";
$x = 0;
foreach($user_what as $k=>$v ) {
$sel = (in_array($k, $show_types)) ? 'checked="checked"' : '';
echo "<td><input type=\"checkbox\" name=\"show_types[]\" value=\"$k\" $sel >".i18n($v)."</input></td>";
if($x) echo "</tr><tr><td></td>";
$x = ~$x;
}
echo "</tr>";
echo "<tr><td>".i18n('Complete').":</td><td>";
echo "<select name=\"show_complete\">";
$s = ($show_complete == 'yes') ? 'selected="selected"' : '';
echo "<option value=\"yes\" $s>".i18n('Show only complete registrations')."</option>";
$s = ($show_complete == 'no') ? 'selected="selected"' : '';
echo "<option value=\"no\" $s>".i18n('Show ALL registrations')."</option>";
echo "</select>";
echo "</tr>";
echo "<tr><td>".i18n('Year').":</td><td>";
echo "<select name=\"show_year\">";
$s = ($show_year == 'current') ? 'selected="selected"' : '';
echo "<option value=\"current\" $s>".i18n('Show only registrations from %1', array($config['FAIRYEAR']))."</option>";
$s = ($show_year == 'all') ? 'selected="selected"' : '';
echo "<option value=\"all\" $s>".i18n('Show ALL years')."</option>";
echo "</select>";
echo "</td></tr></table>";
echo "<br />";
echo "<input type=submit value=\"".i18n('Apply Filter')."\">";
echo "</div>";
echo "</form>";
echo "</div>";
echo "<br/><a id=\"newtext\" href=\"javascript:togglenew()\">".i18n('Add New User')."</a>";
echo '<div id="new" style="display: none;" class="notice">';
echo "<form name=\"newuser\" method=\"GET\" action=\"$PHP_SELF\">";
echo "<table><tr><td>".i18n('Type').":</td><td>";
echo "<select name=\"new_type\">";
$x = 0;
foreach($user_what as $k=>$v ) {
$sel = (in_array($k, $show_types)) ? 'selected="selected"' : '';
echo "<option value=\"$k\" $sel>".i18n($v)."</option>";
}
echo "</select>";
echo "</tr>";
echo "<tr><td>".i18n('Email').":</td><td>";
echo '<input type="text" name="new_email" value="" />';
echo '</td></tr>';
echo '</table>';
echo "<input type=submit onclick=\"neweditor();\" value=\"".i18n('Create New User')."\">";
echo '</form>';
echo '</div>';
echo "<br />";
echo "<br />";
/* Grab a list of users */
$w = array();
foreach($show_types as $t) {
$w [] = "users.types LIKE '%$t%'";
}
$where_types = "AND (".join(" OR ", $w).")";
$where_complete = "";
if($show_complete == 'yes') {
foreach($show_types as $t) {
$where_complete .= "AND ({$t}_complete='yes' OR {$t}_complete IS NULL) ";
}
}
if($show_year == 'current')
$where_year = "AND year={$config['FAIRYEAR']}";
echo "<table class=\"viewtable\">";
$querystr="SELECT
*
FROM
users
LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`users`.`id`
LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`users`.`id`
LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`users`.`id`
LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`users`.`id`
LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`users`.`id`
WHERE
users.deleted='no'
$where_year
$where_types
$where_complete
ORDER BY
lastname ASC,
firstname ASC,
year DESC";
$q=mysql_query($querystr);
echo mysql_error();
// echo $querystr;
$num=mysql_num_rows($q);
echo i18n("Listing %1 people total. See the bottom for breakdown of by complete status",array($num));
echo mysql_error();
echo "<tr>";
echo " <th>".i18n("Name")."</th>";
echo " <th>".i18n("Email Address")."</th>";
echo " <th>".i18n("Year")."</th>";
echo " <th>".i18n("Type(s)")."</th>";
echo " <th>".i18n("Active")."</th>";
echo " <th>".i18n("Complete")."</th>";
echo " <th>".i18n("Actions")."</th>";
echo "</tr>";
$completeyes=0;
$completeno=0;
while($r=mysql_fetch_assoc($q))
{
$types = split(',', $r['types']);
$span = count($types) > 1 ? "rowspan=\"".count($types)."\"" : '';
echo "<tr><td $span>";
$name = "{$r['firstname']} {$r['lastname']}";
if(in_array('fair', $types)) {
$qq = mysql_query("SELECT * FROM users_fair
LEFT JOIN fairs ON fairs.id=users_fair.fairs_id
WHERE users_id='{$r['id']}'");
$rr = mysql_fetch_assoc($qq);
$name = "{$rr['name']}".((trim($name)=='') ? '' : "<br />($name)");
}
echo "<a href=\"#\" onclick=\"return openeditor({$r['id']})\">$name</a>";
echo "</td>";
echo "<td $span>{$r['email']}</td>";
echo "<td $span>{$r['year']}</td>";
$first = true;
foreach($types as $t) {
if(!$first) echo '</tr><tr>';
echo "<td>{$user_what[$t]}</td>";
echo "<td>";
if($r["{$t}_active"] == 'yes') {
echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>";
} else {
echo "<div class=\"error\" align=\"center\">".i18n("no")."</div>";
}
echo "</td>";
echo "<td>";
if($r["{$t}_complete"] == 'yes') {
echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>";
$completeyes++;
} else {
echo "<div class=\"error\" align=\"center\">".i18n("no")."</div>";
$completeno++;
}
echo "</td>";
if($first) {
/* Finish off the the first line */
echo "<td $span align=\"center\">";
echo "<a href=\"#\" onclick=\"return openeditor({$r['id']})\"><img border=0 src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\"></a>&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you completely delete this user?')\" href=\"user_list.php?action=remove&uid={$r['id']}\"><img border=0 src=\"{$config['SFIABDIRECTORY']}/images/16/button_cancel.{$config['icon_extension']}\"></a>";
echo "</td>";
}
$first = false;
}
echo '</tr>';
}
echo "</table>";
echo i18n("Note: Deleting users from this list is a permanent operation and cannot be undone. Consider editting the user and deactivating or deleting roles in their account instead.");
echo "<br />";
echo "<br />";
echo "$num ".i18n("people listed.");
echo "<br />";
echo "$completeyes ".i18n('complete');
echo "<br />";
echo "$completeno ".i18n('incomplete');
echo "<br />";
echo "<br />";
echo "<br />";
send_footer();
?>

View File

@ -47,6 +47,7 @@
$editor->setPrimaryKey("id");
$editor->setDefaultSortField("start,name");
$editor->setRecordType("Volunteer Position");
$editor->filterList('year',$config['FAIRYEAR']);
$editor->execute();
send_footer();

View File

@ -32,11 +32,9 @@
"volunteer_management"
);
echo "<br />";
if($config['volunteer_registration_type']=="invite")
{
echo "<a href=\"user_invite.php?type=volunteer\">".i18n("Invite Volunteers")."</a><br />";
}
echo "<a href=\"volunteer_positions_manager.php\">".i18n("Volunteer Position Management")."</a> <br />";
echo "<a href=\"user_list.php?show_types[]=volunteer\">".i18n("Volunteer Manager")."</a><br />";
echo "<a href=\"volunteer_positions_manager.php\">".i18n("Volunteer Position Management")."</a> <br />";
echo "<a href=\"../user_invite.php?type=volunteer\">".i18n("Invite Volunteers")."</a><br />";
send_footer();

View File

@ -28,8 +28,8 @@
user_auth_required('committee', 'admin');
if($_GET['award_sponsors_id']) $award_sponsors_id=$_GET['award_sponsors_id'];
else if($_POST['award_sponsors_id']) $award_sponsors_id=$_POST['award_sponsors_id'];
if($_GET['sponsors_id']) $sponsors_id=$_GET['sponsors_id'];
else if($_POST['sponsors_id']) $sponsors_id=$_POST['sponsors_id'];
if($_GET['award_types_id']) $award_types_id=$_GET['award_types_id'];
else if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id'];
@ -274,16 +274,16 @@ else
award_awards.name,
award_awards.order AS awards_order,
award_types.type,
award_sponsors.organization
sponsors.organization
FROM
award_awards,
award_types,
award_sponsors
sponsors
WHERE
award_awards.year='".$config['FAIRYEAR']."'
AND award_awards.award_types_id=award_types.id
AND award_types.year='".$config['FAIRYEAR']."'
AND award_awards.award_sponsors_id=award_sponsors.id
AND award_awards.sponsors_id=sponsors.id
ORDER BY awards_order");
echo mysql_error();

View File

@ -46,7 +46,7 @@
curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0);
curl_setopt ($ch, CURLOPT_TIMEOUT, 360);
curl_setopt ($ch, CURLOPT_SSLVERSION, 3);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
$datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream
$datastream = str_replace(" standalone=\"yes\"","",$datastream);
// echo "curl close <br />";
@ -234,14 +234,22 @@
$stats["proj910"]=$projs["910"]?$projs["910"]:0;
$stats["proj11up"]=$projs["11up"]?$projs["11up"]:0;
$q=mysql_query("SELECT COUNT(id) AS num FROM users WHERE types LIKE '%committee%' AND deleted='no'");
$q=mysql_query("SELECT COUNT(id) AS num FROM users
WHERE types LIKE '%committee%'
AND year='$year'
AND deleted='no'");
$r=mysql_fetch_object($q);
$numcommittee=$r->num;
echo i18n("Committee Members: %1 (note: this is CURRENT number of active committee members as of right now! There is no way to extract committee member numbers from previous years)",array($r->num));
echo i18n("Committee Members: %1 (note: this is number of committee members who logged in to SFIAB for the year, anyone who was active but didn't log in to SFIAB will NOT be counted)",array($r->num));
echo "<br />";
$stats["committee"]=$numcommittee;
$q=mysql_query("SELECT COUNT(id) AS num FROM judges,judges_years WHERE judges_years.judges_id=judges.id AND judges_years.year='$year' AND judges.complete='yes' AND judges.deleted='no'");
$q=mysql_query("SELECT COUNT(id) AS num FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id
WHERE users.year='$year'
AND users.types LIKE '%judge%'
AND users.deleted='no'
AND users_judge.judge_complete='yes'
AND users_judge.judge_active='yes'");
$r=mysql_fetch_object($q);
$numjudges=$r->num;
echo i18n("Judges: %1",array($r->num));

View File

@ -31,18 +31,6 @@
send_header("Committee Main", array());
switch($_GET['notice']) {
case 'password_changed':
echo happy(i18n('Your password has been successfully updated'));
break;
case 'already_logged_in':
echo error(i18n('You are already logged in, please use the [Logout] link in the upper right to logout'));
break;
case 'no_auth':
echo error(i18n('You do not have permission to view that page'));
break;
}
//only display the named greeting if we have their name
echo i18n("Hello <b>%1</b>",array($_SESSION['name']));
echo "<br />";
@ -61,6 +49,7 @@
echo " <tr>\n";
echo " <td><a href=\"user_personal.php\">".theme_icon("edit_profile")."<br />".i18n("Edit My Profile")."</a></td>";
echo " <td><a href=\"user_password.php\">".theme_icon("change_password")."<br />".i18n("Change My Password")."</a></td>";
echo " <td><a href=\"user_activate.php\">".theme_icon("")."<br />".i18n("Manage My Roles")."</a></td>";
echo " </tr>\n";
echo "</table>\n";

View File

@ -22,68 +22,56 @@
*/
?>
<?
require("common.inc.php");
require_once('common.inc.php');
require_once('user.inc.php');
send_header("Committee List", null, "committee_management");
echo "<table>";
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
while($r=mysql_fetch_object($q))
{
$q2=mysql_query("SELECT
users.id,
users.firstname,users.lastname,
users.email,
users_committee.emailprivate,
users_committee.displayemail,
committees_link.title,
committees_link.ord
FROM
users, users_committee, committees_link
WHERE
users_committee.users_id=users.id
AND committees_link.users_id=users.id
AND committees_link.committees_id='$r->id'
ORDER BY
ord,firstname");
while($r=mysql_fetch_object($q)) {
/* Select all the users in the committee, using MAX(year) for the most recent year */
$q2=mysql_query("SELECT committees_link.*,users.uid,MAX(users.year),users.lastname
FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid
WHERE committees_id='{$r->id}'
GROUP BY users.uid ORDER BY ord,users.lastname ");
//if there's nobody in this committee, then just skip it and go on to the next one.
if(mysql_num_rows($q2)==0)
continue;
echo "<tr>";
echo "<td colspan=\"3\"><h3>$r->name</h3>";
echo "<td colspan=\"3\"><h3>{$r->name}</h3>";
echo "</td></tr>\n";
echo mysql_error();
while($r2=mysql_fetch_object($q2))
{
while($r2=mysql_fetch_object($q2)) {
$uid = $r2->users_uid;
$u = user_load_by_uid($uid);
$output=$config['committee_publiclayout'];
$name=$r2->firstname.' '.$r2->lastname;
$output=str_replace("name",$name,$output);
$output=str_replace("name",$u['name'],$output);
$output=str_replace("title",$r2->title,$output);
//make sure we do emailprivate before email so we dont match the wrong thing
if($r2->emailprivate && $r2->displayemail=='yes')
{
list($b,$a)=split("@",$r2->emailprivate);
if($u['emailprivate'] && $u['displayemail']=='yes') {
list($b,$a)=split("@",$u['emailprivate']);
$output=str_replace("emailprivate","<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>",$output);
}
else
$output=str_replace("emailprivate","",$output);
} else
$output=str_replace("emailprivate","",$output);
if($r2->email && $r2->displayemail=='yes')
{
list($b,$a)=split("@",$r2->email);
if($u['email'] && $u['displayemail']=='yes') {
list($b,$a)=split("@",$u['email']);
$output=str_replace("email","<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>",$output);
}
else
} else
$output=str_replace("email","",$output);
$output=str_replace("phonehome",$r2->phonehome,$output);
$output=str_replace("phonework",$r2->phonework,$output);
$output=str_replace("phonecell",$r2->phonecell,$output);
$output=str_replace("fax",$r2->fax,$output);
$output=str_replace("phonehome",$u['phonehome'],$output);
$output=str_replace("phonework",$u['->phonework'],$output);
$output=str_replace("phonecell",$u['->phonecell'],$output);
$output=str_replace("fax",$u['fax'],$output);
echo $output;

View File

@ -244,10 +244,6 @@ if($_GET['switchlanguage'])
}
}
if(!is_array($_SESSION['messages'])) {
$_SESSION['messages'] = array();
}
function i18n($str,$args=array(),$argsdesc=array(),$forcelang="")
{
if(!$str)
@ -357,6 +353,15 @@ function happy($str,$type="normal")
return "<span class=\"happy\">$str</span><br />";
}
function display_messages()
{
/* Dump any messages in the queue */
if(is_array($_SESSION['messages'])) {
foreach($_SESSION['messages'] as $m) echo $m;
}
$_SESSION['messages'] = array();
}
$HEADER_SENT=false;
function send_header($title="", $nav=null, $icon=null, $titletranslated=false)
{
@ -378,51 +383,9 @@ function send_header($title="", $nav=null, $icon=null, $titletranslated=false)
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type="text/css" media="all" />
</head>
<body>
<script language="javascript" type="text/javascript">
<!--
//useful function that we'll be using throughout
function confirmClick(msg)
{
var okay=confirm(msg);
if(okay)
return true;
else
return false;
}
function el(str,domain,name)
{
document.write('<a href="ma'+'il'+'to:' + str + '@' + domain + '">' + name + '</a>');
}
function em(str,domain)
{
document.write('<a href="ma'+'il'+'to:' + str + '@' + domain + '">' + str + '@' + domain + '</a>');
}
var anyFieldHasBeenChanged=false;
function fieldChanged()
{
anyFieldHasBeenChanged=true;
}
function confirmChanges()
{
if(anyFieldHasBeenChanged)
{
var okay=confirm('<?=i18n("You have unsaved changes. Click \"Cancel\" to return so you can save your changes, or press \"OK\" to discard your changes and continue")?>');
if(okay)
return true;
else
return false;
}
else
return true;
}
-->
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/sfiab.js"></script>
<?
//if we're under /admin or /config we also want the translationDropdown javascript stuff
@ -453,11 +416,7 @@ if(isset($_SESSION['users_type'])) {
} else if(isset($_SESSION['email'])) {
/* Backwards compatible login settings */
if(isset($_SESSION['judges_id'])) {
echo i18n('Judge');
echo " {$_SESSION['email']}: ";
echo "<a href=\"{$config['SFIABDIRECTORY']}/register_judges.php?action=logout\">[".i18n("Logout")."]</a>";
} else if(isset($_SESSION['registration_id'])) {
if(isset($_SESSION['registration_id'])) {
echo i18n('Participant');
echo " {$_SESSION['email']}: ";
echo "<a href=\"{$config['SFIABDIRECTORY']}/register_participants.php?action=logout\">[".i18n("Logout")."]</a>";
@ -496,12 +455,14 @@ echo "</div>";
<?
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/index.php\">".i18n("Home Page").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/important_dates.php\">".i18n("Important Dates").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants.php\">".i18n("Participant Registration").'</a></li>';
echo $registrationconfirmationlink;
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_judges.php\">".i18n("Judges Registration").'</a></li>';
/*
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants.php\">".i18n("Participant Registration").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=judge\">".i18n("Judges Registration").'</a></li>';
if($config['volunteer_enable'] == 'yes') {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=volunteer\">".i18n("Volunteer Registration").'</a></li>';
}
*/
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/committees.php\">".i18n("Committee").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/winners.php\">".i18n("Winners").'</a></li>';
echo '</ul>';
@ -509,60 +470,46 @@ echo "</div>";
<br />
<ul class="mainnav">
<?
if($_SESSION['users_type'] == 'committee')
{
if($_SESSION['users_type'] == 'committee') {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/committee_main.php\">".i18n("Committee Home").'</a></li>';
if(committee_auth_has_access("admin")){
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/\">".i18n("Fair Administration").'</a></li>';
}
if(committee_auth_has_access("config")){
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/config/\">".i18n("SFIAB Configuration").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/config/\">".i18n("Configuration").'</a></li>';
}
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Committee Logout").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
} else if($_SESSION['users_type']=="judge") {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/judge_main.php\">".i18n("Judge Home").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
} else if($_SESSION['users_type']=="volunteer") {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/volunteer_main.php\">".i18n("Volunteer Home").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
} else if($_SESSION['users_type']=="sponsor") {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/sponsor_main.php\">".i18n("Sponsor Home").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
} else if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php\">".i18n("School Home").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php?action=logout\">".i18n("Logout").'</a></li>';
}
else if($_SESSION['registration_number'] && $_SESSION['registration_id']) {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants_main.php\">".i18n("Participant Home").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants.php?action=logout\">".i18n("Logout")."</a></li>\n";
} else {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=committee\">".i18n("Committee Login").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/login.php\">".i18n("Login/Register").'</a></li>';
}
?></ul>
<br />
<ul class="mainnav">
<?
if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode'])
{
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php\">".i18n("School Access").'</a></li>';
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php?action=logout\">".i18n("School Logout").'</a></li>';
} else {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php\">".i18n("School Login").'</a></li>';
}
if($config['fairs_enable'] == 'yes' && $config['fairs_allow_login'] == 'yes') {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=fair\">".i18n("{$config['fairs_name']} Fair Login").'</a></li>';
}
?></ul>
<br />
<ul class="mainnav">
<?
if($_SESSION['registration_number'] && $_SESSION['registration_id'])
{
?>
<li><a href="<?=$config['SFIABDIRECTORY']?>/register_participants.php?action=logout"><?=i18n("Registration Logout")?></a></li><?
}
?>
</ul>
<div class="aligncenter">
<?
if(count($config['languages'])>1)
{
if(count($config['languages'])>1) {
echo "<br />";
echo "<form name=\"languageselect\" method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<select name=\"switchlanguage\" onchange=\"document.forms.languageselect.submit()\">\n";
foreach($config['languages'] AS $key=>$val)
{
foreach($config['languages'] AS $key=>$val) {
if($_SESSION['lang']==$key) $selected="selected=\"selected\""; else $selected="";
echo "<option $selected value=\"$key\">$val</option>";
@ -588,10 +535,10 @@ if(is_array($nav)) {
foreach($nav as $t=>$l) {
echo "<a href=\"{$config['SFIABDIRECTORY']}/$l\">".i18n($t).'</a> &raquo; ';
}
if(!$titletranslated)
echo i18n($title);
else
echo $title;
if(!$titletranslated)
echo i18n($title);
else
echo $title;
echo '</div>';
}
?>
@ -632,7 +579,10 @@ if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")
}
"</td></tr>";
echo "</table>";
display_messages();
}
/* END OF send_header */
function send_footer()
{
@ -674,13 +624,14 @@ function send_popup_header($title="")
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head><title><?=i18n($title)?></title>
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/sfiab.css" type="text/css" />
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/sfiab.css" type="text/css" media="all" />
<link media=all href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type=text/css rel=stylesheet>
</head>
<body onload="window.focus()">
<?
if($title)
echo "<h2>".i18n($title)."</h2>";
}
function send_popup_footer()
@ -1143,4 +1094,43 @@ function format_datetime($dt) {
return format_date($d)." ".i18n("at")." ".format_time($t);
}
}
function format_money($n)
{
if($n<0){
$neg=true;
$n=$n*-1;
}
//get the part before the decimal
$before=floor($n);
$out="";
//space it out in blocks of three
for($x=strlen($before);$x>3;$x-=3) {
$out=substr($before,$x-3,3)." ".$out;
}
if($x>0)
$out=substr($before,0,$x)." ".$out;
//trim any leading/trailing space that was added
$out=trim($out);
if($neg) $negdisp="-"; else $negdisp="";
//get everything after the decimal place, and %02f it.
$after=substr(strstr(sprintf("%.02f",$n),"."),1);
//finally display it with the right language localization
if($_SESSION['lang']=="fr")
return sprintf("%s%s,%s \$",$negdisp,$out,$after);
else
return sprintf("%s\$%s.%s",$negdisp,$out,$after);
}
function message_push($m)
{
if(!is_array($_SESSION['messages'])) $_SESSION['messages'] = array();
$_SESSION['messages'][] = $m;
}
?>

View File

@ -79,6 +79,8 @@ while($tr=mysql_fetch_row($tableq)) {
header("Content-Type: text/sql");
header("Content-Disposition: attachment; filename=sfiab_backup_".date("Y-m-d-H-i-s",$ts).".sql");
header("Content-Length: ".strlen($dump));
//Make IE with SSL work
header("Pragma: public");
echo $dump;
}
else if($_POST['action']=="restore") {

View File

@ -54,6 +54,22 @@
</script>
<?
function roll($currentfairyear, $newfairyear, $table, $fields)
{
$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])."'";
}
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 +242,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,18 +300,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)."')");
roll($currentfairyear, $newfairyear, 'regfee_items',
array('name','description','cost','per'));
echo "<br />";
echo "<br />";
//volunteer positions
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();

View File

@ -26,11 +26,6 @@
require_once("../user.inc.php");
require_once("../config_editor.inc.php");
user_auth_required('committee', 'config');
send_header("Configuration Variables",
array('Committee Main' => 'committee_main.php',
'SFIAB Configuration' => 'config/index.php')
,"configuration_variables"
);
$q=mysql_query("SELECT * FROM config WHERE year='-1'");
while($r=mysql_fetch_object($q))
@ -56,7 +51,7 @@
mysql_query("UPDATE config SET val='".mysql_escape_string(stripslashes($val))."' WHERE year='0' AND var='$key'");
}
}
echo happy(i18n("Configuration successfully saved"));
message_push(happy(i18n("Configuration successfully saved")));
}
//get the category, and if nothing is chosen, default to Global
@ -64,6 +59,19 @@
else if($_POST['category']) $category=$_POST['category'];
else $category="Global";
$action = config_editor_handle_actions($category, $config['FAIRYEAR'], "var");
if($action == 'update') {
header("Location: variables.php?category=$category");
exit;
}
send_header("Configuration Variables",
array('Committee Main' => 'committee_main.php',
'SFIAB Configuration' => 'config/index.php')
,"configuration_variables"
);
$q=mysql_query("SELECT DISTINCT(category) AS cat FROM config ORDER BY cat");
echo "\n<table valign=\"top\" cellspacing=0 cellpadding=5 border=0>";

View File

@ -162,7 +162,7 @@ function config_editor_handle_actions($category, $year, $array_name)
$updated = true;
}
if($updated == true) {
$_SESSION['messages'][] = 'config_editor_updated';
message_push(happy(i18n("Configuration Updated")));;
}
return 'update';
}
@ -185,17 +185,6 @@ function config_editor($category, $year, $array_name, $self)
config_editor_handle_actions($category, $year, $array_name);
}
if(is_array($_SESSION['messages'])) {
foreach($_SESSION['messages'] as $m) {
switch($m) {
case 'config_editor_updated':
echo happy(i18n("Configuration Updated"));
break;
}
}
$_SESSION['messages'] = array();
}
/* Load questions, then handle up and down, because with up and down we
* have to modify 2 questions to maintain the order */
$var = config_editor_load($category, $year);
@ -289,10 +278,12 @@ function config_editor($category, $year, $array_name, $self)
$rows = intval(($c+2) / 3);
print("</td></tr><tr class=\"$trclass\"><td colspan=2>");
print("<table width=\"100%\"><tr><td width=\"10%\">&nbsp;");
}
} else {
$rows = $c;
}
for($x=0; $x<$c; $x++) {
if(($x % $rows) == 0 && $rows > 0) {
if(($x % $rows) == 0 && $rows > 0 && $c > 5) {
print("</td><td width=\"30%\">");
}
@ -307,6 +298,14 @@ function config_editor($category, $year, $array_name, $self)
if($c > 5) print("</td></tr></table>");
break;
case 'language':
print("<select name=\"$name\">");
foreach($config['languages'] as $k=>$lang) {
$sel = ($config['default_language'] == $k) ? 'selected=selected' : '';
print("<option $sel value=\"$k\">$lang</option>");
}
print("</select>");
break;
default:
print("<input size=\"$size\" type=\"text\" name=\"$name\" value=\"$val\">\n");

View File

@ -81,32 +81,26 @@ function tochange() {
echo "<td><select name=\"to\" onchange=\"tochange()\">";
echo "<option value=\"\">".i18n("Choose a person to contact")."</option>\n";
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
while($r=mysql_fetch_object($q))
{
$q2=mysql_query("SELECT
users.id,
users.firstname,users.lastname,
users.email,
committees_link.title,
committees_link.ord
FROM
users, users_committee, committees_link
WHERE
users_committee.users_id=users.id
AND committees_link.users_id=users.id
AND committees_link.committees_id='$r->id'
ORDER BY
ord,firstname");
while($r=mysql_fetch_object($q)) {
/* Select everyone in this committee, attach the user data using MAX(year) so we only get the most recent
* user data */
$q2=mysql_query("SELECT committees_link.*,users.uid,MAX(users.year),users.firstname,users.lastname,users.email,users.deleted
FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid
WHERE committees_id='{$r->id}'
GROUP BY users.uid ORDER BY ord,users.lastname ");
//if there's nobody in this committee, then just skip it and go on to the next one.
if(mysql_num_rows($q2)==0)
continue;
echo "<option value=\"\">$r->name</option>\n";
echo "<option value=\"\">{$r->name}</option>\n";
echo mysql_error();
while($r2=mysql_fetch_object($q2))
{
if($r2->deleted != 'no') continue;
if($r2->email) {
$name=$r2->firstname.' '.$r2->lastname;
if($r2->title) $titlestr=" ($r2->title)"; else $titlestr="";

View File

@ -1 +1 @@
115
130

328
db/db.update.116.php Normal file
View File

@ -0,0 +1,328 @@
<?
function db_update_116_post()
{
global $config;
/* Fix the users that have a 0 year */
$q = mysql_query("UPDATE `users` SET year={$config['FAIRYEAR']} WHERE year=0");
echo mysql_error();
/* Fix users without a username */
mysql_query("UPDATE `users` SET `username`=`email` WHERE `username`=''");
/*randomize usernames for any user that doesnt have a username at this point */
$q=mysql_query("SELECT id FROM `users` WHERE username=''");
//this is ripped from user.inc.php's generate passsword function.
//yes there's a chance of collisions, but i think highly unlikely enough that we
//dont need to worry about it.
$available="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
$len=strlen($available) - 1;
while($r=mysql_fetch_object($q)) {
$username="";
for($x=0;$x<16;$x++)
$username.=$available{rand(0,$len)};
mysql_query("UPDATE users SET username='$username' WHERE id='$r->id'");
}
//okay now finally, there's a chance of duplicates from
//committee/volunteer that were in here before, so we need to merge
//them
$q = mysql_query("SELECT * FROM `users` WHERE types LIKE '%committee%'");
while($r = mysql_fetch_assoc($q)) {
$orig_r = $r;
$qq = mysql_query("SELECT * FROM `users` WHERE
(`username`='{$r['username']}' OR `email`='{$r['email']}')
AND `id`!={$r['id']}");
if(mysql_num_rows($qq) == 0) continue;
echo "User id {$r['id']} ({$r['username']} {$r['email']}) has multiple users, merging...\n";
/* Now, there should only be two types, because the system is
* only supposed to let committee members and volunteers be
* created, and it has only been in use for one year without
* year stamps., but we'll handle any number */
/* However, we will make the committee the record that sticks
* */
$delete_ids = array();
$delete_userids = array();
while($rr = mysql_fetch_assoc($qq)) {
$delete_ids[] = "`id`={$rr['id']}";
$delete_userids[] = "`users_id`={$rr['id']}";
$keys = array_keys($rr);
foreach($keys as $k) {
switch($k) {
case 'id':
/* Skip */
break;
case 'types':
/* Merge types */
if(strstr($r['types'], $rr['types']) == false) {
$r['types']= $r['types'].','.$rr['types'];
echo " New type: {$r['types']}\n";
}
break;
default:
/* Save data */
if(trim($r[$k]) == '' && trim($rr[$k]) != '') {
$r[$k] = $rr[$k];
}
break;
}
}
}
/* Construct SQL for a SET clause */
$set = array();
$keys = array_keys($r);
foreach($keys as $k) {
if($r[$k] != $orig_r[$k]) {
$set[] = "`$k`='{$r[$k]}'";
}
}
if(count($set)) {
$query = join(',',$set);
mysql_query("UPDATE `users` SET $query WHERE id={$r['id']}");
echo "Update query: UPDATE `users` SET $query WHERE id={$r['id']}\n";
}
/* Join together the WHERE commands */
$where_id = "WHERE ".join(" OR ", $delete_ids);
$where_users_id = "WHERE ".join(" OR ", $delete_userids);
echo "Merged... Deleting duplicate and adjusting volunteer tables...\n";
/* Delete the dupe */
mysql_query("DELETE FROM `users` $where_id");
/* Update volunteer linkage */
mysql_query("UPDATE `users_volunteer` SET `users_id`={$r['id']} $where_users_id");
mysql_query("UPDATE `volunteer_positions_signup` SET `users_id`={$r['id']} $where_users_id");
echo "done with this user.\n";
}
/* Create volunteer database entries for any that don't exist */
$q = mysql_query("SELECT * FROM users WHERE types LIKE '%volunteer%'");
while($i = mysql_fetch_object($q)) {
mysql_query("INSERT INTO users_volunteer(`users_id`,`volunteer_active`,`volunteer_complete`)
VALUES ('{$i->id}','yes','{$i->complete}')");
}
/* Update any remaining volunteer entries */
$q = mysql_query("SELECT * FROM users WHERE types LIKE '%volunteer%'");
while($i = mysql_fetch_object($q)) {
mysql_query("UPDATE users_volunteer
SET volunteer_complete='{$i->complete}'
WHERE users_id='{$i->id}'");
echo mysql_error();
}
/* Every committee member role should be activated */
$q = mysql_query("SELECT * FROM users WHERE types LIKE '%committee%'");
while($i = mysql_fetch_object($q)) {
mysql_query("UPDATE users_committee
SET committee_active='yes'
WHERE users_id='{$i->id}'");
echo mysql_error();
}
/* Convert Judges */
$map = array();
$jtl = array();
$jsal = array();
/* Select all judges, duplicate rows for each year */
$jq = mysql_query("SELECT * FROM judges
LEFT JOIN judges_years ON judges_years.judges_id=judges.id
ORDER BY year");
while($j = mysql_fetch_object($jq)) {
if(!is_array($map[$j->id])) {
$map[$j->id] = array('uid' => '');
}
$u = array( 'id' => '',
'uid' => $map[$j->id]['uid'],
'types' => 'judge',
'firstname' => mysql_escape_string($j->firstname),
'lastname' => mysql_escape_string($j->lastname),
'username' => mysql_escape_string($j->email),
'email' => mysql_escape_string($j->email),
'sex' => '',
'password' => mysql_escape_string($j->password),
'passwordset' => $j->lastlogin,
'oldpassword' => '',
'year' => $j->year,
'phonehome' => mysql_escape_string($j->phonehome),
'phonework' => mysql_escape_string($j->phonework.(($j->phoneworkext=='') ? '' : " x{$j->phoneworkext}")),
'phonecell' => mysql_escape_string($j->phonecell),
'fax' => '',
'organization' => mysql_escape_string($j->organization),
'lang' => '', /* FIXME, or unused for judges?, this is preferred communication language, not judging languages */
'created' => $j->created,
'lastlogin' => $j->lastlogin,
'address' => mysql_escape_string($j->address),
'address2' => mysql_escape_string($j->address2),
'city' => mysql_escape_string($j->city),
'province' => mysql_escape_string($j->province),
'postalcode' => mysql_escape_string($j->postalcode),
'firstaid' => 'no',
'cpr' => 'no',
'deleted' => $j->deleted,
'deleteddatetime' => $j->deleteddatetime );
$updateexclude=array("id","uid","types","username","password","passwordset","oldpassword","year","created","lastlogin","firstaid","cpr","deleted","deleteddatetime");
//check if a user already exists with this username
$uq=mysql_query("SELECT * FROM users WHERE (username='".mysql_real_escape_string($j->email)."' OR email='".mysql_real_escape_string($j->email)."') AND year='$j->year'");
if($j->email && $ur=mysql_fetch_object($uq)) {
$id=$ur->id;
echo "Using existing users.id=$id for judges.id=$j->id because email address/year ($j->email/$j->year) matches\n";
$sqlset="";
foreach($u AS $f=>$v) {
if(!$ur->$f && $j->$f && !in_array($f,$updateexclude)) {
$sqlset.="`$f`='".mysql_real_escape_string($j->$f)."', ";
}
}
$sql="UPDATE users SET $sqlset `types`='{$ur->types},judge',`username`='".mysql_real_escape_string($j->email)."' WHERE id='$id'";
mysql_query($sql);
echo mysql_error();
echo " Updated user record with judge info, but only merged:\n";
echo " ($sqlset)\n";
}
else
{
/* Insert the judge */
$fields = '`'.join('`,`', array_keys($u)).'`';
$vals = "'".join("','", array_values($u))."'";
$q = mysql_query("INSERT INTO users ($fields) VALUES ($vals)");
$id = mysql_insert_id();
if($map[$j->id]['uid'] == '') {
$map[$j->id]['uid'] = $id;
$q = mysql_query("UPDATE users SET `uid`='$id' WHERE id='$id'");
}
}
$uj = array( 'users_id' => "$id",
'judge_active' => 'yes',
'highest_psd' => mysql_escape_string($j->highest_psd),
'special_award_only' => ($j->typepref == 'speconly') ? 'yes' : 'no',
'expertise_other' => mysql_escape_string((($j->professional_quals != '')?($j->professional_quals."\n"):'').
$j->expertise_other),
/* These need to get pulled from the questions */
'years_school' => $j->years_school,
'years_regional' => $j->years_regional,
'years_national' => $j->years_national,
'willing_chair' => $j->willing_chair,
'judge_complete' => $j->complete,
);
// $j->attending_lunch,
/* catprefs */
$q = mysql_query("SELECT * FROM judges_catpref WHERE judges_id='{$j->id}' AND year='{$j->year}'");
$catpref = array();
while($i = mysql_fetch_object($q)) {
$catpref[$i->projectcategories_id] = $i->rank;
}
$uj['cat_prefs'] = mysql_escape_string(serialize($catpref));
/* divprefs and subdivision prefs */
$q = mysql_query("SELECT * FROM judges_expertise WHERE judges_id='{$j->id}' AND year='{$j->year}'");
$divpref = array();
$divsubpref = array();
while($i = mysql_fetch_object($q)) {
if($i->projectdivisions_id)
$divpref[$i->projectdivisions_id] = $i->val;
else if ($i->projectsubdivisions_id)
$divsubpref[$i->projectsubdivisions_id] = $i->val;
}
$uj['div_prefs'] = mysql_escape_string(serialize($divpref));
$uj['divsub_prefs'] = mysql_escape_string(serialize($divsubpref));
/* languages */
$q = mysql_query("SELECT * FROM judges_languages WHERE judges_id='{$j->id}'");
$langs = array();
while($i = mysql_fetch_object($q)) {
$langs[] = $i->languages_lang;
}
$uj['languages'] = mysql_escape_string(serialize($langs));
/* Map judges questions back to the profile. We're going to keep questions we need for
* judge scheduling as hard-coded questions so users can't erase them.
* "Years School" "Years Regional" "Years National" "Willing Chair" */
$qmap = array('years_school' => 'Years School',
'years_regional' => 'Years Regional',
'years_national' => 'Years National',
'willing_chair' => 'Willing Chair');
foreach($qmap as $field=>$head) {
/* Find the question ID */
$q = mysql_query("SELECT id FROM questions WHERE year='{$j->year}' AND db_heading='{$head}'");
if(mysql_num_rows($q) == 0) {
echo "Warning: Question '$head' for judge {$j->id} doesn't exist in year '{$j->year}', cannot copy answer.\n";
continue;
}
$i = mysql_fetch_object($q);
/* Now find the answer */
$q = mysql_query("SELECT * FROM question_answers WHERE
year='{$j->year}' AND
registrations_id='{$j->id}' AND
questions_id='{$i->id}'");
echo mysql_error();
if(mysql_num_rows($q) == 0) {
echo "Warning: Judge {$j->id} did not answer question '$head' in year '{$j->year}', cannot copy answer.\n";
continue;
}
$i = mysql_fetch_assoc($q);
$uj[$field] = $i['answer'];
}
// print_r($uj);
$fields = '`'.join('`,`', array_keys($uj)).'`';
$vals = "'".join("','", array_values($uj))."'";
$q = mysql_query("INSERT INTO users_judge ($fields) VALUES ($vals)");
echo mysql_error();
/* FIXUP all the judging tables (but don't write back yet, we don't want to
* accidentally create a duplicate judges_id and overwrite it later) */
/* judges_teams_link */
$q = mysql_query("SELECT * FROM judges_teams_link WHERE judges_id='{$j->id}' AND year='{$j->year}'");
while($i = mysql_fetch_object($q))
$jtl[$i->id] = $id;
/* judges_specialawards_sel */
$q = mysql_query("SELECT * FROM judges_specialaward_sel WHERE judges_id='{$j->id}' AND year='{$j->year}'");
echo mysql_error();
while($i = mysql_fetch_object($q))
$jsal[$i->id] = $id;
/* question_answers */
$q = mysql_query("SELECT * FROM question_answers WHERE registrations_id='{$j->id}' AND year='{$j->year}'");
echo mysql_error();
while($i = mysql_fetch_object($q))
$qa[$i->id] = $id;
}
/* Now write back the judge ids */
foreach($jtl as $id=>$new_id)
$q = mysql_query("UPDATE judges_teams_link SET judges_id='$new_id' WHERE id='$id' ");
foreach($jsal as $id=>$new_id)
$q = mysql_query("UPDATE judges_specialaward_sel SET judges_id='$new_id' WHERE id='$id' ");
foreach($qa as $id=>$new_id)
$q = mysql_query("UPDATE question_answers SET registrations_id='$new_id' WHERE id='$id' ");
}
?>

40
db/db.update.116.sql Normal file
View File

@ -0,0 +1,40 @@
ALTER TABLE `users` ADD `uid` INT NOT NULL AFTER `id` ;
ALTER TABLE `users` CHANGE `sex` `sex` ENUM( 'male', 'female' ) NULL DEFAULT NULL ;
ALTER TABLE `users_committee` CHANGE `active` `committee_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
ALTER TABLE `users_committee` ADD `committee_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `committee_active` ;
ALTER TABLE `users_fair` CHANGE `active` `fair_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
ALTER TABLE `users_fair` ADD `fair_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `fair_active` ;
ALTER TABLE `users_judge` CHANGE `active` `judge_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
ALTER TABLE `users_judge` ADD `judge_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `judge_active` ;
ALTER TABLE `users_judge` ADD `cat_prefs` TINYTEXT NOT NULL AFTER `special_award_only` ;
ALTER TABLE `users_judge` ADD `div_prefs` TINYTEXT NOT NULL AFTER `cat_prefs` ;
ALTER TABLE `users_judge` ADD `divsub_prefs` TINYTEXT NOT NULL AFTER `div_prefs` ;
ALTER TABLE `users_judge` ADD `languages` TINYTEXT NOT NULL AFTER `divsub_prefs` ;
ALTER TABLE `users_judge` ADD `highest_psd` TINYTEXT NOT NULL AFTER `languages` ;
ALTER TABLE `users_judge` ADD `expertise_other` TINYTEXT NOT NULL AFTER `highest_psd` ;
ALTER TABLE `users_volunteer` CHANGE `active` `volunteer_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
ALTER TABLE `users_volunteer` ADD `volunteer_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `volunteer_active` ;
ALTER TABLE `users_volunteer` DROP `tmp`;
DROP TABLE users_years;
-- Add new judge emails, delete old
INSERT INTO `emails` ( `id` , `val` , `name` , `description` , `from` , `subject` , `body` , `type` ) VALUES
('', 'judge_recover_password', 'Judges - Recover Password', 'Recover the password for a judge if they submit a ''forgot password'' request', '', 'Password Recovery for [FAIRNAME]', 'We have received a request for the recovery of your password from this email address. Please find your new password below:\n\nJudge Email Address: [EMAIL]\nJudge Password: [PASSWORD] ', 'system'),
('', 'judge_welcome', 'Judges - Welcome', 'Welcome email sent to a judge after they have registered for the first time. This email includes their temporary password.', '', 'Judge Registration for [FAIRNAME]', 'Thank you for registering as a judge at our fair. Please find your temporary password below. After logging in for the first time you will be prompted to change your password.\n\nJudge Email Address: [EMAIL]\nJudge Password: [PASSWORD]', 'system'),
('', 'judge_new_invite', 'Judges - New Judge Invitation', 'This is sent to a new judge when they are invited using the invite users administration option.', '', 'Judge Registration for [FAIRNAME]', 'You have been invited to be a judge for the [FAIRNAME]. An account has been created for you to login with and complete your information. You can login to the judge registration site with:\n\nEmail Address: [EMAIL]\nPassword: [PASSWORD]\nYou can change your password once you login.', 'system'),
('', 'judge_add_invite', 'Judges - Add Judge Invitation', 'This is sent to existing users when they are invited using the invite users administration option.', '', 'Judge Registration for [FAIRNAME]', 'The role of judge for the [FAIRNAME] has been added to your account by a committee member. When you login again, there will be a [Switch Roles] link in the upper right hand area of the page. Clicking on [Switch Roles] will let you switch between being a Judge and your other roles without needing to logout.\n', 'system'),
('', 'judge_activate_reminder', 'Judges - Activation Reminder', 'This is sent to existing judges who have not yet activated their account for the current fair year.', '', 'Judge Registration for [FAIRNAME]', 'This message is to let you know that Judge registration for the [FAIRNAME] is now open. If you would like to participate in the fair this year please log in to the registration site using your email address ([EMAIL]) an\n', 'system'),
('', 'volunteer_activate_reminder', 'Volunteer Registration - Activation Reminder', 'This is sent to existing volunteers who have not yet activated their account for the current fair year.', '', 'Volunteer Registration for [FAIRNAME]', 'This message is to let you know that Volunteer registration for the [FAIRNAME] is now open. If you would like to participate in the fair this year please log in to the registration site using your email address ([EMAIL]).\n', 'system');
DELETE FROM `emails` WHERE `val`='new_judge_invite';
DELETE FROM `emails` WHERE `val`='register_judges_resend_password';
-- Fix the names of these emails
UPDATE `emails` SET `name` = 'Volunteers - New Volunteer Invitation' WHERE `val`='volunteer_new_invite';
UPDATE `emails` SET `name` = 'Volunteers - Add Volunteer Invitation' WHERE `val`='volunteer_add_invite';

31
db/db.update.117.php Normal file
View File

@ -0,0 +1,31 @@
<?
function db_update_117_post()
{
global $config;
$qmap = array('years_school' => 'Years School',
'years_regional' => 'Years Regional',
'years_national' => 'Years National',
'willing_chair' => 'Willing Chair');
foreach($qmap as $field=>$head) {
$q = mysql_query("SELECT id FROM questions WHERE db_heading='{$head}'");
while($i = mysql_fetch_object($q)) {
$id = $i->id;
/* Drop all answers for this question */
mysql_query("DELETE FROM question_answers
WHERE questions_id='$id'");
}
/* Now dump the question itself */
mysql_query("DELETE FROM questions
WHERE id='$id'");
}
}

21
db/db.update.117.sql Normal file
View File

@ -0,0 +1,21 @@
-- complete has been moved inside each users_* table
ALTER TABLE `users` DROP `complete`;
-- drop the old judge tables, all this info is now in the new user system (converted in the 116 update)
DROP TABLE `judges`,`judges_catpref`,`judges_expertise`,`judges_languages`,`judges_years` ;
-- questions table should use users_id now (which is what was being saved in the registrations_id)
ALTER TABLE `question_answers` CHANGE `registrations_id` `users_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';
-- The answer has been linked to a users_id that is unique per-year, so we don't need to duplicate the year storage
ALTER TABLE `question_answers` DROP `year`;
-- Use users_id instead of judges_id now, the judges_id was converted to the proper users_id in the 116 update
ALTER TABLE `judges_specialaward_sel` CHANGE `judges_id` `users_id` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `judges_teams_link` CHANGE `judges_id` `users_id` INT( 11 ) NOT NULL DEFAULT '0' ;
-- The users_id is linked with the year, don't need to store it here too
ALTER TABLE `judges_specialaward_sel` DROP `year`;
ALTER TABLE users ADD UNIQUE (username,year);

92
db/db.update.118.php Normal file
View File

@ -0,0 +1,92 @@
<?
function db_update_118_post()
{
global $config;
$available="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
$availlen=strlen($available) - 1;
$userfields=array("salutation","firstname","lastname","email","phonehome","phonework","phonecell","fax");
//grab all the contacts from awards_contacts
$q=mysql_query("SELECT * FROM award_contacts");
while($r=mysql_fetch_object($q)) {
//if its older than the current year, then set them to complete/active because if they were in the
//system then, then they must have beenc omplete and active
//set anyone for the current fair year to complete=no, active = yes, because its not too late to get them
//to login and make sure that all the info is complete
if($r->year<$config['FAIRYEAR']) {
$complete="yes";
$active="yes";
}
else {
$complete="no";
$active="yes";
}
//see if a user exists with this email
$uq=mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($r->email)."' AND year='$r->year'");
if($r->email && $ur=mysql_fetch_object($uq)) {
$user_id=$ur->id;
echo "Using existing users.id=$user_id for award_contacts.id=$r->id because email address/year ($r->email/$r->year) matches\n";
//update any info we have thats missing
$sqlset="";
foreach($userfields AS $f) {
//if its NOT in their USER record, but it IS in their AWARD_CONTACTS record, then bring it over, else, assume the users record has priority
if(!$ur->$f && $r->$f) {
$sqlset.="`$f`='".mysql_real_escape_string($r->$f)."', ";
}
}
$sql="UPDATE users SET $sqlset `types`='{$ur->types},sponsor' WHERE id='$user_id'";
mysql_query($sql);
echo mysql_error();
echo " Updated user record\n";
}
else {
//we need a username, if htere's no email, then we need to gerneate one to use.
if($r->email) {
$username=$r->email;
}
else {
$username="";
for($x=0;$x<16;$x++)
$username.=$available{rand(0,$availlen)};
}
//and create them a password
$password="";
for($x=0;$x<8;$x++)
$password.=$available{rand(0,$availlen)};
//set passwordset to 0000-00-00 to force it to expire on next login
$sql="INSERT INTO users (`types`,`username`,`created`,`password`,`passwordset`,`".implode("`,`",$userfields)."`,`year`) VALUES (";
$sql.="'sponsor','".mysql_real_escape_string($username)."',NOW(),'$password','0000-00-00'";
foreach($userfields AS $f) {
$sql.=",'".mysql_real_escape_string($r->$f)."'";
}
$sql.=",'".mysql_real_escape_string($r->year)."')";
mysql_query($sql);
echo mysql_error();
$user_id=mysql_insert_id();
//and link it to themselves as a starting record
mysql_query("UPDATE users SET uid='$user_id' WHERE id='$user_id'");
echo "Creating new users.id=$user_id for award_contacts.id=$r->id\n";
}
echo " Linking $user_id to users_sponsor record\n";
mysql_query("INSERT INTO users_sponsor (`users_id`,`sponsors_id`,`sponsor_complete`,`sponsor_active`,`primary`,`position`,`notes`) VALUES (
'".$user_id."',
'".$r->award_sponsors_id."',
'$complete',
'$active',
'".mysql_real_escape_string($r->primary)."',
'".mysql_real_escape_string($r->position)."',
'".mysql_real_escape_string($r->notes)."')");
echo mysql_error();
}
}
?>

29
db/db.update.118.sql Normal file
View File

@ -0,0 +1,29 @@
CREATE TABLE `users_sponsor` (
`users_id` int(11) NOT NULL default '0',
`sponsors_id` int(11) NOT NULL default '0',
`sponsor_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
`sponsor_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
`primary` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
`position` VARCHAR(64) NOT NULL default '',
`notes` text NOT NULL,
PRIMARY KEY (`users_id`)
) TYPE=MyISAM;
ALTER TABLE `users` CHANGE `types` `types` SET( 'student', 'judge', 'committee', 'volunteer', 'fair', 'sponsor' ) NOT NULL ;
ALTER TABLE `users` ADD `salutation` VARCHAR( 8 ) NOT NULL AFTER `types` ;
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` )
VALUES (
'sponsor_personal_fields', 'phonecell,phonework,fax,org',
'Sponsors', 'multisel',
'salutation=Salutation|sex=Gender|phonehome=Home Phone|phonework=Work Phone|phonecell=Cell Phone|fax=Fax|org=Organization|birthdate=Birthdate|lang=Preferred Language|address=Address and PostalCode|city=City|province=Province',
'500', 'Personal Information to ask for on the Sponsor Contact profile page (in addition to Name and Email)', '-1');
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` )
VALUES (
'sponsor_personal_required', '',
'Sponsors', 'multisel',
'salutation=Salutation|sex=Gender|phonehome=Home Phone|phonework=Work Phone|phonecell=Cell Phone|fax=Fax|org=Organization|birthdate=Birthdate|lang=Preferred Language|address=Address and PostalCode|city=City|province=Province',
'600', 'Required Personal Information on the Sponsor Contact profile page (Name and Email is always required)', '-1');

65
db/db.update.119.sql Normal file
View File

@ -0,0 +1,65 @@
DROP TABLE award_contacts;
CREATE TABLE `fundraising` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`type` VARCHAR( 32 ) NOT NULL ,
`name` VARCHAR( 128 ) NOT NULL ,
`description` TEXT NULL DEFAULT NULL ,
`system` ENUM( 'no', 'yes' ) DEFAULT 'no' NOT NULL ,
`goal` INT UNSIGNED NOT NULL ,
`year` INT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
ALTER TABLE `fundraising` ADD UNIQUE (type,year);
INSERT INTO `fundraising` ( `id` , `type` , `name` , `description`, `system` , `goal` , `year` ) VALUES ( '', 'general', 'General Funds', 'General funds donated to the fair may be allocated as the fair organizers see fit','yes', '0', '-1');
INSERT INTO `fundraising` ( `id` , `type` , `name` , `description`, `system` , `goal` , `year` ) VALUES ( '', 'awards', 'Award Sponsorships', 'Award Sponsorships are provided to allow an organization to sponsor a specific award that is given out at the fair', 'yes', '0', '-1');
ALTER TABLE `award_sponsors` RENAME `sponsors` ;
ALTER TABLE `sponsors` DROP `confirmed`;
ALTER TABLE `sponsors` ADD `tollfree` VARCHAR( 32 ) NOT NULL AFTER `phone` ;
ALTER TABLE `sponsors` ADD `website` VARCHAR( 128 ) NOT NULL AFTER `email` ;
ALTER TABLE `sponsors` ADD `donationpolicyurl` VARCHAR( 255 ) NOT NULL AFTER `notes` ;
ALTER TABLE `sponsors` ADD `fundingselectiondate` DATE NULL DEFAULT NULL AFTER `donationpolicyurl` ;
ALTER TABLE `sponsors` ADD `logo` VARCHAR (128 ) NULL DEFAULT NULL AFTER `fundingselectiondate` ;
ALTER TABLE `sponsors` ADD `waiveraccepted` ENUM ( 'no' , 'yes' ) DEFAULT 'no' NOT NULL AFTER `logo`;
ALTER TABLE `sponsors` ADD `taxreceiptrequired` ENUM ( 'no' , 'yes' ) DEFAULT 'no' NOT NULL AFTER `waiveraccepted`;
ALTER TABLE `award_awards` CHANGE `award_sponsors_id` `sponsors_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';
CREATE TABLE `sponsors_logs` (
`id` INT NOT NULL AUTO_INCREMENT ,
`sponsors_id` INT NOT NULL ,
`dt` DATETIME NOT NULL ,
`users_id` INT NOT NULL ,
`log` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
CREATE TABLE `sponsorships` (
`id` INT NOT NULL AUTO_INCREMENT ,
`sponsors_id` INT NOT NULL ,
`fundraising_type` VARCHAR( 32 ) NOT NULL ,
`value` INT NOT NULL ,
`status` ENUM( 'pending', 'confirmed', 'received' ) NOT NULL ,
`probability` INT NOT NULL ,
`year` INT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
CREATE TABLE `sponsorships_levels` (
`id` INT NOT NULL AUTO_INCREMENT ,
`level` VARCHAR( 64 ) NOT NULL ,
`min` INT NOT NULL ,
`max` INT NOT NULL ,
`description` TEXT NOT NULL ,
`year` INT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
INSERT INTO sponsorships_levels (`level`,`min`,`max`,`year`) VALUES ('Bronze','100','499',-1);
INSERT INTO sponsorships_levels (`level`,`min`,`max`,`year`) VALUES ('Silver','500','999',-1);
INSERT INTO sponsorships_levels (`level`,`min`,`max`,`year`) VALUES ('Gold','1000','10000',-1);

3
db/db.update.120.sql Normal file
View File

@ -0,0 +1,3 @@
-- This wasn't done in the 116 update
UPDATE users SET `uid`=`id` WHERE `uid`=0;

2
db/db.update.121.sql Normal file
View File

@ -0,0 +1,2 @@
ALTER TABLE `committees_link` CHANGE `users_id` `users_uid` INT( 11 ) NOT NULL DEFAULT '0' ;

43
db/db.update.122.php Normal file
View File

@ -0,0 +1,43 @@
<?
function db_update_122_post()
{
global $config;
$year = $config['FAIRYEAR'];
$q = mysql_query("SELECT * FROM judges_timeslots WHERE year='$year'");
$round = array();
while($r = mysql_fetch_assoc($q)) {
$type = $r['type'];
if(!array_key_exists($type, $round)) {
$round[$type]['starttime'] = $r['starttime'];
$round[$type]['endtime'] = $r['endtime'];
$round[$type]['date'] = $r['date'];
}
if($r['starttime'] < $round[$type]['starttime'] ) {
$round[$type]['starttime'] = $r['starttime'];
}
if($r['endtime'] > $round[$type]['endtime']) {
$round[$type]['endtime'] = $r['endtime'];
}
}
foreach($round as $type=>$d) {
mysql_query("INSERT INTO judges_timeslots (round_id,type,date,starttime,endtime,year)
VALUES ('0','$type','{$d['date']}','{$d['starttime']}','{$d['endtime']}','$year')");
$round_id = mysql_insert_id();
mysql_query("UPDATE judges_timeslots SET
round_id='$round_id', type='timeslot'
WHERE type='$type' AND year='$year'");
/* Undo the set we just did to the round we just inserted */
mysql_query("UPDATE judges_timeslots SET
round_id='0',type='$type'
WHERE id='$round_id'");
}
}
?>

10
db/db.update.122.sql Normal file
View File

@ -0,0 +1,10 @@
ALTER TABLE `judges_timeslots` ADD `round_id` INT NOT NULL AFTER `id` ;
ALTER TABLE `judges_timeslots` ADD `name` TINYTEXT NOT NULL AFTER `endtime` ;
ALTER TABLE `judges_timeslots` ADD `type` ENUM( 'timeslot','divisional1', 'divisional2', 'grand', 'special' ) NOT NULL AFTER `round_id` ;
UPDATE `judges_timeslots` SET `type`='divisional1' WHERE allowdivisional='yes';
UPDATE `judges_timeslots` SET `type`='special' WHERE allowdivisional='no';
ALTER TABLE `judges_timeslots` DROP `allowdivisional` ;

3
db/db.update.123.sql Normal file
View File

@ -0,0 +1,3 @@
ALTER TABLE `config` CHANGE `type` `type` ENUM( '', 'yesno', 'number', 'text', 'enum', 'multisel', 'language' ) NOT NULL ;
UPDATE config SET `type`='language' WHERE `var`='default_language';

11
db/db.update.124.sql Normal file
View File

@ -0,0 +1,11 @@
CREATE TABLE `judges_availability` (
`id` INT NOT NULL AUTO_INCREMENT ,
`users_id` INT NOT NULL ,
`date` DATE NOT NULL ,
`start` TIME NOT NULL ,
`end` TIME NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year`)
VALUES ( 'judges_availability_enable', 'no', 'Judge Registration', 'yesno', '', '950', 'Allow judges to specify their time availability on the fair day based on the defined judging rounds/timeslots. The scheduler will then use this judge availability data when assigning judges to teams and projects.', '-1');

6
db/db.update.125.sql Normal file
View File

@ -0,0 +1,6 @@
DROP TABLE `fairs`;
ALTER TABLE `users_fair` CHANGE `fairs_id` `fair_name` TINYTEXT NOT NULL;
ALTER TABLE `users_fair` ADD `fair_abbrv` VARCHAR( 16 ) NOT NULL AFTER `fair_name` ;

71
db/db.update.126.sql Normal file
View File

@ -0,0 +1,71 @@
CREATE TABLE `fairs_stats` (
`id` int(11) NOT NULL auto_increment,
`users_uid` int(11) NOT NULL default '0',
`year` int(11) NOT NULL default '0',
`start_date` date NOT NULL default '0000-00-00',
`end_date` date NOT NULL default '0000-00-00',
`address` text NOT NULL,
`budget` float NOT NULL default '0',
`ysf_affiliation_complete` enum('Y','N') NOT NULL default 'Y',
`charity` tinytext NOT NULL,
`male_1` int(11) NOT NULL default '0',
`male_4` int(11) NOT NULL default '0',
`male_7` int(11) NOT NULL default '0',
`male_9` int(11) NOT NULL default '0',
`male_11` int(11) NOT NULL default '0',
`female_1` int(11) NOT NULL default '0',
`female_4` int(11) NOT NULL default '0',
`female_7` int(11) NOT NULL default '0',
`female_9` int(11) NOT NULL default '0',
`female_11` int(11) NOT NULL default '0',
`projects_1` int(11) NOT NULL default '0',
`projects_4` int(11) NOT NULL default '0',
`projects_7` int(11) NOT NULL default '0',
`projects_9` int(11) NOT NULL default '0',
`projects_11` int(11) NOT NULL default '0',
`publicschools` int(11) NOT NULL default '0',
`privateschools` int(11) NOT NULL default '0',
`schooldistricts` int(11) NOT NULL default '0',
`studentsvisiting` int(11) NOT NULL default '0',
`publicvisiting` int(11) NOT NULL default '0',
`firstnations` int(11) NOT NULL default '0',
`innercity` int(11) NOT NULL default '0',
`teacherssupporting` int(11) NOT NULL default '0',
`increasedinterest` int(11) NOT NULL default '0',
`consideringcareer` int(11) NOT NULL default '0',
`next_chair_name` varchar(128) NOT NULL default '',
`next_chairemail` varchar(64) NOT NULL default '',
`next_chair_hphone` varchar(32) NOT NULL default '',
`next_chair_bphone` varchar(32) NOT NULL default '',
`next_chair_fax` varchar(32) NOT NULL default '',
`scholarships` text NOT NULL,
`delegate1` varchar(64) NOT NULL default '',
`delegate2` varchar(64) NOT NULL default '',
`delegate3` varchar(64) NOT NULL default '',
`delegate4` varchar(64) NOT NULL default '',
`delegate1_email` tinytext NOT NULL,
`delegate2_email` tinytext NOT NULL,
`delegate3_email` tinytext NOT NULL,
`delegate4_email` tinytext NOT NULL,
`delegate1_size` enum('small','medium','large','xlarge') NOT NULL default 'small',
`delegate2_size` enum('small','medium','large','xlarge') NOT NULL default 'small',
`delegate3_size` enum('small','medium','large','xlarge') NOT NULL default 'small',
`delegate4_size` enum('small','medium','large','xlarge') NOT NULL default 'small',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;
ALTER TABLE `schools` ADD `atrisk` ENUM( 'no', 'yes' ) NOT NULL default 'no';
-- Update the designate into '', public, indpendent, and home, more useful for
-- SFIAB. This pre-conversions are for everyone in BC who imported the science
-- world school list
UPDATE schools SET designate='public' WHERE designate='Standard';
UPDATE schools SET designate='independent' WHERE designate='Independent';
UPDATE schools SET designate='public' WHERE designate='Alternate';
UPDATE schools SET designate='public' WHERE designate='PRP';
UPDATE schools SET designate='public' WHERE designate='Continuing Education';
UPDATE schools SET designate='public' WHERE designate='Youth Containment Ctr';
UPDATE schools SET designate='home' WHERE designate='Distributed Learning';
UPDATE schools SET designate='independent' WHERE designate='Offshore';
ALTER TABLE `schools` CHANGE `designate` `designate` ENUM( '', 'public', 'independent', 'home' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;

36
db/db.update.127.sql Normal file
View File

@ -0,0 +1,36 @@
INSERT INTO `config` (`var`, `val`, `category`, `type`, `type_values`, `ord`, `description`, `year`) VALUES
('fair_stats_participation', 'yes', 'Science Fairs', 'yesno', '', 100, 'Gather Stats: Student and School Participation (students, gender, and projects) by age group.', -1),
('fair_stats_schools_ext', 'yes', 'Science Fairs', 'yesno', '', 200, 'Gather Stats: Extended school participation data.<ul>\r\n<li>Number of at-risk schools and students<li>Number of public schools and students<li>Number of private/independent schools and students</ul>', -1),
('fair_stats_minorities', 'firstnations', 'Science Fairs', 'multisel', 'firstnations=Number of First Nation students|disabled=Number of Disabled students', 300, 'Gather Stats: Participant minority demographics (must be filled in manually by the fair)', -1),
('fair_stats_guests', 'yes', 'Science Fairs', 'yesno', '', 400, 'Gather Stats: Number of student and public guests (must be filled in manually by the fair)', -1),
('fair_stats_sffbc_misc', 'yes', 'Science Fairs', 'yesno', '', '500', 'Gather Stats: Misc. SFFBC Data<ul> <li>Supporting teachers <li>Students with increased interest in sci and tech <li>Students considering a career in science</ul>', '-1');
ALTER TABLE `fairs_stats` CHANGE `publicschools` `schools_public` INT( 11 ) NOT NULL DEFAULT '0',
CHANGE `privateschools` `schools_private` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `fairs_stats` ADD `students_public` INT NOT NULL AFTER `projects_11` ;
ALTER TABLE `fairs_stats` ADD `students_private` INT NOT NULL AFTER `schools_public` ;
ALTER TABLE `fairs_stats` CHANGE `users_uid` `fairs_id` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `fairs_stats` ADD `students_total` INT NOT NULL AFTER `projects_11` ,
ADD `schools_total` INT NOT NULL AFTER `students_total` ;
ALTER TABLE `fairs_stats` CHANGE `innercity` `students_atrisk` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `fairs_stats` ADD `schools_atrisk` INT NOT NULL AFTER `students_atrisk` ;
ALTER TABLE `fairs_stats` ADD `schools_active` INT NOT NULL AFTER `schools_total` ;
ALTER TABLE `fairs_stats` ADD `committee_members` INT NOT NULL AFTER `consideringcareer` ,
ADD `judges` INT NOT NULL AFTER `committee_members` ;
ALTER TABLE `fairs_stats` CHANGE `schooldistricts` `schools_districts` INT( 11 ) NOT NULL DEFAULT '0';
CREATE TABLE `fairs` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TINYTEXT NOT NULL ,
`abbrv` VARCHAR( 16 ) NOT NULL ,
`type` ENUM( 'feeder', 'sfiab', 'ysf' ) NOT NULL ,
`url` TINYTEXT NOT NULL ,
`username` varchar( 32 ) NOT NULL ,
`password` varchar( 32 ) NOT NULL
) ENGINE = MYISAM ;
ALTER TABLE `users_fair` CHANGE `fair_name` `fairs_id` INT NOT NULL;
ALTER TABLE `users_fair` DROP `fair_abbrv` ;

12
db/db.update.128.sql Normal file
View File

@ -0,0 +1,12 @@
INSERT INTO `config` (`var`, `val`, `category`, `type`, `type_values`, `ord`, `description`, `year`) VALUES
('fair_stats_info', 'yes', 'Science Fairs', 'yesno', '', 600, 'Gather Stats: Information about the fair (date, location, budget, charity info).', -1),
('fair_stats_next_chair', 'yes', 'Science Fairs', 'yesno', '', 700, 'Gather Stats: Chairperson name and contact info for the next year', -1),
('fair_stats_scholarships', 'yes', 'Science Fairs', 'yesno', '', 800, 'Gather Stats: Scholarships given out by the fair', -1),
('fair_stats_delegates', 'yes', 'Science Fairs', 'yesno', '', '900', 'Gather Stats: CWSF Delegate names/email/jacket size', '-1');
ALTER TABLE `fairs` ADD `website` TINYTEXT NOT NULL AFTER `url` ;
ALTER TABLE `fairs` ADD `enable_stats` ENUM( 'no', 'yes' ) NOT NULL ,
ADD `enable_awards` ENUM( 'no', 'yes' ) NOT NULL ,
ADD `enable_winners` ENUM( 'no', 'yes' ) NOT NULL ;

52
db/db.update.129.php Normal file
View File

@ -0,0 +1,52 @@
<?
require_once('../user.inc.php');
function db_update_129_pre()
{
/* Load all external award sources */
$source_map = array();
$q = mysql_query("SELECT * FROM award_sources");
while($r = mysql_fetch_assoc($q)) {
/* Make a user, use the password generator to get
* a random username */
$u = user_create('fair', user_generate_password());
/* Add a Fair Entry */
$name = mysql_escape_string($r['name']);
$url = mysql_escape_string($r['url']);
$website = mysql_escape_string($r['website']);
$username = mysql_escape_string($r['username']);
$password = mysql_escape_string($r['password']);
$en = ($r['enabled'] == 'no') ? 'no' : 'yes';
mysql_query("INSERT INTO fairs (`id`,`name`,`abbrv`,`type`,
`url`,`website`,`username`,`password`,`enable_stats`,
`enable_awards`,`enable_winners`) VALUES (
'', '$name', '', 'ysf', '$url', '$web',
'$username','$password','no','$en','$en')");
/* Link the fair to the user */
$u['fairs_id'] = mysql_insert_id();
/* Record the old sources_id to new sources_id mapping */
$source_map[$r['id']] = $u['fairs_id'];
user_save($u);
}
/* Map all awards to their new source IDs */
$q = mysql_query("SELECT * FROM award_awards");
$keys = array_keys($source_map);
while($r = mysql_fetch_assoc($q)) {
$old_id = $r['award_sources_id'];
if(!in_array($old_id, $keys)) continue;
$qq = mysql_query("UPDATE award_awards SET award_sources_id='{$source_map[$old_id]}'
WHERE id='{$r['id']}'");
}
}
?>

0
db/db.update.129.sql Normal file
View File

4
db/db.update.130.sql Normal file
View File

@ -0,0 +1,4 @@
ALTER TABLE `award_awards` CHANGE `award_sources_id` `award_source_fairs_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL;
ALTER TABLE `fairs` ADD `award_awards_ids` TEXT NOT NULL;

View File

@ -3,21 +3,30 @@ CREATE TABLE `isefforms` (
`name` varchar(128) NOT NULL,
`required` enum('N','Y') NOT NULL,
`description` text NOT NULL,
`filename` varchar(128) default NULL,
`url` varchar(128) default NULL,
`formper` ENUM('student','project') NOT NULL DEFAULT project,
`year` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM ;
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1) Checklist for Adult Sponsor', 'Y', 'This completed form is required for ALL projects and must be completed before experimentation.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1A) Student Checklist', 'Y', 'This form is required for ALL projects.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1A2) Research Plan', 'Y', 'REQUIRED for ALL Projects Before Experimentation. A complete research hplan must accompany Checklist for Student (1A).', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1B) Approval Form', 'Y', 'A completed form is required for each student, including all team members.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1C) Regulated Research Institutional/Industrial Setting Form', 'N', 'This form must be completed after experimentation by the adult supervising the student research conducted in a regulated research institution, industrial setting or an work site other than home, school or field.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(2) Qualified Scientist Form', 'N', 'May be required for researc involving human subjects, vertebrate animals, potentially hazardous biological agents, and DEA-controlled substances. Must be completed and signed before the start of student experimentation.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(3) Risk Assessment Form', 'N', 'Required for projects using hazardous chemicals, activities or devices. Must be completed before experimentation.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(4) Human Subjects Form', 'N', 'Required for all research involving human subjects. IRB approval required before experimentation.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(5A) Vertebrate Animal Form', 'N', 'Required for all research involving vertebrate animals that is conducted in a Non-Regulated Research Site. (SRC approval required before experimentation.)', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(5B) Vertebrate Animal Form', 'N', 'Required for all research involving vertebrate animals that is conducated at a Regulated Research Institution. (IACUC approval required before experimentation.)', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(6A) Potentially Hazardous Biological Agents Risk Assessment Form', 'N', 'Required for research involving microorganisms, rDNA, fresh/frozen tissue, blood and body fluids. SRC/IACUC/IBC approval required before experimentation.', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(6B) Human and Vertebrate Animal Tissue Form', 'N', 'Required for projects using fresh/frozen tissue, primary cell cultures, blood, blood products and body fluids. If the research involves living organisms, please ensure that the proper human or animal forms are completed. All projets using any tissue listed above, must also complete Form 6A', NULL, 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(7A) Continuation Projects Form', 'N', 'Required for projects that are a continuation in the same field of study as a previous project. This form must be accompanied by the previous year\'s abstract, Form (1A) and Research Plan', NULL, 2009);
CREATE TABLE `isefforms_registrations_link` (
`id` int(10) unsigned NOT NULL auto_increment,
`registrations_id` int(10) unsigned NOT NULL,
`isefforms_id` int(10) unsigned NOT NULL,
`filename` varchar(128) NOT NULL
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(1) Checklist for Adult Sponsor', 'Y', 'This completed form is required for ALL projects and must be completed before experimentation.', 'http://www.societyforscience.org/isef/document/chklst09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(1A) Student Checklist', 'Y', 'This form is required for ALL projects.', 'http://www.societyforscience.org/isef/document/respln09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(1A2) Research Plan', 'Y', 'REQUIRED for ALL Projects Before Experimentation. A complete research hplan must accompany Checklist for Student (1A).', 'http://www.societyforscience.org/isef/document/respln09.pdf' , 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `formper`, `year`) VALUES ('(1B) Approval Form', 'Y', 'A completed form is required for each student, including all team members.', 'http://www.societyforscience.org/isef/document/1bappr09.pdf', 'student', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(1C) Regulated Research Institutional/Industrial Setting Form', 'N', 'This form must be completed after experimentation by the adult supervising the student research conducted in a regulated research institution, industrial setting or an work site other than home, school or field.', 'http://www.societyforscience.org/isef/document/1cinst09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(2) Qualified Scientist Form', 'N', 'May be required for researc involving human subjects, vertebrate animals, potentially hazardous biological agents, and DEA-controlled substances. Must be completed and signed before the start of student experimentation.', 'http://www.societyforscience.org/isef/document/qualsc09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(3) Risk Assessment Form', 'N', 'Required for projects using hazardous chemicals, activities or devices. Must be completed before experimentation.', 'http://www.societyforscience.org/isef/document/rskass09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(4) Human Subjects Form', 'N', 'Required for all research involving human subjects. IRB approval required before experimentation.', 'http://www.societyforscience.org/isef/document/hmsubj09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(5A) Vertebrate Animal Form', 'N', 'Required for all research involving vertebrate animals that is conducted in a Non-Regulated Research Site. (SRC approval required before experimentation.)', 'http://www.societyforscience.org/isef/document/vertan09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(5B) Vertebrate Animal Form', 'N', 'Required for all research involving vertebrate animals that is conducated at a Regulated Research Institution. (IACUC approval required before experimentation.)', 'http://www.societyforscience.org/isef/document/vertan09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(6A) Potentially Hazardous Biological Agents Risk Assessment Form', 'N', 'Required for research involving microorganisms, rDNA, fresh/frozen tissue, blood and body fluids. SRC/IACUC/IBC approval required before experimentation.', 'http://www.societyforscience.org/isef/document/biohaz09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(6B) Human and Vertebrate Animal Tissue Form', 'N', 'Required for projects using fresh/frozen tissue, primary cell cultures, blood, blood products and body fluids. If the research involves living organisms, please ensure that the proper human or animal forms are completed. All projets using any tissue listed above, must also complete Form 6A', 'http://www.societyforscience.org/isef/document/tissue09.pdf', 2009);
INSERT INTO `isefforms` (`name`, `required`, `description`, `url`, `year`) VALUES ('(7A) Continuation Projects Form', 'N', 'Required for projects that are a continuation in the same field of study as a previous project. This form must be accompanied by the previous year\'s abstract, Form (1A) and Research Plan', 'http://www.societyforscience.org/isef/document/contin09.pdf', 2009);

133
dialog.inc.php Normal file
View File

@ -0,0 +1,133 @@
<? require_once("ajax.inc.php"); ?>
<div class="SFIABDialog" id="SFIABDialog" style="position: absolute; visibility: hidden;">
<div class="SFIABDialogInner" id="SFIABDialogInner"></div>
</div>
<div id="FadeScreenDiv" style="visibility: hidden; top: 0px; left: 0px;"></div>
<script type="text/javascript">
var SFIABDialogGrowWidth=0;
var SFIABDialogGrowHeight=0;
var SFIABDialogFinalWidth=100;
var SFIABDialogFinalHeight=100;
var SFIABDialogGrowWidthStep=0;
var SFIABDialogGrowHeightStep=0;
var SFIABDialogGrowTime=0; //0 means no animation, i dont know why i coded the animation thing to begin with, who knows, maybe we'll want it somewhere at some point
var SFIABDialogGrowSteps=5;
var SFIABDialogInnerPre='<form id="SFIABDialogForm" method="post" action="<?=$_SERVER['PHP_SELF']?>">';
var SFIABDialogInnerPost='<table width="100%"><tr><td style="width: 50%; text-align: center;"><input onclick="return SFIABDialogSubmit()" type="submit" value="<?=i18n("Save")?>"></td><td style="text-align: center;"><input onclick="return SFIABDialogCancel()" type="button" value="<?=i18n("Cancel")?>"></td></tr></table></form>';
function SFIABDialog(e, url, width, height) {
var posx = 0;
var posy = 0;
//get this going while we do the other stuff
SFIABDialogFill(url);
if(!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
var d=document.getElementById('SFIABDialog');
var di=document.getElementById('SFIABDialogInner');
var fs=document.getElementById('FadeScreenDiv');
fs.style.visibility="visible";
d.style.top=posy+'px';
d.style.left=posx+'px';
di.style.visibility='hidden';
if(SFIABDialogGrowTime==0) {
d.style.visibility='visible';
d.style.width=width+"px";
d.style.height=height+"px";
}
else
{
//expand it in over time...
SFIABDialogGrowWidth=1;
SFIABDialogGrowHeight=1;
//set the final width&&height
SFIABDialogFinalWidth=width;
SFIABDialogFinalHeight=height;
//set the steps
SFIABDialogGrowWidthStep=Math.round(width/SFIABDialogGrowSteps);
SFIABDialogGrowHeightStep=Math.round(height/SFIABDialogGrowSteps);
//set the size to start us off, and go visible
d.style.width=SFIABDialogGrowWidth+"px";
d.style.height=SFIABDialogGrowHeight+"px";
d.style.visibility='visible';
//startup the timer
setTimeout('growDialog()',Math.round(SFIABDialogGrowTime/SFIABDialogGrowSteps));
}
return false;
}
function growDialog() {
SFIABDialogGrowWidth+=SFIABDialogGrowWidthStep;
SFIABDialogGrowHeight+=SFIABDialogGrowHeightStep;
if(SFIABDialogGrowWidth>SFIABDialogFinalWidth)
SFIABDialogGrowWidth=SFIABDialogFinalWidth;
if(SFIABDialogGrowHeight>SFIABDialogFinalHeight)
SFIABDialogGrowHeight=SFIABDialogFinalHeight;
var d=document.getElementById('SFIABDialog');
d.style.width=SFIABDialogGrowWidth+"px";
d.style.height=SFIABDialogGrowHeight+"px";
if(SFIABDialogGrowWidth<SFIABDialogFinalWidth || SFIABDialogGrowHeight<SFIABDialogFinalHeight)
{
setTimeout('growDialog()',Math.round(SFIABDialogGrowTime/SFIABDialogGrowSteps));
}
else {
var di=document.getElementById('SFIABDialogInner');
di.style.visibility="visible";
}
}
function SFIABDialogFill(url) {
var d=document.getElementById('SFIABDialogInner');
d.innerHTML="";
d.style.visibility='hidden';
http.open("GET",url,true);
http.onreadystatechange=SFIABDialogFillResponse;
http.send(null);
}
function SFIABDialogFillResponse() {
try {
if(http.readyState==4) {
var di=document.getElementById('SFIABDialogInner');
var objhtml=http.responseText;
di.innerHTML=SFIABDialogInnerPre+objhtml+SFIABDialogInnerPost;
di.style.visibility='visible';
}
}
catch (e) {
}
}
function SFIABDialogSubmit() {
//we let it submit the form, which reloads the page
return true;
}
function SFIABDialogCancel() {
var d=document.getElementById('SFIABDialog');
var di=document.getElementById('SFIABDialogInner');
var fs=document.getElementById('FadeScreenDiv');
fs.style.visibility="hidden";
d.style.visibility="hidden";
di.style.visibility="hidden";
return false;
}
</script>

52
fair.inc.php Normal file
View File

@ -0,0 +1,52 @@
<?
/*
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>
Copyright (C) 2007 David Grant <dave@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.
*/
?>
<?
function fair_status_info($u)
{
global $config;
if(trim($u['fairname']) != '') {
return "complete";
}
return "incomplete";
}
function fair_status_update(&$u)
{
global $config;
if( user_personal_info_status($u) == 'complete'
&& fair_status_info($u) == 'complete' )
$u['fair_complete'] = 'yes';
else
$u['fair_complete'] = 'no';
user_save($u);
return ($u['fair_complete'] == 'yes') ? 'complete' : 'incomplete';
}
?>

212
fair_info.php Normal file
View File

@ -0,0 +1,212 @@
<?
/*
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>
Copyright (C) 2007 David Grant <dave@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_once("common.inc.php");
require_once("user.inc.php");
require_once("fair.inc.php");
$fair_type = array('feeder' => 'Feeder Fair', 'sfiab' => 'SFIAB Upstream', 'ysf' => 'YSF/CWSF Upstream');
function yesno($name, $val)
{
echo "<select name=\"$name\">";
$sel = ($val == 'yes') ? 'selected="selected"' : '';
echo "<option $sel value=\"yes\">".i18n("Yes")."</option>";
$sel = ($val == 'no') ? 'selected="selected"' : '';
echo "<option $sel value=\"no\">".i18n("No")."</option>";
echo "</select>";
}
if($_SESSION['embed'] == true) {
$u = user_load($_SESSION['embed_edit_id']);
} else {
user_auth_required('fair');
$u = user_load($_SESSION['users_id']);
}
if($_POST['action']=="save")
{
$id = $_POST['id'];
if(trim($id) == '') {
$q = mysql_query("INSERT INTO fairs(`id`,`name`) VALUES('','new entry')");
$id = mysql_insert_id();
} else {
$id = intval($id);
}
$name = mysql_escape_string(stripslashes($_POST['name']));
$abbrv = mysql_escape_string(stripslashes($_POST['abbrv']));
$url = mysql_escape_string($_POST['url']);
$website = mysql_escape_string($_POST['website']);
$type = array_key_exists($_POST['type'], $fair_type) ? $_POST['type'] : '';
$username = mysql_escape_string(stripslashes($_POST['username']));
$password = mysql_escape_string(stripslashes($_POST['password']));
$enable_stats = ($_POST['enable_stats'] == 'yes') ? 'yes' : 'no';
$enable_awards = ($_POST['enable_awards'] == 'yes') ? 'yes' : 'no';
$enable_winners = ($_POST['enable_winners'] == 'yes') ? 'yes' : 'no';
$q = mysql_query("UPDATE fairs SET `name`='$name',
`abbrv`='$abbrv', `url`='$url',
`website`='$website',
`type`='$type' , `username`='$username',
`password`='$password',
`enable_stats`='$enable_stats',
`enable_awards`='$enable_awards',
`enable_winners`='$enable_winners'
WHERE id=$id");
$u['fairs_id'] = $id;
user_save($u);
message_push(notice(i18n("Fair Informaiton successfully updated")));
}
/* update overall status */
fair_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=fair_status_info($u);
if($newstatus!='complete')
message_push(error(i18n("Fair Information Incomplete")));
else
message_push(happy(i18n("Fair Information Complete")));
}
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Fair Information')."</h3>";
echo "<br />";
} else {
//send the header
send_header("Fair Information",
array("Science Fair Main" => "fair_main.php")
);
}
/* Load the fair info */
$q = mysql_query("SELECT * FROM fairs WHERE id={$u['fairs_id']}");
if(mysql_num_rows($q)) {
$f = mysql_fetch_assoc($q);
} else {
$f = array();
}
$s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'fair_info.php';
echo "<form name=\"fairinfo\" method=\"post\" action=\"$s\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
echo "<input type=\"hidden\" name=\"id\" value=\"{$f['id']}\" />\n";
echo "<table class=\"usereditor\">\n";
echo '<tr><td class="left">'.i18n('Fair Type').':</td><td class="right">';
echo "<select name=\"type\" id=\"type\" >";
foreach($fair_type as $k=>$o) {
$s = ($f['type'] == $k) ? 'selected="selected"' : '';
echo "<option value=\"$k\" $s >".i18n($o)."</option>";
}
echo "</select></td></tr>";
echo '<tr><td class="left">'.i18n('Fair Name').':</td><td class="right">';
echo "<input type=\"text\" name=\"name\" value=\"{$f['name']}\" size=\"40\" />";
echo '<tr><td class="left">'.i18n('Fair Abbreviation').':</td><td class="right">';
echo "<input type=\"text\" name=\"abbrv\" value=\"{$f['abbrv']}\" size=\"7\" />";
echo '<tr><td class="left">'.i18n('Fair Website').':</td><td class="right">';
if($f['website'] == '') $f['website'] = 'http://';
echo "<input type=\"text\" name=\"website\" value=\"{$f['website']}\" size=\"40\" />";
echo '</td></tr>';
echo '</table>';
/* All upstream stuff */
echo '<div id="upstream">';
echo "<table class=\"usereditor\">\n";
echo '<tr><td class="left">'.i18n('Upstream URL').':</td><td class="right">';
if($f['url'] == '') $f['url'] = 'http://';
echo "<input type=\"text\" name=\"url\" value=\"{$f['url']}\" size=\"40\" />";
echo '</td></tr>';
echo '<tr><td class="left">'.i18n('Upstream Username').':</td><td class="right">';
echo "<input type=\"text\" name=\"username\" value=\"{$f['username']}\" size=\"20\" />";
echo '</td></tr>';
echo '<tr><td class="left">'.i18n('Upstream Password').':</td><td class="right">';
echo "<input type=\"text\" name=\"password\" value=\"{$f['password']}\" size=\"15\" />";
echo '</td></tr>';
echo '<tr><td class="left">'.i18n('Enable stats upload').':</td><td class="right">';
yesno('enable_stats', $f['enable_stats']);
echo '</td></tr>';
echo '<tr><td class="left">'.i18n('Enable awards download').':</td><td class="right">';
yesno('enable_awards', $f['enable_awards']);
echo '</td></tr>';
echo '<tr><td class="left">'.i18n('Enable winners upload').':</td><td class="right">';
yesno('enable_winners', $f['enable_winners']);
echo '</td></tr>';
/* End upstream stuff */
echo "</table>";
echo i18n('* Use the \'Personal\' tab to specify contact information for someone at this fair.');
echo '</div>';
echo '<div id="feeder">';
echo i18n('* The feeder fair must login to this SFIAB to download award lists
and upload statistics and winners. Use the \'Personal\' tab to specify an
email and password for the feeder fair, use the email address of a contact at
the feeder fair. Then give the email/password to that person so they can configure
their own SFIAB to upload data to this SFIAB.'); echo '</div>';
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Fair Information")."\" />\n";
echo "</form>";
echo "<br />";
if($_SESSION['embed'] != true) send_footer();
?>
<script language="javascript" type="text/javascript">
<!--
var fairtype=document.getElementById("type");
fairtype.onchange=function() { /* Hook onto the onchange */
var type = this.options[this.selectedIndex].value;
var upstream_div = document.getElementById("upstream");
var feeder_div = document.getElementById("feeder");
if(type == "feeder") {
upstream_div.style.display="none";
feeder_div.style.display="block";
} else if(type == "sfiab") {
upstream_div.style.display="block";
feeder_div.style.display="none";
} else {
upstream_div.style.display="block";
feeder_div.style.display="none";
}
return true;
}
fairtype.onchange();
-->
</script>
<?
?>

87
fair_main.php Normal file
View File

@ -0,0 +1,87 @@
<?
/*
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>
Copyright (C) 2007 David Grant <dave@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_once("common.inc.php");
require_once("user.inc.php");
require_once("user_page.inc.php");
require_once("fair.inc.php");
user_auth_required('fair');
$u = user_load($_SESSION['users_id']);
/*
if($u['fair_active'] == 'no') {
message_push(notice(i18n("Your fair role is not active. If you would like to participate as a fair for the %1 %2 please click the '<b>Activate Role</b>' button in the Volunteer section below",array($config['FAIRYEAR'],$config['fairname']))));
header('Location: user_activate.php');
exit;
}
*/
send_header("Science Fair Main", array());
//only display the named greeting if we have their name
echo i18n("Hello <b>%1</b>",array($_SESSION['name']));
echo "<br />";
echo "<br />";
echo i18n("Please use the checklist below to complete your data. Click on an item in the table to edit that information. When you have entered all information, the <b>Status</b> field will change to <b>Complete</b>");
echo "<br />";
echo "<br />";
user_page_summary_begin();
user_page_summary_item("Contact Information",
"user_personal.php", "user_personal_info_status", array($u));
user_page_summary_item("Volunteer Positions",
"fair_info", "fair_status_info", array($u));
$overallstatus = user_page_summary_end(true);
/* Update fair_status */
fair_status_update($u);
echo "<br />";
echo "<br />";
/*
if($overallstatus!='complete')
{
echo error(i18n("You will not be marked as an active fair until your \"Overall Status\" is \"Complete\""));
}
else
{
echo happy(i18n("Thank you for completing the fair registration process. We look forward to seeing you at the fair"));
}
*/
echo "<br />";
echo i18n('Other Options and Things To Do').':<br />';
echo '<ul>';
echo '<li><a href="user_password.php">'.i18n('Change Password').'</a> - '.i18n('Change your password').'</li>';
echo '<li><a href="user_activate.php">'.i18n('Activate/Deactivate Roles').'</a> - '.
i18n('Activate/Deactiate/Remove/Delete roles or your entire account').
'</li>';
echo '<li>'.i18n('To logout, use the [Logout] link in the upper-right of the page').'</li>';
echo '</ul>';
send_footer();
?>

79
htabs.inc.php Normal file
View File

@ -0,0 +1,79 @@
<script type="text/javascript">
var htabs_current = new Array();
function htabs_open(tab)
{
var cur = htabs_current[tab];
$("#htabs_"+tab+"_"+cur).click();
}
</script>
<?
$htabs_current = "";
$htabs_tabs = array();
function htabs_begin($name, $tabs, $selected)
{
global $htabs_current, $htabs_tabs;
echo "<ul id=\"htabs_$name\" class=\"htabs\">";
foreach($tabs as $t=>$d) {
$sel = ($t == $selected) ? 'class=\"htabs_sel\"' : '';
echo "<li id=\"htabs_{$name}_$t\" $sel>".i18n($d['label']).'</li>';
$tabs[$t]['selected'] = false;
}
echo '</ul>';
/* Force the upcoming divs below this UL */
echo '<span style="clear: both; height: 0; visibility: hidden; display: block;"></span>';
$tabs[$selected]['selected'] = true;
$htabs_current = $name;
$htabs_tabs = $tabs;
}
function htabs_tab_begin($tab)
{
global $htabs_current, $htabs_tabs;
echo "<div id=\"htabs_tab_{$htabs_current}_$tab\" class=\"htabs\"
style=\"display:none;\">";
echo '<h1>'.i18n($htabs_tabs[$tab]['title']).'</h1>';
echo "<div id=\"htabs_tab_{$htabs_current}_{$tab}_body\">";
}
function htabs_tab_end()
{
echo '</div></div>';
}
function htabs_end()
{
global $htabs_current, $htabs_tabs;
$default = '';
$first = '';
echo '<script type="text/javascript">';
foreach($htabs_tabs as $t=>$d) {
echo "\$(\"#htabs_{$htabs_current}_$t\").click(function() {
\$(\"#htabs_{$htabs_current}_$t\").addClass(\"htabs_sel\");
\$(\"#htabs_tab_{$htabs_current}_$t\").css(\"display\", \"block\");\n";
foreach($htabs_tabs as $tt=>$dd) {
if($tt == $t) continue;
echo "\$(\"#htabs_{$htabs_current}_$tt\").removeClass(\"htabs_sel\");\n";
echo "\$(\"#htabs_tab_{$htabs_current}_$tt\").css(\"display\", \"none\");\n";
}
if(trim($d['callback']) != '') {
echo "{$d['callback']}();\n";
}
echo "htabs_current['$htabs_current'] = \"{$t}\";";
echo "});\n";
if($d['selected'] == true) $default = $t;
if($first == '') $first = $t;
}
if($default == '') $default = $first;
echo "htabs_current['$htabs_current'] = \"{$default}\";";
echo '</script>';
$htabs_current = "";
$htabs_tabs = array();
}
?>

View File

@ -31,11 +31,10 @@
while($r=mysql_fetch_object($q))
{
$trclass = ($trclass == 'odd') ? 'even' : 'odd';
if($r->date == '0000-00-00 00:00:00')
$d = i18n("not specified");
else
if($r->date != '0000-00-00 00:00:00') {
$d = format_datetime($r->udate);
echo "<tr class=\"$trclass\"><td>".i18n($r->description)."</td><td>$d</td></tr>";
echo "<tr class=\"$trclass\"><td>".i18n($r->description)."</td><td>$d</td></tr>";
}
}
echo "</table>";

View File

@ -141,7 +141,7 @@ if($_POST['action']=="save")
echo "<b>Done!</b><br />";
echo "Creating superuser account...";
$u = user_create('committee');
$u = user_create('committee',$_POST['email']);
if($_POST['firstname'] && $_POST['lastname']) {
$u['firstname']=mysql_escape_string(stripslashes($_POST['firstname']));
$u['lastname']=mysql_escape_string(stripslashes($_POST['lastname']));

View File

@ -1,392 +0,0 @@
<?
/* Just the fields in the judges table, we use this twice */
$judges_fields = array( 'firstname' => 'First Name',
'lastname' => 'Last Name',
'email' => 'Email Address',
'password' => 'Password',
'passwordexpiry' => 'Password Expiry',
'phonehome' => 'Phone (Home)',
'phonecell' => 'Phone (Cell)',
'phonework' => 'Phone (Work)',
'phoneworkext' => 'Phone Ext. (Work)',
'organization' => 'Organization',
// 'created' => 'Created',
// 'lastlogin' => 'Last Login',
'address' =>"Address 1",
'address2' =>"Address 2",
'city' => 'City',
'province' => $config['provincestate'],
'postalcode' => $config['postalzip'],
// 'deleted' => 'Deleted',
// 'deleteddatetime' => 'Deleted Date/Time',
'expertise_other' => 'Other Expertise/Notes',
'typepref' => 'Type Request',
'complete' => "Complete");
/* Setup the table editor with the fields we want to display
* when displaying a list of judges, and also the type of each
* field where required */
$judges_table_fields = array( 'id' => 'ID',
'firstname' => 'First Name',
'lastname' => 'Last Name',
'email' => 'Email Address',
'complete' => 'Complete',
// 'year' => 'Year',
);
class person {
var $id;
function person($person_id=NULL)
{
if($person_id == NULL) {
// print("Empty constructor called\n");
$this->id = FALSE;
} else {
// print("ID $person_id construction called\n");
$this->id = $person_id;
}
}
};
class judge extends person /*implements TableEditorInterface*/ {
/* Static members for the table editor */
function tableEditorSetup($editor)
{
global $judges_fields, $judges_table_fields;
global $config;
$cat = array();
$catf = array();
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
$cat[$r->id]=$r->category;
$catf["catpref_{$r->id}"] = "Category Pref|{$r->category}:";
}
$div = array();
$diff = array();
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
// $divshort[$r->id]=$r->division_shortform;
$div[$r->id]=$r->division;
/* yes, catf */
$catf["divpref_{$r->id}"] = "Expertise|{$r->division}:";
}
$q = mysql_query("SELECT * FROM award_awards WHERE year='{$config['FAIRYEAR']}'
AND (award_types_id=2 OR award_types_id=5) ORDER BY id");
while($r=mysql_fetch_object($q)) {
// $divshort[$r->id]=$r->division_shortform;
$sa[$r->id]=$r->name;
/* yes, catf */
$catf["sa_{$r->id}"] = "Special Award|{$r->name}:";
}
/* Most of these should be moved to the base class, as they
* will be the same for all person groups */
$e = array_merge($judges_fields,
array( 'language' => 'Language(s)',
));
$e = array_merge($e, $catf);
$editor->setTable('judges');
$editor->setRecordType('Judge');
$editor->setListFields($judges_table_fields);
$editor->setEditFields($e);
$editor->setFieldOptions('complete', array(
array('key' => 'yes', 'val' => 'Yes'),
array('key' => 'no', 'val' => 'No')));
$editor->setFieldOptions('year', array(
array('key' => 'NULL', 'val' => 'Inactive'),
array('key' => $config['FAIRYEAR'], 'val' => $config['FAIRYEAR'])));
// print_r($e);
print("<br>\n");
/* Build an array of langauges that we support */
$langs = array();
$q=mysql_query("SELECT * FROM languages WHERE active='Y'");
while($r=mysql_fetch_object($q)) {
$langs[$r->lang] = $r->langname;
}
$editor->setFieldOptions('language', $langs);
$editor->setFieldInputType('language', 'multicheck');
/* Pulled these out of register_judges.inc.php */
$preferencechoices=array(
array('key' => -2, 'val' => "Very Low"),
array('key' => -1, 'val' => "Low"),
array('key' => 0, 'val' => "Indifferent"),
array('key' => 1, 'val' => "Medium"),
array('key' => 2, 'val' => "High") );
foreach($cat as $cid=>$category) {
$editor->setFieldOptions("catpref_$cid", $preferencechoices);
$editor->setFieldInputType("catpref_$cid", 'select');
}
$expertisechoices=array(
array('key' => 1, 'val' => "(1) Low"),
array('key' => 2, 'val' => "(2) Med-Low"),
array('key' => 3, 'val' => "(3) Medium"),
array('key' => 4, 'val' => "(4) Med-High"),
array('key' => 5, 'val' => "(5) High") );
foreach($div as $did=>$division) {
$editor->setFieldOptions("divpref_$did", $expertisechoices);
$editor->setFieldInputType("divpref_$did", 'select');
}
if(count($sa)) {
foreach($sa as $said=>$special_award) {
$editor->setFieldOptions("sa_$said", array(
array('key' => 'yes', 'val' => 'Would like to judge'),
array('key' => '', 'val' => '')));
$editor->setFieldInputType("sa_$said", 'select');
}
}
$editor->setFieldOptions('typepref', array(
array('key' => 'speconly', 'val' => 'Special Award Judge Only'),
array('key' => '', 'val' => 'Regular Judge')));
$editor->SetFieldInputType('typepref', 'select');
$editor->createOption('judges_show_what');
}
/* STATIC */
function tableEditorGetList($editor)
{
//return $editor->defaultGetList();
global $config;
global $judges_table_fields;
$show_what = $editor->getOption('judges_show_what');
$sel = array_keys($judges_table_fields);
$from = array('judges');
$where = array();
switch($show_what) {
case "all":
// $editor->additionalListTableLeftJoin("judges_years", "judges_years.judges_id=judges.id");
// $editor->filterList("(judges_years.year={$config['FAIRYEAR']} OR judges_years.year IS NULL)");
break;
case "current_year_active":
$from[] = "LEFT JOIN `judges_years` ON judges_years.judges_id=judges.id";
$where[] = "judges_years.year={$config['FAIRYEAR']}";
break;
case "current_year_complete":
$from[] = "LEFT JOIN `judges_years` ON judges_years.judges_id=judges.id";
$where[] = "judges_years.judges_id=judges.id";
$where[] = "judges_years.year={$config['FAIRYEAR']}";
$where[] = "judges.complete='yes'";
break;
}
//only show non-deleted judges
$where[] = "judges.deleted='no'";
return array($sel, $from, $where);
}
/* Functions for $this */
function judge($judge_id=NULL)
{
global $judges_fields;
person::person($judge_id);
}
function tableEditorLoad()
{
global $config;
$id = $this->id;
// print("Loading Judge ID $id\n");
$q=mysql_query("SELECT judges.*
FROM judges
WHERE judges.id='$id'");
echo mysql_error();
/* We assume that the field names in the array we want to return
* are the same as those in the database, so we'll turn the entire
* query into a single associative array */
$j = mysql_fetch_assoc($q);
/* Now turn on the ones this judge has selected */
$q=mysql_query("SELECT languages_lang
FROM judges_languages
WHERE judges_id='$id'");
$j['language'] = array();
if(mysql_num_rows($q)) {
while($r=mysql_fetch_object($q)) {
$j['language'][$r->languages_lang] = 1;
}
}
$q=mysql_query("SELECT *
FROM judges_catpref
WHERE judges_id='$id'
AND year='{$config['FAIRYEAR']}'");
if(mysql_num_rows($q)) {
while($r=mysql_fetch_object($q)) {
$j["catpref_{$r->projectcategories_id}"] = $r->rank;
}
}
$q=mysql_query("SELECT *
FROM judges_expertise
WHERE judges_id='$id'
AND year='{$config['FAIRYEAR']}'");
if(mysql_num_rows($q)) {
while($r=mysql_fetch_object($q)) {
$j["divpref_{$r->projectdivisions_id}"] = $r->val;
}
}
$q=mysql_query("SELECT *
FROM judges_specialaward_sel
WHERE judges_id='$id'
AND year='{$config['FAIRYEAR']}'");
if(mysql_num_rows($q)) {
while($r=mysql_fetch_object($q)) {
$j["sa_{$r->award_awards_id}"] = 'yes';
}
}
// print_r($j);
return $j;
}
function tableEditorSave($data)
{
/* If $this->id == false, then we need to INSERT a new record.
* if it's a number, then we want an UPDATE statement */
global $judges_fields;
global $config;
$query = "";
/* Construct an insert query if we have to */
if($this->id == false) {
$query = "INSERT INTO judges (id) VALUES ('')";
mysql_query($query);
$this->id = mysql_insert_id();
}
/* Now just update the record */
$query="UPDATE `judges` SET ";
foreach($judges_fields AS $f=>$n) {
$n = $data[$f];
$query .= "`$f`=$n,";
}
//rip off the last comma
$query=substr($query,0,-1);
$query .= " WHERE id='{$this->id}'";
// echo $query;
mysql_query($query);
/* judges_languages */
/* First delete all the languages, then insert the ones the judge
* has selected */
$query = "DELETE FROM judges_languages WHERE judges_id='{$this->id}'";
mysql_query($query);
// print_r($data['language']);
$keys = array_keys($data['language']);
foreach($keys as $k) {
$query = "INSERT INTO
judges_languages (judges_id,languages_lang)
VALUES ('{$this->id}','$k')";
// print("$query");
mysql_query($query);
}
/* judges_catpref */
$query = "DELETE FROM judges_catpref WHERE judges_id='{$this->id}'";
// print($query);
mysql_query($query);
/* Find all the catpref_[number] keys */
$keys = array_keys($data);
foreach($keys as $k) {
if(ereg("^catpref_([0-9]*)$", $k, $regs)) {
if($data[$k] == "''") continue;
$query = "INSERT INTO judges_catpref
(judges_id,projectcategories_id,rank,year)
values ('{$this->id}','{$regs[1]}',{$data[$k]},'{$config['FAIRYEAR']}')";
// print($query."<br>\n");
mysql_query($query);
}
}
/* Find all the divpref_[number] keys */
$query = "DELETE FROM judges_expertise WHERE judges_id='{$this->id}'";
// print($query);
mysql_query($query);
$keys = array_keys($data);
foreach($keys as $k) {
if(ereg("^divpref_([0-9]*)$", $k, $regs)) {
if($data[$k] == "''") continue;
$query = "INSERT INTO judges_expertise
(judges_id,projectdivisions_id,val,year)
values ('{$this->id}','{$regs[1]}',{$data[$k]},'{$config['FAIRYEAR']}')";
// print($query."<br>\n");
mysql_query($query);
}
}
$query = "DELETE FROM judges_specialaward_sel WHERE judges_id='{$this->id}'";
mysql_query($query);
$keys = array_keys($data);
foreach($keys as $k) {
if(ereg("^sa_([0-9]*)$", $k, $regs)) {
if($data[$k] == "''") continue;
$query = "INSERT INTO judges_specialaward_sel
(judges_id,award_awards_id,year)
values ('{$this->id}','{$regs[1]}','{$config['FAIRYEAR']}')";
// print($query."<br>\n");
mysql_query($query);
}
}
}
function tableEditorDelete()
{
global $config;
$id = $this->id;
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='$id' AND year=".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_years WHERE judges_id='$id' AND year='".$config['FAIRYEAR']."'");
mysql_query("UPDATE judges SET deleted='yes', deleteddatetime=NOW() WHERE id='$id'");
echo happy(i18n("Successfully deleted the judge"));
}
};
?>

135
judge.inc.php Normal file
View File

@ -0,0 +1,135 @@
<?
/*
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>
Copyright (C) 2009 David Grant <dave@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.
*/
?>
<?
$preferencechoices=array(
-2=>"Very Low",
-1=>"Low",
0=>"Indifferent",
1=>"Medium",
2=>"High"
);
function judge_status_expertise(&$u)
{
global $config;
/* If the judging special awards are active, and the judge has
* selected "I am a special awards judge", then disable
* expertise checking */
if($config['judges_specialaward_only_enable'] == 'yes') {
if($u['special_award_only'] == 'yes')
return 'complete';
}
/* Check to see if they have ranked all project age categories, and all divisions */
$q=mysql_query("SELECT COUNT(id) AS num FROM projectcategories WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numcats=$r->num;
if($numcats != count($u['cat_prefs'])) return 'incomplete';
$q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numdivisions=$r->num;
if($numdivisions != count($u['div_prefs'])) return 'incomplete';
return 'complete';
}
function judge_status_other(&$u)
{
global $config;
/* They must select a language to judge in */
if(count($u['languages']) < 1) return 'incomplete';
return 'complete';
}
function judge_status_special_awards(&$u)
{
global $config;
/* Complete if:
* - judge has selected (none) "no special award preferences"
* - judge has selected between min and max preferences
*/
$qq = mysql_query("SELECT COUNT(id) AS num FROM judges_specialaward_sel
WHERE users_id='{$u['id']}'");
$rr = mysql_fetch_object($qq);
$awards_selected = $rr->num;
// echo "$awards_selected awards selected, ({$config['judges_specialaward_min']} - {$config['judges_specialaward_max']})";
if($u['special_award_only'] == 'yes') {
/* Judge for special award */
/* They may judge more than one award, so don't limit them
* to one */
if($awards_selected >= 1) return 'complete';
return 'incomplete';
}
if( ($awards_selected >= $config['judges_specialaward_min'])
&&($awards_selected <= $config['judges_specialaward_max']) ){
return 'complete';
}
return 'incomplete';
}
function judge_status_availability(&$u)
{
global $config;
if($config['judges_availability_enable'] == 'no') return 'complete';
$q = mysql_query("SELECT id FROM judges_availability
WHERE users_id=\"{$u['id']}\"");
if(mysql_num_rows($q) > 0) return 'complete';
return 'incomplete';
}
function judge_status_update(&$u)
{
global $config;
if( user_personal_info_status($u) == 'complete'
&& judge_status_expertise($u) == 'complete'
&& judge_status_other($u) == 'complete'
&& judge_status_availability($u) == 'complete'
&& judge_status_special_awards($u) == 'complete')
$u['judge_complete'] = 'yes';
else
$u['judge_complete'] = 'no';
user_save($u);
return ($u['judge_complete'] == 'yes') ? 'complete' : 'incomplete';
}
?>

140
judge_availability.php Normal file
View File

@ -0,0 +1,140 @@
<?
/*
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>
Copyright (C) 2009 David Grant <dave@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_once('common.inc.php');
require_once('user.inc.php');
require_once('judge.inc.php');
if($_SESSION['embed'] == true) {
user_auth_required('committee');
$u = user_load($_SESSION['embed_edit_id']);
} else {
user_auth_required('judge');
$u = user_load($_SESSION['users_id']);
}
$times = array();
/* Load the judging rounds */
$q = mysql_query("SELECT date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND year='{$config['FAIRYEAR']}' ORDER BY starttime,type");
$x = 0;
while($r = mysql_fetch_object($q)) {
$found = false;
foreach($times as $xx => $t) {
if($t['date'] == $r->date && $t['starttime'] == $r->starttime && $t['endtime'] == $r->endtime) {
$times[$xx]['name'] .= ", {$r->name}";
$found = true;
break;
}
}
if(!$found) {
$times[$x] = array( 'date' => $r->date,
'starttime' => $r->starttime,
'endtime' => $r->endtime,
'name' => $r->name);
$x++;
}
}
if($_POST['action']=='save') {
mysql_query("DELETE FROM judges_availability WHERE users_id='{$u['id']}'");
if(is_array($_POST['time']) ) {
foreach($_POST['time'] as $x) {
if(trim($times[$x]['starttime']) == '') continue;
mysql_query("INSERT INTO judges_availability (users_id, `date`,`start`,`end`)
VALUES ('{$u['id']}',
'{$times[$x]['date']}',
'{$times[$x]['starttime']}','{$times[$x]['endtime']}')");
}
}
message_push(notice(i18n("Time Availability preferences successfully saved")));
}
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Time Availability')."</h3>";
echo "<br />";
} else {
//send the header
send_header('Time Availability',
array('Judge Registration' => 'judge_main.php')
);
}
judge_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=judge_status_availability($u);
if($newstatus!='complete')
echo error(i18n("Time Availability Preferences Incomplete"));
else
echo happy(i18n("Time Availability Preferences Complete"));
}
$url = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'judge_availability.php';
echo "<form name=\"availabilityform\" method=\"post\" action=\"$url\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<br />";
/* Get all their available times */
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$u['id']}\" ORDER BY `start`");
$sel = array();
while($r=mysql_fetch_object($q)) {
foreach($times as $x=>$t) {
if($r->start == $t['starttime'] && $r->end == $t['endtime'] && $r->date == $t['date']) {
$sel[$x] = true;
}
}
}
echo "<table>\n";
foreach($times as $x=>$t) {
$ch = $sel[$x] == true ? 'checked="checked"' : '';
echo "<tr><td>";
echo "<input onclick=\"checkboxclicked(this)\" $ch type=\"checkbox\" name=\"time[]\" value=\"$x\" />";
$st = substr($t['starttime'], 0, 5);
$end = substr($t['endtime'], 0, 5);
echo "</td><td><b>{$times[$x]['date']} $st - $end</b></td></tr>";
echo "<tr><td></td><td><p>{$t['name']}</td>";
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Time Availability Preferences")."\" />\n";
echo "</form>";
if($_SESSION['embed'] != true) send_footer();
?>

View File

@ -22,88 +22,87 @@
*/
?>
<?
require("common.inc.php");
include "register_judges.inc.php";
require_once('common.inc.php');
require_once('user.inc.php');
require_once('judge.inc.php');
if($_SESSION['embed'] == true) {
$u = user_load($_SESSION['embed_edit_id']);
} else {
$u = user_load($_SESSION['users_id']);
}
//send the header
send_header("Judges Registration - Divisional Judging Preferences");
echo "<a onclick=\"return confirmChanges();\" href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
echo "<br />";
if($_POST['action']=="save")
{
//first delete all their old associations for this year..
mysql_query("DELETE FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
if(!is_array($_POST['division']))
$_POST['division']=array();
if(!is_array($_POST['subdivision']))
$_POST['subdivision']=array();
$u['div_prefs'] = array();
foreach($_POST['division'] AS $key=>$val)
{
mysql_query("INSERT INTO judges_expertise (judges_id, projectdivisions_id, val, year) VALUES ('".$_SESSION['judges_id']."','$key','$val','".$config['FAIRYEAR']."')");
}
$u['div_prefs'][$key] = $val;
$u['div_prefs_sub'] = array();
foreach($_POST['subdivision'] AS $key=>$val)
{
mysql_query("INSERT INTO judges_expertise (judges_id, projectsubdivisions_id, val, year) VALUES ('".$_SESSION['judges_id']."','$key','$val','".$config['FAIRYEAR']."')");
}
$u['div_prefs_sub'][$key] = $val;
if($_POST['expertise_other'])
{
mysql_query("UPDATE judges SET expertise_other='".mysql_escape_string(stripslashes($_POST['expertise_other']))."' WHERE id='".$_SESSION['judges_id']."'");
$u['expertise_other'] = stripslashes($_POST['expertise_other']);
else
$u['expertise_other'] = NULL;
}
else
{
mysql_query("UPDATE judges SET expertise_other=NULL WHERE id='".$_SESSION['judges_id']."'");
}
$u['cat_prefs'] = array();
if(is_array($_POST['catpref'])) {
foreach($_POST['catpref'] AS $k=>$v) {
if($v == '') continue;
mysql_query("DELETE FROM judges_catpref WHERE judges_id='".$_SESSION['judges_id']."'");
if(is_array($_POST['catpref']))
{
foreach($_POST['catpref'] AS $k=>$v)
{
if($v!="")
mysql_query("INSERT INTO judges_catpref (judges_id,projectcategories_id,rank,year) values ('".$_SESSION['judges_id']."','$k','$v','".$config['FAIRYEAR']."')");
$u['cat_prefs'][$k] = $v;
}
}
echo notice(i18n("Preferences successfully saved"));
user_save($u);
message_push(notice(i18n("Preferences successfully saved")));
$u = user_load($u['id']);
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
updateJudgeCompleteStatus($judgeinfo);
//output the current status
$newstatus=expertiseStatus();
if($newstatus!="complete")
{
echo error(i18n("Divisional Judging Information Incomplete"));
}
else
{
echo happy(i18n("Divisional Judging Information Complete"));
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
// echo "<h3>".i18n('Category and Division Preferences')."</h3>";
echo "<br />";
} else {
//send the header
send_header('Category and Division Preferences',
array('Judge Registration' => 'judge_main.php')
);
}
judge_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=judge_status_expertise($u);
if($newstatus!="complete")
echo error(i18n("Divisional Judging Information Incomplete"));
else
echo happy(i18n("Divisional Judging Information Complete"));
}
if($judgeinfo->typepref == "speconly") {
if($u['special_award_only'] == 'yes') {
echo i18n("You have specified that you are a judge for a specific special award. Divisional Judging preferences have been disabled because they do not apply to you.");
echo "<br />";
send_footer();
exit;
}
echo "<form name=\"expertiseform\" method=\"post\" action=\"register_judges_expertise.php\">\n";
if($_SESSION['embed'] == true) {
echo "<form name=\"expertiseform\" method=\"post\" action=\"{$_SESSION['embed_submit_url']}\">\n";
} else {
echo "<form name=\"expertiseform\" method=\"post\" action=\"judge_expertise.php\">\n";
}
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
$q=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
$catprefs=array();
while($r=mysql_fetch_object($q))
$catprefs[$r->projectcategories_id]=$r->rank;
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade");
echo "<h3>".i18n("Age Category Preferences")."</h3><br>";
echo "<table>";
@ -117,7 +116,10 @@ else
echo "<option value=\"\">".i18n("Choose")."</option>\n";
foreach($preferencechoices AS $val=>$str)
{
if($catprefs[$r->id]==$val && $catprefs[$r->id]!="") $sel="selected=\"selected\""; else $sel="";
if($u['cat_prefs'][$r->id]==$val && $u['cat_prefs'][$r->id]!="")
$sel="selected=\"selected\"";
else
$sel="";
echo "<option $sel value=\"$val\">".i18n($str)."</option>\n";
}
echo "</select>".REQUIREDFIELD;
@ -140,49 +142,42 @@ else
echo "<br />";
echo "<br />";
$q=mysql_query("SELECT * FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
while($r=mysql_fetch_object($q))
{
if($r->projectdivisions_id)
$expertise[$r->projectdivisions_id]=$r->val;
else if($r->projectsubdivisions_id)
$subexpertise[$r->projectsubdivisions_id]=$r->val;
}
// echo "<table>\n";
//query all of the categories
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division");
while($r=mysql_fetch_object($q))
{
echo "<tr><td></td><td colspan=\"2\">".i18n("Novice")."</td><td colspan=\"3\" align=\"right\">".i18n("Expert")."</td></tr>";
echo "<tr><th></th>";
for($x=1;$x<=5;$x++)
echo "<th>$x</th>";
echo "<th></th>";
echo "</tr>";
$first = true;
while($r=mysql_fetch_object($q)) {
echo "<tr><td><b>".i18n($r->division)."</b></td>";
$trclass = ($trclass == 'odd') ? 'even' : 'odd';
if($first == true) {
echo "<tr><td></td><td colspan=\"2\">".i18n("Novice")."</td><td colspan=\"3\" align=\"right\">".i18n("Expert")."</td></tr>";
echo "<tr><th></th>";
for($x=1;$x<=5;$x++)
echo "<th>$x</th>";
echo "<th></th>";
echo "</tr>";
$first = false;
}
for($x=1;$x<=5;$x++)
{
if($expertise[$r->id]==$x) $sel="checked=\"checked\""; else $sel="";
echo "<tr class=\"$trclass\"><td><b>".i18n($r->division)."</b></td>";
for($x=1;$x<=5;$x++) {
$sel = ($u['div_prefs'][$r->id]==$x) ? "checked=\"checked\"" : '';
echo "<td width=\"30\"><input onclick=\"fieldChanged()\" $sel type=\"radio\" name=\"division[$r->id]\" value=\"$x\" /></td>";
}
echo "<td width=\"100\"></td>";
echo "</tr>";
//only show the sub-divisions if the 'main' division is scored >=3
if($expertise[$r->id]>=3)
{
if($u['div_prefs'][$r->id]>=3) {
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE projectdivisions_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY subdivision");
while($subr=mysql_fetch_object($subq))
{
while($subr=mysql_fetch_object($subq)) {
echo "<tr>";
echo "<td>&nbsp;</td>";
if($subexpertise[$subr->id]) $ch="checked=\"checked\""; else $ch="";
$ch = ($u['div_prefs_sub'][$subr->id]) ? "checked=\"checked\"" : '';
echo "<td><input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"subdivision[$subr->id]\" value=\"1\" /></td>";
echo "<td colspan=\"5\">";
@ -191,24 +186,18 @@ else
echo "</tr>";
}
}
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>";
}
echo "</table>";
echo "<br />";
echo "<h3>".i18n("Other Areas of Expertise not listed above")."</h3>";
$q=mysql_query("SELECT expertise_other FROM judges WHERE id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
echo "<textarea name=\"expertise_other\" rows=\"4\" cols=\"60\">".htmlspecialchars($judgeinfo->expertise_other)."</textarea>";
echo "<textarea name=\"expertise_other\" rows=\"4\" cols=\"60\">".htmlspecialchars($u['expertise_other'])."</textarea>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Judging Preferences")."\" />\n";
echo "</form>";
echo "<br />";
echo "<a onclick=\"return confirmChanges();\" href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
send_footer();
if($_SESSION['embed'] != true) send_footer();
?>

102
judge_main.php Normal file
View File

@ -0,0 +1,102 @@
<?
/*
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_once('common.inc.php');
require_once('user.inc.php');
require_once('user_page.inc.php');
require_once('judge.inc.php');
user_auth_required('judge');
$u = user_load($_SESSION['users_id']);
if($u['judge_active'] == 'no') {
message_push(notice(i18n("Your judge role is not active. If you would like to participate as a judge for the %1 %2 please click the '<b>Activate Role</b>' button in the Judge section below",array($config['FAIRYEAR'],$config['fairname']))));
header('Location: user_activate.php');
exit;
}
send_header("Judge Registration", array());
//only display the named greeting if we have their name
if($u['firstname']) {
echo i18n("Hello <b>%1</b>",array($u['firstname']));
echo "<br />";
}
echo "<br />";
//first, we need to see if they havec the current FAIRYEAR activated, if not, we'll keep their acocunt 'dormant' and it wont
//be used for anything, but will still be available for them to login in the following years.
echo i18n("Please use the checklist below to complete your data. Click on an item in the table to edit that information. When you have entered all information, the <b>Status</b> field will change to <b>Complete</b>");
echo "<br />";
echo "<br />";
$overallstatus="complete";
user_page_summary_begin();
user_page_summary_item("Contact Information",
"user_personal.php", "user_personal_info_status", array($u));
user_page_summary_item("Other Information",
"judge_other.php", "judge_status_other", array($u));
user_page_summary_item("Areas of Expertise",
"judge_expertise.php", "judge_status_expertise", array($u));
if($config['judges_availability_enable'] == 'yes') {
user_page_summary_item("Time Availability",
"judge_availability.php", "judge_status_availability", array($u));
}
if($config['judges_specialaward_enable'] == 'yes' || $u['special_award_only'] == 'yes') {
user_page_summary_item("Special Award Preferences",
"judge_special_awards.php", "judge_status_special_awards", array($u));
}
// user_page_summary_item("Areas of Expertise",
// "register_judges_expertise.php", "expertiseStatus", array($u));
$overallstatus = user_page_summary_end(true);
judge_status_update($u);
echo '<br /><br />';
if($overallstatus!="complete")
echo error(i18n("You will not be marked as an active judge until your \"Overall Status\" is \"Complete\""));
else
echo happy(i18n("Thank you for completing the judge registration process. We look forward to seeing you at the fair"));
echo "<br />";
echo i18n('Other Options and Things To Do').':<br />';
echo '<ul>';
echo '<li><a href="user_password.php">'.i18n('Change Password').'</a> - '.i18n('Change your password').'</li>';
echo '<li><a href="user_activate.php">'.i18n('Activate/Deactivate Role').'</a> - '.
i18n('Activate/Deactiate/Remove/Delete roles or your entire account').
'</li>';
echo '<li>'.i18n('To logout, use the [Logout] link in the upper-right of the page').'</li>';
echo '</ul>';
send_footer();
?>

158
judge_other.php Normal file
View File

@ -0,0 +1,158 @@
<?
/*
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_once('common.inc.php');
require_once('user.inc.php');
require_once('judge.inc.php');
require_once("questions.inc.php");
if($_SESSION['embed'] == true) {
$u = user_load($_SESSION['embed_edit_id']);
} else {
$u = user_load($_SESSION['users_id']);
}
if($_POST['action']=="save")
{
if(!is_array($_POST['languages'])) $_POST['languages']=array();
$u['languages'] = array();
foreach($_POST['languages'] AS $val)
$u['languages'][] = $val;
$u['special_award_only'] = ($_POST['special_award_only'] == 'yes') ? 'yes' : 'no';
$u['willing_chair'] = ($_POST['willing_chair'] == 'yes') ? 'yes' : 'no';
$u['years_school'] = intval($_POST['years_school']);
$u['years_regional'] = intval($_POST['years_regional']);
$u['years_national'] = intval($_POST['years_national']);
$u['highest_psd'] = stripslashes($_POST['highest_psd']);
user_save($u);
message_push(notice(i18n("Preferences successfully saved")));
$u = user_load($u['id']);
}
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Other Information')."</h3>";
echo "<br />";
} else {
//send the header
send_header('Other Information',
array('Judge Registration' => 'judge_main.php')
);
}
judge_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=judge_status_other($u);
if($newstatus!="complete")
echo error(i18n("Other Information Incomplete"));
else
echo happy(i18n("Other Information Complete"));
}
if($_SESSION['embed'] == true) {
echo "<form name=\"otherform\" method=\"post\" action=\"{$_SESSION['embed_submit_url']}\">\n";
} else {
echo "<form name=\"otherform\" method=\"post\" action=\"judge_other.php\">\n";
}
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>\n";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("I can judge in the following languages")." ".REQUIREDFIELD."</td>";
echo " <td colspan=\"2\">";
$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
echo mysql_error();
while($r=mysql_fetch_object($q))
{
$ch = (in_array($r->lang,$u['languages'])) ? 'checked="checked"' : '';
echo "<input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"languages[]\" value=\"$r->lang\" /> $r->langname <br />";
}
echo " </td>\n";
echo "</tr>\n";
if($config['judges_specialaward_only_enable'] == 'yes') {
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("I am a judge for a specific special award")."<br /><font size=-1>(".i18n("Check this box if you are supposed to judge a specific special award, and please select that award on the Special Award Preferences page.").")</font></td>";
$ch = ($u['special_award_only'] == 'yes') ? 'checked="checked"' : '';
echo " <td colspan=\"2\"><input $ch type=\"checkbox\" name=\"special_award_only\" value=\"yes\" />";
echo " </td>";
echo "</tr>\n";
}
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Years of judging experience at a School level:")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"years_school\" size=\"5\" value=\"{$u['years_school']}\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Years of judging experience at a Regional level:")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"years_regional\" size=\"5\" value=\"{$u['years_regional']}\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Years of judging experience at a National level:")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"years_national\" size=\"5\" value=\"{$u['years_national']}\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("I am willing to be the lead for my judging team")."</td>";
$ch = ($u['willing_chair'] == 'yes') ? 'checked="checked"' : '';
echo " <td colspan=\"2\"><input $ch type=\"checkbox\" name=\"willing_chair\" value=\"yes\" />";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Highest post-secondary degree")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"highest_psd\" size=\"35\" value=\"{$u['highest_psd']}\" /></td>\n";
echo "</tr>\n";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
questions_print_answer_editor('judgereg', $u, 'questions');
echo "</table>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Information")."\" />\n";
echo "</form>";
if($_SESSION['embed'] != true) send_footer();
?>

View File

@ -22,47 +22,60 @@
*/
?>
<?
require("common.inc.php");
include "register_judges.inc.php";
//send the header
send_header("Judges Registration - Special Awards");
require_once('common.inc.php');
require_once('user.inc.php');
require_once('judge.inc.php');
echo "<a onclick=\"return confirmChanges();\" href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
echo "<br />";
if($_SESSION['embed'] == true) {
$u = user_load($_SESSION['embed_edit_id']);
} else {
$u = user_load($_SESSION['users_id']);
}
if($_POST['action']=="save")
{
if($_POST['action']=="save") {
//first delete all their old associations for this year..
mysql_query("DELETE FROM judges_specialaward_sel WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
if(array_key_exists('spaward', $_POST)) {
foreach($_POST['spaward'] AS $aid)
{
mysql_query("INSERT INTO judges_specialaward_sel (judges_id, award_awards_id, year)
VALUES ('".$_SESSION['judges_id']."','$aid','{$config['FAIRYEAR']}')");
foreach($_POST['spaward'] AS $aid) {
mysql_query("INSERT INTO judges_specialaward_sel (users_id, award_awards_id)
VALUES ('{$u['id']}','$aid')");
}
}
echo notice(i18n("Special Award preferences successfully saved"));
message_push(notice(i18n("Special Award preferences successfully saved")));
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
updateJudgeCompleteStatus($judgeinfo);
//output the current status
$newstatus=specialawardStatus();
if($newstatus!="complete")
{
echo error(i18n("Special Award Preferences Incomplete"));
}
else
{
echo happy(i18n("Special Award Preferences Complete"));
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Special Awards')."</h3>";
echo "<br />";
} else {
//send the header
send_header('Special Awards',
array('Judge Registration' => 'judge_main.php')
);
}
judge_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=judge_status_special_awards($u);
if($newstatus!='complete')
echo error(i18n("Special Award Preferences Incomplete"));
else
echo happy(i18n("Special Award Preferences Complete"));
}
echo "<form name=\"specialawardform\" method=\"post\" action=\"register_judges_specialawards.php\">\n";
if($_SESSION['embed'] == true) {
echo "<form name=\"specialawardform\" method=\"post\" action=\"{$_SESSION['embed_submit_url']}\">\n";
} else {
echo "<form name=\"specialawardform\" method=\"post\" action=\"judge_special_awards.php\">\n";
}
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
if($judgeinfo->typepref == 'speconly') {
if($u['special_award_only'] == 'yes') {
echo i18n("Please select the special award you are supposed to judge.");
} else {
echo i18n("Please select any special awards you would prefer to judge.");
@ -72,12 +85,10 @@ else
echo "<br />";
echo "<br />";
$q=mysql_query("SELECT * FROM judges_specialaward_sel WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
$q=mysql_query("SELECT * FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
$spawards = array();
while($r=mysql_fetch_object($q))
{
$spawards[] = $r->award_awards_id;
}
while($r=mysql_fetch_object($q)) $spawards[] = $r->award_awards_id;
echo "<table>\n";
@ -85,14 +96,14 @@ else
$q=mysql_query("SELECT award_awards.id,
award_awards.name,
award_awards.criteria,
award_sponsors.organization
sponsors.organization
FROM
award_awards,
award_types,
award_sponsors
sponsors
WHERE
award_types.id=award_awards.award_types_id
AND award_sponsors.id=award_awards.award_sponsors_id
AND sponsors.id=award_awards.sponsors_id
AND (award_types.type='Special' OR award_types.type='Other')
AND award_awards.year='{$config['FAIRYEAR']}'
AND award_types.year='{$config['FAIRYEAR']}'
@ -103,9 +114,9 @@ else
{
echo "<tr><td rowspan=\"2\">";
$ch = (in_array($r->id,$spawards)) ? "checked=\"checked\"" : "";
echo "<input $ch type=\"checkbox\" name=\"spaward[]\" value=\"{$r->id}\" />";
echo "<input onclick=\"checkboxclicked(this)\" $ch type=\"checkbox\" name=\"spaward[]\" value=\"{$r->id}\" />";
echo "</td><td>";
echo "<b>{$r->name}</b> ($r->organization)";
echo "<b>{$r->name}</b> ({$r->organization})";
echo "</td></tr>";
echo "<tr><td>";
echo "{$r->criteria}";
@ -117,9 +128,8 @@ else
echo "<input type=\"submit\" value=\"".i18n("Save Special Award Preferences")."\" />\n";
echo "</form>";
echo "<br />";
echo "<a onclick=\"return confirmChanges();\" href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
send_footer();
if($_SESSION['embed'] != true) send_footer();
?>

74
login.php Normal file
View File

@ -0,0 +1,74 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 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_once("common.inc.php");
send_header("Login/Register");
echo i18n("Please choose one of the following:");
echo "<br />\n";
echo "<br />\n";
echo "<h4>Participant</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"register_participants.php\">I am a participant</a></li>\n";
echo "</ul>\n";
echo "<h4>Judge</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=judge\">I am a judge and I already have an account</a></li>\n";
echo "<li><a href=\"user_new.php?type=judge\">I am a new judge and would like to register to judge</a></li>\n";
echo "</ul>\n";
echo "<h4>Sponsor</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=sponsor\">I am an existing sponsor</a></li>\n";
echo "<li><a href=\"user_new.php?type=sponsor\">I would like to become a sponsor</a></li>\n";
echo "</ul>\n";
echo "<h4>Teacher/School</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"schoolaccess.php\">I am a teacher or science fair coordinator at a school</a></li>\n";
echo "</ul>\n";
if($config['volunteer_enable'] == 'yes') {
echo "<h4>Volunteer</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=sponsor\">I am a volunteer and I already have an account</a></li>\n";
echo "<li><a href=\"user_new.php?type=sponsor\">I am a new volunteer and would like to help out</a></li>\n";
echo "</ul>\n";
}
echo "<h4>Committee</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=committee\">I am a committee member</a></li>\n";
echo "</ul>\n";
if($config['fairs_enable'] == 'yes' && $config['fairs_allow_login'] == 'yes') {
echo "<h4>Other Fair</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=fair\">".i18n("{$config['fairs_name']} Fair Login").'</a></li>';
echo "</ul>\n";
}
send_footer();
?>

View File

@ -24,13 +24,12 @@
<?
function questions_load_answers($section, $id, $year)
function questions_load_answers($section, $users_id)
{
$q = mysql_query('SELECT question_answers.*, questions.* '.
'FROM question_answers '.
'LEFT JOIN questions ON questions.id=question_answers.questions_id '.
"WHERE question_answers.year='$year' ".
" AND registrations_id='$id' ".
"WHERE users_id='$users_id' ".
" AND questions.section='$section' ".
'ORDER BY questions.ord ASC');
@ -62,13 +61,13 @@ function questions_load_questions($section, $year)
return $qs;
}
function questions_save_answers($section, $id, $year, $answers)
function questions_save_answers($section, $id, $answers)
{
$qs = questions_load_questions($section, $year);
$qs = questions_load_questions($section);
$keys = array_keys($answers);
$query = "DELETE FROM question_answers ".
"WHERE registrations_id='$id' ".
" AND year='$year' AND (";
"WHERE users_id='$id' ".
" AND (";
$n = 0;
foreach($keys as $qid) {
if($n == 1) $query .= " OR ";
@ -82,18 +81,17 @@ function questions_save_answers($section, $id, $year, $answers)
foreach($keys as $qid) {
/* Poll key */
mysql_query("INSERT INTO question_answers ".
"(year,registrations_id,questions_id,answer) VALUES(".
"'$year','$id','$qid',".
"(users_id,questions_id,answer) VALUES(".
"'$id','$qid',".
"'".mysql_escape_string($answers[$qid])."'".
")" );
}
}
function questions_find_question_id($section, $year, $dbheading)
function questions_find_question_id($section, $dbheading)
{
$q = mysql_query("SELECT id FROM questions WHERE ".
" section='$section' ".
" AND year='$year' ".
" AND db_heading='$dbheading' ");
if(mysql_num_rows($q) == 1) {
$r = mysql_fetch_object($q);
@ -103,10 +101,10 @@ function questions_find_question_id($section, $year, $dbheading)
}
function questions_print_answer_editor($section, $id, $year, $array_name)
function questions_print_answer_editor($section, &$u, $array_name)
{
$ans = questions_load_answers($section, $id, $year);
$qs = questions_load_questions($section, $year);
$ans = questions_load_answers($section, $u['id']);
$qs = questions_load_questions($section, $u['year']);
$keys = array_keys($qs);
foreach($keys as $qid) {
@ -133,10 +131,10 @@ function questions_print_answer_editor($section, $id, $year, $array_name)
}
}
function questions_print_answers($section, $id, $year)
function questions_print_answers($section, $id)
{
$ans = questions_load_answers($section, $id, $year);
$qs = questions_load_questions($section, $year);
$ans = questions_load_answers($section, $id);
$qs = questions_load_questions($section);
$keys = array_keys($qs);
foreach($keys as $qid) {
echo "<tr>\n";
@ -158,7 +156,7 @@ function questions_parse_from_http_headers($array_name)
return $ans;
}
function questions_update_question($qs, $year)
function questions_update_question($qs)
{
mysql_query("UPDATE questions SET
`question`='".mysql_escape_string($qs['question'])."',
@ -166,7 +164,7 @@ function questions_update_question($qs, $year)
`db_heading`='".mysql_escape_string($qs['db_heading'])."',
`required`='".mysql_escape_string($qs['required'])."',
`ord`=".intval($qs['ord'])."
WHERE id='{$qs['id']}' AND year='$year'");
WHERE id='{$qs['id']}' ");
echo mysql_error();
}

View File

@ -1,203 +0,0 @@
<?
/*
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.
*/
?>
<?
$preferencechoices=array(
-2=>"Very Low",
-1=>"Low",
0=>"Indifferent",
1=>"Medium",
2=>"High"
);
function personalStatus()
{
global $config;
$required_fields=array("firstname","lastname","address","city","postalcode","phonehome","email");
$q=mysql_query("SELECT * FROM judges WHERE id='".$_SESSION['judges_id']."'");
while($r=mysql_fetch_object($q))
{
foreach ($required_fields AS $req)
{
if(!$r->$req)
{
return "incomplete";
}
}
}
//and they also have to select at least one language to judge in
$q=mysql_query("SELECT COUNT(judges_id) AS num FROM judges_languages WHERE judges_id='".$_SESSION['judges_id']."'");
$r=mysql_fetch_object($q);
if($r->num==0)
return "incomplete";
//if it made it through without returning incomplete, then we must be complete
return "complete";
}
function expertiseStatus()
{
global $config;
/* If the judging special awards are active, and the judge has
* selected "I am a special awards judge", then disable this */
if($config['judges_specialaward_only_enable'] == 'yes') {
$q = mysql_query("SELECT typepref FROM judges WHERE
id='{$_SESSION['judges_id']}'");
if(mysql_num_rows($q) != 1) return "incomplete";
$r = mysql_fetch_object($q);
if($r->typepref == 'speconly')
return 'complete';
}
//and they need to rank all of the age categories
$q=mysql_query("SELECT COUNT(id) AS num FROM projectcategories WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numcats=$r->num;
$q=mysql_query("SELECT COUNT(id) AS num FROM judges_catpref WHERE year='".$config['FAIRYEAR']."' AND judges_id='".$_SESSION['judges_id']."'");
$r=mysql_fetch_object($q);
$numprefs=$r->num;
if($numcats!=$numprefs)
return "incomplete";
//easiest check here is to check the number of divisions, then check the number of entries
//that they have in the judges_expertise table. If they are the same, then we're good to go
//if they are different, they forgot to fill one out (because it only gets inserted if a value)
//is choosen, and they are always ALL removed before each update
$q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numdivisions=$r->num;
$q=mysql_query("SELECT COUNT(id) AS num FROM judges_expertise WHERE projectdivisions_id IS NOT NULL AND judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numjudgesexpertise=$r->num;
if($numdivisions == $numjudgesexpertise)
return "complete";
else
return "incomplete";
}
function specialawardStatus()
{
global $config;
/* Complete if:
* - judge has selected (none) "no special award preferences"
* - judge has selected (pref) "i would like to specify awards", and has
* selected between min and max preferences
* - judge has selected "i am a special awards judge, and has
* selected an award */
$q = mysql_query("SELECT typepref FROM judges WHERE
id='{$_SESSION['judges_id']}'");
if(mysql_num_rows($q) != 1) return "incomplete";
$r = mysql_fetch_object($q);
$qq = mysql_query("SELECT COUNT(id) AS num FROM judges_specialaward_sel
WHERE judges_id='{$_SESSION['judges_id']}'
AND year={$config['FAIRYEAR']}");
$rr = mysql_fetch_object($qq);
$awards_selected = $rr->num;
switch($r->typepref) {
case "speconly": /* Judge for special award */
/* They may judge more than one award, so don't limit them
* to one */
if($awards_selected >= 1) return "complete";
break;
case "pref": /* Special award preferences specified */
default:
if( ($awards_selected >= $config['judges_specialaward_min'])
&&($awards_selected <= $config['judges_specialaward_max']) ){
return "complete";
}
break;
}
return "incomplete";
}
//authenticate based on email address and registration number from the SESSION
if(! ($_SESSION['email'] && $_SESSION['judges_id']) )
{
header("Location: register_judges.php");
exit;
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."' AND deleted='no'");
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_judges.php?action=logout");
exit;
}
$judgeinfo=mysql_fetch_object($q);
//only check for password expiry if we are NOT on the change password page, otherwise we create endless redirect loops
if(!strstr($_SERVER['PHP_SELF'],"register_judges_password.php"))
{
//check for expired password
$q=mysql_query("SELECT id FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."' AND deleted='no' AND passwordexpiry<=NOW()");
if(mysql_num_rows($q))
{
$_SESSION['judges_password_expired']=true;
header("Location: register_judges_password.php");
}
}
//ji = judgeinfo record from database (select * from judges where id='whatever')
function updateJudgeCompleteStatus($ji)
{
if( personalStatus()=="complete" &&
expertiseStatus()=="complete"
)
$complete="yes";
else
$complete="no";
if($complete!=$ji->complete)
{
mysql_query("UPDATE judges SET complete='$complete' WHERE id='".$ji->id."'");
}
}
//finally, if everything else is good, update their 'overall status' if it needs to be
updateJudgeCompleteStatus($judgeinfo);
?>

View File

@ -1,287 +0,0 @@
<?
/*
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");
if($_POST['action']=="new")
{
//first make sure their password is good
if(!$_POST['pass1'])
{
send_header("Judges Registration");
echo error(i18n("Password is required"));
$_POST['action']="login";
}
else if($_POST['pass1'] != $_POST['pass2'])
{
send_header("Judges Registration");
echo error(i18n("Passwords do not match"));
$_POST['action']="login";
}
else
{
if($config['judges_password_expiry_days']>0)
$ex="DATE_ADD(CURDATE(),INTERVAL ".$config['judges_password_expiry_days']." DAY)";
else
$ex="NULL";
mysql_query("INSERT INTO judges (email,password,created,lastlogin,passwordexpiry) VALUES ('".$_SESSION['email']."','".$_POST['pass1']."',NOW(),NOW(),$ex)");
$id=mysql_insert_id();
$_SESSION['judges_id']=$id;
//obviously if they are signing up right now they would like to particapte in the current years fair, so setup the year for them
mysql_query("INSERT INTO judges_years (judges_id,year) VALUES ('$id','".$config['FAIRYEAR']."')");
//now redirect to jduges main
header("Location: register_judges_main.php");
exit;
}
}
else if($_POST['action']=="continue")
{
if($_POST['pass'])
{
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND password='".$_POST['pass']."' AND deleted='no'");
if(mysql_num_rows($q)==1)
{
$r=mysql_fetch_object($q);
$_SESSION['judges_id']=$r->id;
$_SESSION['judges_lastlogin']=$r->lastlogin;
mysql_query("UPDATE judges SET lastlogin=NOW() WHERE id='$r->id'");
header("Location: register_judges_main.php");
exit;
}
else
{
send_header("Judges Registration");
echo error(i18n("Invalid Password"));
$_POST['action']="login";
}
}
else
{
send_header("Judges Registration");
echo error(i18n("Password missing"));
$_POST['action']="login";
}
}
else if($_GET['action']=="resend" && $_SESSION['email'])
{
//first see if the email matches directly from the registrations table
$q=mysql_query("SELECT * FROM judges
WHERE
email='".$_SESSION['email']."'
");
$r=mysql_fetch_object($q);
if($r)
{
email_send("register_judges_resend_password",$_SESSION['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("PASSWORD"=>$r->password,"EMAIL"=>$r->email));
send_header("Judges Registration");
echo notice(i18n("Your judge registration password has been sent to your email address <b>%1</b>",array($_SESSION['email']),array("email address") ));
}
else
{
send_header("Judges Registration");
echo error(i18n("Could not find a judge record with your email address"));
}
}
else if($_GET['action']=="logout")
{
unset($_SESSION['email']);
unset($_SESSION['judges_id']);
unset($_SESSION['judges_lastlogin']);
unset($_SESSION['judges_password_expired']);
send_header("Judges Registration");
echo notice(i18n("You have been successfully logged out"));
}
if($_SESSION['email'] && $_SESSION['judges_id'])
{
header("Location: register_judges_main.php");
exit;
}
send_header("Judges Registration");
$_POST['email']=trim($_POST['email']);
if($_POST['action']=="login" && ( $_POST['email'] || $_SESSION['email']) )
{
if($_POST['email'])
$_SESSION['email']=$_POST['email'];
echo "<form method=\"post\" action=\"register_judges.php\">";
$allownew=true;
//first, check if they have any registrations waiting to be opened
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND deleted='no'");
if(mysql_num_rows($q)>0)
{
echo i18n("Please enter your password to login");
echo "<br />";
echo "<br />";
echo i18n("Password:")." ";
echo "<input type=\"password\" size=\"10\" name=\"pass\">";
echo "<input type=\"hidden\" name=\"action\" value=\"continue\">";
echo "<input type=\"submit\" value=\"".i18n("Login")."\">";
echo "<br />";
echo "<br />";
echo i18n("If you have lost or forgotten your <b>password</b>, please <a href=\"register_judges.php?action=resend\">click here to resend</a> it to your email address");
}
else
{
$allownew=true;
if($config['judge_registration_type']=="invite")
{
$allownew=false;
echo i18n("Judge registration is by invite only. You can not create a new account. If you have been invited already, you need to use the same email address that you were invited with. If you need an invitation, please contact the science fair committee.");
echo "<br />";
echo "<br />";
echo "<a href=\"register_judges.php\">Back to Judges Registration</a>";
}
else if($config['judge_registration_type']=="singlepassword")
{
$showsinglepasswordform=true;
if($_POST['singlepassword'])
{
if($_POST['singlepassword']==$config['judge_registration_singlepassword'])
{
$allownew=true;
$showsinglepasswordform=false;
}
else
{
echo error(i18n("Invalid registration password, please try again"));
$allownew=false;
}
}
if($showsinglepasswordform)
{
echo i18n("Judge registration is protected by a password. You must know the <b>judge registration password</b> in order to create an account.");
echo "<br />";
echo "<br />";
echo "<input type=\"hidden\" name=\"action\" value=\"login\">";
echo i18n("Email Address:")." ".$_SESSION['email']."<br />";
echo i18n("Judge Registration Password:");
echo "<input type=\"text\" size=\"10\" name=\"singlepassword\">";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"Submit\">";
echo "</form>";
$allownew=false;
}
}
else if($config['judge_registration_type']=="open")
{
//thats fine, continue on and create them the account.
}
else
{
echo error(i18n("There is an error with the SFIAB configuration. judge_registration_type is not defined. Contact the fair organizers to get this fixed."));
$allownew=false;
}
if($allownew)
{
echo i18n("Please choose a password in order to create your judges account");
echo "<br />";
echo "<br />";
echo i18n("This session may not be encrypted (look for https:// in the URL, or the lock icon in the lower right corner of your browser window). For your safety, we recommend that you DO NOT use an important password here. For example, DO NOT use your personal banking password here.");
echo "<br />";
echo "<br />";
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
echo "<table>";
echo "<tr><td>";
echo i18n("Choose Password:");
echo "</td><td>";
echo "<input type=\"password\" size=\"10\" name=\"pass1\">";
echo "</td></tr>";
echo "<tr><td>";
echo i18n("Confirm Password:");
echo "</td><td>";
echo "<input type=\"password\" size=\"10\" name=\"pass2\">";
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Create Account")."\">";
}
}
echo "</form>";
}
else
{
//Lets check the date - if we are AFTER 'judgeregopen' and BEFORE 'judgeregclose' then we can login
//otherwise, registration is closed - no logins!
$now = date('Y-m-d H:i:s');
if($now < $config['dates']['judgeregopen'])
{
echo i18n("Judges registration for the %1 %2 has not yet opened",array($config['FAIRYEAR'],$config['fairname']),array("Fair year","Fair name"));
}
else if($now > $config['dates']['judgeregclose'])
{
echo i18n("Judges registration for the %1 %2 is now closed",array($config['FAIRYEAR'],$config['fairname']),array("Fair year","Fair name"));
}
else
{
if($config['judge_registration_type']=="invite")
{
output_page_text("register_judges_invite");
echo "<br />";
echo "<br />";
echo i18n("Please enter your email address to :");
echo "<ul>";
}
else
{
echo i18n("Please enter your email address to :");
echo "<ul>";
echo "<li>".i18n("Begin a new registration")."</li>";
}
echo "<li>".i18n("Login to your account")."</li>";
echo "</ul>";
?>
<form method="post" action="register_judges.php">
<input type="hidden" name="action" value="login" />
<?=i18n("Email")?>: <input type="text" name="email" size="30" />
<input type="submit" value="<?=i18n("Begin");?>" />
</form>
<?
}
}
send_footer();
?>

View File

@ -1,189 +0,0 @@
<?
/*
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");
include "register_judges.inc.php";
send_header("Judges Registration");
if($_GET['action']=="activate")
{
mysql_query("INSERT INTO judges_years (judges_id,year) VALUES ('".$_SESSION['judges_id']."','".$config['FAIRYEAR']."')");
echo happy(i18n("Judge profile for %1 successfully activated",array($config['FAIRYEAR'])));
}
if($_GET['action']=="deactivate")
{
mysql_query("DELETE FROM judges_years WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Judge profile for %1 successfully deactivated",array($config['FAIRYEAR'])));
}
if($_GET['action']=="delete")
{
//okay here we go, lets get rid of them completely, since this is what theyve asked for
echo happy(i18n("Judge account successfully deleted. Goodbye!",array($config['FAIRYEAR'])));
mysql_query("UPDATE judges SET deleted='yes', deleteddatetime=NOW() WHERE id='".$_SESSION['judges_id']."'");
unset($_SESSION['judges_id']);
unset($_SESSION['email']);
send_footer();
exit;
}
//only display the named greeting if we have their name
if($judgeinfo->firstname)
{
echo i18n("Hello <b>%1</b>",array($judgeinfo->firstname));
echo "<br />";
}
echo "<br />";
//first, we need to see if they havec the current FAIRYEAR activated, if not, we'll keep their acocunt 'dormant' and it wont
//be used for anything, but will still be available for them to login in the following years.
$q=mysql_query("SELECT * FROM judges_years WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q))
{
echo i18n("If you would like to participate as a judge for the %1 %2 please click the '<b>Activate %3 Judge Profile</b>' button below to activate your judges account for the fair",array($config['FAIRYEAR'],$config['fairname'],$config['FAIRYEAR']));
echo "<br />";
echo "<br />";
echo i18n("If you can not judge this year, but would like to remain on our mailing list for future years, no action is necessary");
echo "<br />";
echo "<br />";
echo i18n("If you would like to be completely removed from our judges mailing list, please click the '<b>Delete Judge Account</b>' button below");
echo "<br />";
echo "<br />";
echo "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<input type=\"hidden\" name=\"action\" value=\"activate\">\n";
echo "<input style=\"width: 300px;\" type=\"submit\" value=\"".i18n("Activate %1 Judge Profile",array($config['FAIRYEAR']))."\">";
echo "</form>";
}
else
{
$overallstatus="complete";
echo i18n("Please use the checklist below to complete your registration. Click on an item in the table to edit that information. When you have entered all information, the <b>Status</b> field will change to <b>Complete</b>");
echo "<br />";
echo "<br />";
echo "<table class=\"summarytable\">";
echo "<tr><th>".i18n("Registration Item")."</th><th>".i18n("Status")."</th></tr>";
//judges personal information
echo "<tr><td>";
echo "<a href=\"register_judges_personal.php\">";
echo i18n("Personal Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statuspersonal=personalStatus();
echo outputStatus($statuspersonal);
if($statuspersonal!="complete") $overallstatus="incomplete";
echo "</td></tr>";
/*
//organization information
echo "<tr><td>";
echo "<a href=\"register_judges_organization.php\">";
echo i18n("Organization Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusorganization=organizationStatus();
echo outputStatus($statusorganization);
echo "</td></tr>";
*/
//area of expertise
echo "<tr><td>";
echo "<a href=\"register_judges_expertise.php\">";
echo i18n("Areas of Expertise");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusexpertise=expertiseStatus();
echo outputStatus($statusexpertise);
if($statusexpertise!="complete") $overallstatus="incomplete";
echo "</td></tr>";
// special awards
if($config['judges_specialaward_enable'] == 'yes' || $judgeinfo->typepref == 'speconly') {
echo "<tr><td>";
echo "<a href=\"register_judges_specialawards.php\">";
echo i18n("Special Award Preferences");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusspecialawards=specialawardStatus();
echo outputStatus($statusspecialawards);
if($statusspecialawards!="complete") $overallstatus="incomplete";
echo "</td></tr>";
}
echo "<tr><td colspan=\"2\"><hr></td></tr>";
echo "<tr><td>".i18n("Overall Status")."</td><td>";
echo outputStatus($overallstatus);
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo "<br />";
if($overallstatus!="complete")
{
echo error(i18n("You will not be marked as an active judge until your \"Overall Status\" is \"Complete\""));
}
else
{
echo happy(i18n("Thank you for completing the judge registration process. We look forward to seeing you at the fair"));
}
echo "<br />";
echo i18n("If you are unable to participate as a judge in the %1 %2 please click the deactivate button below to deactivate your judges account for the fair",array($config['FAIRYEAR'],$config['fairname']));
echo "<br />";
echo "<br />";
echo "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<input type=\"hidden\" name=\"action\" value=\"deactivate\">\n";
echo "<input style=\"width: 300px;\" onclick=\"return confirmClick('".i18n("Are you sure you want to deactivate your judges profile for %1?",array($config['FAIRYEAR']))."')\" type=\"submit\" value=\"".i18n("Deactivate %1 Judge Profile",array($config['FAIRYEAR']))."\">";
echo "</form>";
}
echo "<br />";
echo "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<input type=\"hidden\" name=\"action\" value=\"delete\">\n";
echo "<input style=\"width: 300px;\" onclick=\"return confirmClick('".i18n("Are you sure you want to completely delete your judges account? \\n Doing so will remove you from our mailing list for future years and you will never hear from us again")."')\" type=\"submit\" value=\"".i18n("Delete Judge Account")."\">";
echo "</form>";
echo "<br />";
echo "<a href=\"register_judges_password.php\">".i18n("Change Password")."</a>";
echo "<br />";
echo "<a href=\"register_judges.php?action=logout\">".i18n("Logout")."</a>";
send_footer();
?>

Some files were not shown because too many files have changed in this diff Show More