forked from science-ation/science-ation
Add the 'one click' CWSF registration code!
It current generates the XML but does not implement the sending to YSF (thats still to come!)
This commit is contained in:
parent
9fbb3feb3b
commit
2019e24b89
@ -66,6 +66,7 @@
|
||||
"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']))."', ".
|
||||
"cwsfaward='".mysql_escape_string(stripslashes($_POST['cwsfaward']))."', ".
|
||||
"criteria='".mysql_escape_string(stripslashes($_POST['criteria']))."' ".
|
||||
"WHERE id='$id'";
|
||||
|
||||
@ -140,6 +141,7 @@
|
||||
award_awards.order,
|
||||
award_awards.presenter,
|
||||
award_awards.excludefromac,
|
||||
award_awards.cwsfaward,
|
||||
award_types.id AS award_types_id,
|
||||
award_types.type,
|
||||
award_sponsors.id AS award_sponsors_id,
|
||||
@ -169,6 +171,7 @@ echo mysql_error();
|
||||
$award_sponsor=$r->organization;
|
||||
$award_awards_presenter=$r->presenter;
|
||||
$award_awards_excludefromac=$r->excludefromac;
|
||||
$award_awards_cwsfaward=$r->cwsfaward;
|
||||
|
||||
//select the current categories that this award is linked to
|
||||
$ccq=mysql_query("SELECT * FROM award_awards_projectcategories WHERE award_awards_id='$r->id'");
|
||||
@ -203,6 +206,7 @@ echo mysql_error();
|
||||
if($_POST['eligibledivisions']) $currentdivisions=$_POST['eligibledivisions'];
|
||||
if($_POST['presenter']) $award_awards_presenter=$_POST['presenter'];
|
||||
if($_POST['excludefromac']) $award_awards_excludefromac=$_POST['excludefromac'];
|
||||
if($_POST['cwsfaward']) $award_awards_cwsfaward=$_POST['cwsfaward'];
|
||||
|
||||
|
||||
echo "<form method=\"post\" action=\"award_awards.php\">\n";
|
||||
@ -292,6 +296,9 @@ echo mysql_error();
|
||||
echo "<tr><td align=\"right\">";
|
||||
if($award_awards_excludefromac==1) $ch="checked=\"checked\""; else $ch="";
|
||||
echo "<input $ch type=\"checkbox\" name=\"excludefromac\" value=\"1\"></td><td>".i18n("Exclude this award from the award ceremony script")."</td></tr>";
|
||||
echo "<tr><td align=\"right\">";
|
||||
if($award_awards_cwsfaward==1) $ch="checked=\"checked\""; else $ch="";
|
||||
echo "<input $ch type=\"checkbox\" name=\"cwsfaward\" value=\"1\"></td><td>".i18n("This award identifies the students that will be attending the Canada-Wide Science Fair")."</td></tr>";
|
||||
|
||||
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
|
||||
|
||||
|
335
admin/cwsfregister.php
Normal file
335
admin/cwsfregister.php
Normal file
@ -0,0 +1,335 @@
|
||||
<?
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
function xmlCreateRecurse($d)
|
||||
{
|
||||
global $indent;
|
||||
global $output;
|
||||
foreach($d AS $key=>$val)
|
||||
{
|
||||
if(is_numeric($key))
|
||||
{
|
||||
if($val['xml_type'])
|
||||
{
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="<".$val['xml_type'].">\n";
|
||||
$indent++;
|
||||
xmlCreateRecurse($val);
|
||||
$indent--;
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="</".$val['xml_type'].">\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="<$key>\n";
|
||||
$indent++;
|
||||
xmlCreateRecurse($val);
|
||||
$indent--;
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="</$key>\n";
|
||||
|
||||
}
|
||||
}
|
||||
else if(is_array($val))
|
||||
{
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="<$key>\n";
|
||||
$indent++;
|
||||
xmlCreateRecurse($val);
|
||||
$indent--;
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="</$key>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if($key!="xml_type" && $key!="projectid" && $key!="projectdivisions_id")
|
||||
{
|
||||
for($x=0;$x<$indent;$x++) $output.=" ";
|
||||
$output.="<$key>$val</$key>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_cwsf_award_winners()
|
||||
{
|
||||
global $config;
|
||||
$winners=array();
|
||||
|
||||
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q)==1)
|
||||
{
|
||||
$award=mysql_fetch_object($q);
|
||||
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award->id'");
|
||||
while($prize=mysql_fetch_object($pq))
|
||||
{
|
||||
$wq=mysql_query("SELECT
|
||||
projects.id,
|
||||
projects.projectnumber,
|
||||
projects.title,
|
||||
projects.summary,
|
||||
projects.registrations_id,
|
||||
projects.cwsfdivisionid,
|
||||
projects.projectdivisions_id
|
||||
|
||||
FROM
|
||||
winners,
|
||||
projects
|
||||
WHERE
|
||||
winners.projects_id=projects.id AND
|
||||
awards_prizes_id='$prize->id' AND
|
||||
winners.year='".$config['FAIRYEAR']."'");
|
||||
echo mysql_error();
|
||||
while($project=mysql_fetch_object($wq))
|
||||
{
|
||||
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='$project->registrations_id' AND year='".$config['FAIRYEAR']."'");
|
||||
$students=array();
|
||||
$cwsf_agecategory=0;
|
||||
while($s=mysql_fetch_object($sq))
|
||||
{
|
||||
if($s->grade>=7 && $s->grade<=8)
|
||||
{
|
||||
if($cwsf_agecategory<1)
|
||||
$cwsf_agecategory=1;
|
||||
}
|
||||
if($s->grade>=9 && $s->grade<=10)
|
||||
{
|
||||
if($cwsf_agecategory<2)
|
||||
$cwsf_agecategory=2;
|
||||
}
|
||||
if($s->grade>=11 && $s->grade<=13)
|
||||
{
|
||||
if($cwsf_agecategory<3)
|
||||
$cwsf_agecategory=3;
|
||||
}
|
||||
$students[]=array(
|
||||
"xml_type"=>"student",
|
||||
"firstname"=>$s->firstname,
|
||||
"lastname"=>$s->lastname,
|
||||
"email"=>$s->email,
|
||||
"gender"=>$s->sex,
|
||||
"grade"=>$s->grade,
|
||||
"language"=>$s->lang,
|
||||
"birthdate"=>$s->dateofbirth,
|
||||
"address1"=>$s->address,
|
||||
"address2"=>"",
|
||||
"city"=>$s->city,
|
||||
"province"=>$s->province,
|
||||
"postalcode"=>$s->postalcode,
|
||||
"homephone"=>$s->phone,
|
||||
"cellphone"=>"",
|
||||
);
|
||||
}
|
||||
$winners[]=array(
|
||||
"xml_type"=>"project",
|
||||
"projectid"=>$project->id,
|
||||
"projectnumber"=>$project->projectnumber,
|
||||
"title"=>$project->title,
|
||||
"abstract"=>$project->summary,
|
||||
"category_id"=>$cwsf_agecategory,
|
||||
"division_id"=>$project->cwsfdivisionid,
|
||||
"projectdivisions_id"=>$project->projectdivisions_id,
|
||||
"students"=>$students,
|
||||
);
|
||||
}
|
||||
}
|
||||
//print_r($award);
|
||||
}
|
||||
return $winners;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
require("../projects.inc.php");
|
||||
auth_required('admin');
|
||||
send_header("Administration - One-Click CWSF Registration");
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
if(count($_POST['cwsfdivision']))
|
||||
{
|
||||
foreach($_POST['cwsfdivision'] AS $p=>$d)
|
||||
{
|
||||
mysql_query("UPDATE projects SET cwsfdivisionid='$d' WHERE id='$p'");
|
||||
}
|
||||
echo happy(i18n("CWSF Project Divisions saved"));
|
||||
|
||||
}
|
||||
|
||||
$ok=true;
|
||||
//make sure we have the ysf_region_id and ysf_region_password
|
||||
if(!$config['ysf_region_id'])
|
||||
{
|
||||
echo error(i18n("You have not yet specified your YSF Region ID. Go to the Configuration Variables page to set it"));
|
||||
$ok=false;
|
||||
}
|
||||
if(!$config['ysf_region_password'])
|
||||
{
|
||||
echo error(i18n("You have not yet specified your YSF Region Password. Go to the Configuration Variables page to set it"));
|
||||
$ok=false;
|
||||
}
|
||||
|
||||
if($ok)
|
||||
{
|
||||
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND year='".$config['FAIRYEAR']."'");
|
||||
if(!mysql_num_rows($q))
|
||||
{
|
||||
echo error(i18n("Cannot find an award that is specified as the Canada-Wide Science Fair Award"));
|
||||
echo i18n("Please go to the awards manager and select which award identifies your CWSF students");
|
||||
}
|
||||
else if(mysql_num_rows($q)>1)
|
||||
{
|
||||
echo error(i18n("There is more than one award that is identified as your Canada-Wide Science Fair award."));
|
||||
echo i18n("Please go to the awards manager and choose only one award that identifies your CWSF students");
|
||||
}
|
||||
else
|
||||
{
|
||||
$award=mysql_fetch_object($q);
|
||||
echo "<b>".i18n("CWSF Award").":</b> ".$award->name."<br />";
|
||||
echo i18n("Please review the list of winning projects/students below. If it is all correct then you can click the 'Register for CWSF' button at the bottom of the page to send the information to YSF");
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
$winners=get_cwsf_award_winners();
|
||||
echo "<b>".i18n("Found %1 CWSF prize winners",array(count($winners)))."</b>";
|
||||
echo "<br />";
|
||||
$error=false;
|
||||
echo "<form method=\"post\" action=\"cwsfregister.php\">";
|
||||
echo "<table class=\"viewtable\">";
|
||||
echo "<tr><th>".i18n("Project Information")."</th>";
|
||||
echo "<th>".i18n("Project Division / CWSF Project Division")."</th>";
|
||||
echo "</tr>";
|
||||
|
||||
foreach($winners AS $winner)
|
||||
{
|
||||
echo "<tr><td>";
|
||||
echo "<b>";
|
||||
echo $winner['projectnumber']." - ".$winner['title'];
|
||||
echo "</b>";
|
||||
echo "<br />";
|
||||
foreach($winner['students'] AS $s)
|
||||
{
|
||||
echo " "; echo " "; echo " "; echo " ";
|
||||
echo $s['firstname']." ".$s['lastname'];
|
||||
echo " Email: ".$s['email'];
|
||||
if(!$s['email'])
|
||||
{
|
||||
echo error(i18n("No Email Address"),"inline");
|
||||
$error=true;
|
||||
}
|
||||
echo " Grade: ".$s['grade'];
|
||||
if(!$s['grade'])
|
||||
{
|
||||
echo error(i18n("No Grade"),"inline");
|
||||
$error=true;
|
||||
}
|
||||
|
||||
if(!$winner['division_id'])
|
||||
{
|
||||
echo "<br />";
|
||||
echo error(i18n("Choose a CWSF Division"),"inline");
|
||||
$error=true;
|
||||
|
||||
}
|
||||
echo "<br />";
|
||||
}
|
||||
echo "</td><td>";
|
||||
|
||||
$t=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' AND id='".$winner['projectdivisions_id']."'");
|
||||
$tr=mysql_fetch_object($t);
|
||||
echo $tr->division;
|
||||
echo "<br />";
|
||||
|
||||
echo "<select name=\"cwsfdivision[".$winner['projectid']."]\">";
|
||||
echo "<option value=\"\">".i18n("No corresponding CWSF division")."</option>\n";
|
||||
foreach($CWSFDivisions AS $k=>$v)
|
||||
{
|
||||
if($winner['division_id'])
|
||||
{
|
||||
if($k==$winner['division_id']) $sel="selected=\"selected\""; else $sel="";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($k==$tr->cwsfdivisionid) $sel="selected=\"selected\""; else $sel="";
|
||||
}
|
||||
|
||||
echo "<option $sel value=\"$k\">".i18n($v)."</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
|
||||
echo "</td></tr>";
|
||||
|
||||
}
|
||||
echo "<tr><td></td><td>";
|
||||
echo "<input type=\"submit\" value=\"Save CWSF Divisions\">";
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
if(!$error)
|
||||
{
|
||||
$reg=array("registration"=>array(
|
||||
"ysf_region_id"=>$config['ysf_region_id'],
|
||||
"ysf_region_password"=>$config['ysf_region_password'],
|
||||
"projects"=>$winners
|
||||
)
|
||||
);
|
||||
|
||||
$output="";
|
||||
xmlCreateRecurse($reg);
|
||||
$xmldata=$output;
|
||||
|
||||
echo "<h3>".i18n("The following data will be sent to YSF")."</h3>";
|
||||
echo "<form method=\"post\" action=\"cwsfregister.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"register\">";
|
||||
echo "<textarea rows=\"15\" cols=\"80\" name=\"xml\">";
|
||||
echo $xmldata;
|
||||
echo "</textarea>";
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo i18n("Warning! You can only use this feature once, and it will send whatever data is listed above. If you try to submit this data a second time to YSF it will not work. So please make sure everything is correct before submitting!");
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Register for CWSF")."\">";
|
||||
echo "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo error(i18n("You must correct the above errors before registration can proceed"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
send_footer();
|
||||
|
||||
?>
|
@ -843,4 +843,14 @@ function generatePassword()
|
||||
}
|
||||
|
||||
|
||||
$CWSFDivisions=array(
|
||||
1=>"Biotechnology & Pharmaceutical Sciences",
|
||||
2=>"Computing & Information Technology",
|
||||
3=>"Earth & Environmental Sciences",
|
||||
4=>"Engineering",
|
||||
5=>"Health Sciences",
|
||||
6=>"Life Sciences",
|
||||
7=>"Physical & Mathematical Sciences"
|
||||
);
|
||||
|
||||
?>
|
||||
|
78
config/divisions_cwsf.php
Normal file
78
config/divisions_cwsf.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
auth_required('config');
|
||||
send_header("Configuration - CWSF Project Divisions");
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Configuration")."</a><br />";
|
||||
|
||||
if(count($_POST['cwsfdivision']))
|
||||
{
|
||||
foreach($_POST['cwsfdivision'] AS $k=>$v)
|
||||
{
|
||||
mysql_query("UPDATE projectdivisions SET cwsfdivisionid='$v' WHERE id='$k' AND year='".$config['FAIRYEAR']."'");
|
||||
}
|
||||
echo happy(i18n("Corresponding CWSF divisions saved"));
|
||||
}
|
||||
|
||||
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
|
||||
|
||||
echo "<h3>".i18n("CWSF Project Divisions")."</h3>";
|
||||
|
||||
|
||||
echo i18n("For each of your divisions, please select a corresponding CWSF division if applicable. If no corresponding CWSF division is chosen then you will need to manually select the CWSF division for each project that you register for the CWSF. You can select the 'most likely' division to use as a default which can then be changed on a per-project basis when you perform the automatic CWSF registration");
|
||||
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo "<table class=\"summarytable\">";
|
||||
echo "<tr>";
|
||||
echo "<th>".i18n("Your Division")."</th>\n";
|
||||
echo "<th>".i18n("Corresponding CWSF Division")."</th>\n";
|
||||
echo "</tr>";
|
||||
|
||||
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<tr>";
|
||||
echo " <td>".i18n($r->division)."</td>";
|
||||
echo " <td>";
|
||||
echo "<select name=\"cwsfdivision[$r->id]\">";
|
||||
echo "<option value=\"\">".i18n("No corresponding CWSF division")."</option>\n";
|
||||
foreach($CWSFDivisions AS $k=>$v)
|
||||
{
|
||||
if($k==$r->cwsfdivisionid) $sel="selected=\"selected\""; else $sel="";
|
||||
echo "<option $sel value=\"$k\">".i18n($v)."</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo " </td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr><td colspan=\"2\" align=\"center\">";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Save Corresponding CWSF Divisions")."\">";
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
send_footer();
|
||||
?>
|
@ -31,6 +31,7 @@
|
||||
echo "<a href=\"dates.php\">".i18n("Important Dates")."</a> <br />";
|
||||
echo "<a href=\"categories.php\">".i18n("Project Age Categories")."</a> <br />";
|
||||
echo "<a href=\"divisions.php\">".i18n("Project Divisions")."</a> <br />";
|
||||
echo "<a href=\"divisions_cwsf.php\">".i18n("CWSF Project Divisions")."</a> <br />";
|
||||
echo "<a href=\"subdivisions.php\">".i18n("Project Sub-Divisions")."</a> <br />";
|
||||
echo "<a href=\"pagetexts.php\">".i18n("Page Texts")."</a> <br />";
|
||||
echo "<a href=\"signaturepage.php\">".i18n("Exhibitor Signature Page")."</a> <br />";
|
||||
|
@ -1 +1 @@
|
||||
28
|
||||
29
|
||||
|
Loading…
x
Reference in New Issue
Block a user