From dbcd4e955f7f05822e53e97c59d7a1e551a419e3 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 5 Oct 2007 18:40:07 +0000 Subject: [PATCH] Update admin index to include One-Click Affiliation Stats Factor XML functiosn out of cwsfregister into separate xml.inc.php Add xml functionality to ysfstats, and fudge the male/female stats to include "not specificed" genders Add submit functionality to ysfstats to actually send data to YSF --- admin/cwsfregister.php | 52 +------------- admin/index.php | 1 + admin/ysfstats.php | 151 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 51 deletions(-) diff --git a/admin/cwsfregister.php b/admin/cwsfregister.php index 49b9fb4..ab3ea28 100644 --- a/admin/cwsfregister.php +++ b/admin/cwsfregister.php @@ -21,57 +21,7 @@ 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.="\n"; - } - else - { - for($x=0;$x<$indent;$x++) $output.=" "; - $output.="<$key>\n"; - $indent++; - xmlCreateRecurse($val); - $indent--; - for($x=0;$x<$indent;$x++) $output.=" "; - $output.="\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.="\n"; - } - else - { - if($key!="xml_type" && $key!="projectid" && $key!="projectdivisions_id") - { - for($x=0;$x<$indent;$x++) $output.=" "; - $output.="<$key>$val\n"; - } - } - } -} - +include "xml.inc.php"; function get_cwsf_award_winners() { diff --git a/admin/index.php b/admin/index.php index 847fad1..86238e1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -42,6 +42,7 @@ if($config['tours_enable'] == 'yes') { echo "
"; echo "".i18n("Enter Winning Projects")."
"; echo "".i18n("One-Click CWSF Registration")."
"; + echo "".i18n("One-Click YSF Affiliation")."
"; echo "
"; echo "".i18n("Communication (Send Emails)")."
"; diff --git a/admin/ysfstats.php b/admin/ysfstats.php index cc753a4..607f615 100644 --- a/admin/ysfstats.php +++ b/admin/ysfstats.php @@ -23,22 +23,90 @@ "; + curl_close ($ch); /// close the curl session + + echo i18n("The YSF Registration Server said:")."
"; + echo notice($datastream); + } + 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; + } + + $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($_GET['year']) $year=$_GET['year']; + else if($_POST['year']) $POST=$_GET['year']; else $year=$config['FAIRYEAR']; + echo "
"; + $q=mysql_query("SELECT DISTINCT(year) AS year FROM config WHERE year>0 ORDER BY year"); + echo "\n"; + echo "
"; + + if($year) + { + + echo i18n("The following information is collected by YSF Canada each year for all affiliated regions"); + echo "
"; + echo "
"; + + $stats=array(); + //number of schools $q=mysql_query("SELECT COUNT(id) AS num FROM schools WHERE year='$year'"); $r=mysql_fetch_object($q); $numberofschools=$r->num; echo i18n("Number of schools: %1",array($numberofschools))."
"; + $stats["numschoolstotal"]=$numberofschools; //number of schools $q=mysql_query("SELECT DISTINCT(students.schools_id) AS sid FROM students,registrations WHERE students.registrations_id=registrations.id AND students.year='$year' AND registrations.year='$year' AND (registrations.status='complete' OR registrations.status='paymentpending')"); echo mysql_error(); $numberofactiveschools=mysql_num_rows($q); echo i18n("Number of active schools: %1",array($numberofactiveschools))."
"; + $stats["numschoolsactive"]=$numberofactiveschools; //total number of students: $q=mysql_query("SELECT COUNT(students.id) AS num FROM students,registrations WHERE students.registrations_id=registrations.id AND students.year='$year' AND registrations.year='$year' AND (registrations.status='complete' OR registrations.status='paymentpending')"); @@ -46,6 +114,7 @@ $numberofstudents=$r->num; echo i18n("Number of students: %1",array($numberofstudents))."
"; echo mysql_error(); + $stats["numstudents"]=$numberofstudents; //number of students per grade per gender $q=mysql_query("SELECT COUNT(students.id) AS num, students.grade, students.sex FROM students,registrations WHERE students.registrations_id=registrations.id AND students.year='$year' AND registrations.year='$year' AND (registrations.status='complete' OR registrations.status='paymentpending') GROUP BY students.grade, students.sex"); @@ -60,6 +129,7 @@ else if($r->grade>10) $nums["11up"][$r->sex]+=$r->num; } + echo "
"; echo "Student participation (by age group/gender)
"; echo i18n("K-6 Male: %1",array($nums["6down"]["male"]?$nums["6down"]["male"]:0))."
"; echo i18n("K-6 Female: %1",array($nums["6down"]["female"]?$nums["6down"]["female"]:0))."
"; @@ -85,6 +155,50 @@ echo i18n("11 up Unknown: %1",array($nums["11up"][""]?$nums["11up"][""]:0))."
"; echo "
"; + $stats["numk6m"]=$nums["6down"]["male"]?$nums["6down"]["male"]:0; + $stats["numk6f"]=$nums["6down"]["female"]?$nums["6down"]["female"]:0; + //add on unknown genders split evenly + if($nums["6down"][""]>0) + { + $m=ceil($nums["6down"][""]/2); + $f=$nums["6down"][""]-$m; + $stats["numk6m"]+=$m; + $stats["numk6f"]+=$f; + } + + $stats["num78m"]=$nums["78"]["male"]?$nums["78"]["male"]:0; + $stats["num78f"]=$nums["78"]["female"]?$nums["78"]["female"]:0; + if($nums["78"][""]>0) + { + $m=ceil($nums["78"][""]/2); + $f=$nums["78"][""]-$m; + $stats["num78m"]+=$m; + $stats["num78f"]+=$f; + } + + + $stats["num910m"]=$nums["910"]["male"]?$nums["910"]["male"]:0; + $stats["num910f"]=$nums["910"]["female"]?$nums["910"]["female"]:0; + if($nums["910"][""]>0) + { + $m=ceil($nums["910"][""]/2); + $f=$nums["910"][""]-$m; + $stats["num910m"]+=$m; + $stats["num910f"]+=$f; + } + + + + $stats["num11upm"]=$nums["11up"]["male"]?$nums["11up"]["male"]:0; + $stats["num11upf"]=$nums["11up"]["female"]?$nums["11up"]["female"]:0; + if($nums["11up"][""]>0) + { + $m=ceil($nums["11up"][""]/2); + $f=$nums["11up"][""]-$m; + $stats["num11upm"]+=$m; + $stats["num11upf"]+=$f; + } + //number of students per grade per gender $q=mysql_query("SELECT MAX(students.grade) grade FROM students,registrations,projects WHERE students.registrations_id=registrations.id AND projects.registrations_id=registrations.id AND students.year='$year' AND registrations.year='$year' AND projects.year='$year' AND (registrations.status='complete' OR registrations.status='paymentpending') GROUP BY projects.id"); @@ -107,19 +221,56 @@ echo i18n("11 up: %1",array($projs["11up"]?$projs["11up"]:0))."
"; echo "
"; + $stats["projk6"]=$projs["6down"]?$projs["6down"]:0; + $stats["proj78"]=$projs["78"]?$projs["78"]:0; + $stats["proj910"]=$projs["910"]?$projs["910"]:0; + $stats["proj11up"]=$projs["11up"]?$projs["11up"]:0; + $q=mysql_query("SELECT COUNT(id) AS num FROM committees_members WHERE deleted='N'"); $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 "
"; + $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'"); $r=mysql_fetch_object($q); $numjudges=$r->num; echo i18n("Judges: %1",array($r->num)); + $stats["judges"]=$numjudges; echo "
"; + if($ok) + { + $affil=array("affiliation"=>array( + "ysf_region_id"=>$config['ysf_region_id'], + "ysf_region_password"=>$config['ysf_region_password'], + "year"=>$year, + "stats"=>$stats + ) + ); + $output=""; + xmlCreateRecurse($affil); + $xmldata=$output; + + echo "

".i18n("The following data will be sent to YSF")."

"; + echo "
"; + echo ""; + echo ""; + echo "
"; + echo "
"; + 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 "
"; + echo "
"; + echo ""; + echo "
"; + + } + + } send_footer(); ?>