2005-01-24 18:00:03 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
2006-12-15 19:51:32 +00:00
Copyright ( C ) 2005 - 2006 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 - 2006 James Grant < james @ lightbox . org >
2005-01-24 18:00:03 +00:00
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 .
*/
?>
2005-01-07 04:45:17 +00:00
< ?
require ( " ../common.inc.php " );
2007-11-21 17:02:09 +00:00
require_once ( " ../user.inc.php " );
2007-11-18 23:50:23 +00:00
user_auth_required ( 'committee' , 'admin' );
2005-01-07 04:45:17 +00:00
require ( " ../register_participants.inc.php " );
2008-01-24 18:51:05 +00:00
if ( $_GET [ 'year' ]) $year = $_GET [ 'year' ];
else $year = $config [ 'FAIRYEAR' ];
2007-11-18 23:50:23 +00:00
send_header ( " Registration List and Statistics " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'Participant Registration' => 'admin/registration.php' )
);
2006-03-28 23:32:43 +00:00
?>
< script language = " javascript " type = " text/javascript " >
2006-12-15 18:45:06 +00:00
2006-03-28 23:32:43 +00:00
function openstudentinfo ( id )
{
window . open ( " students_info.php?id= " + id , " StudentInfo " , " location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes " );
return false ;
}
</ script >
< ?
2006-10-25 17:35:51 +00:00
if ( $_GET [ 'action' ] == " delete " && $_GET [ 'delete' ])
{
$regid = $_GET [ 'delete' ];
mysql_query ( " DELETE FROM registrations WHERE id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
mysql_query ( " DELETE FROM students WHERE registrations_id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
mysql_query ( " DELETE FROM projects WHERE registrations_id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
mysql_query ( " DELETE FROM safety WHERE registrations_id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
mysql_query ( " DELETE FROM questions_answers WHERE registrations_id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
mysql_query ( " DELETE FROM mentors WHERE registrations_id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
mysql_query ( " DELETE FROM emergencycontact WHERE registrations_id=' $regid ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
echo happy ( i18n ( " Registration and all related data successfully deleted " ));
}
2005-01-07 04:45:17 +00:00
echo " <br /> " ;
echo i18n ( " Choose Status " ) . " : " ;
echo " <form name= \" statuschangerform \" method= \" get \" action= \" registration_list.php \" > " ;
echo " <select name= \" showstatus \" onchange= \" document.forms.statuschangerform.submit() \" > " ;
2005-01-13 17:28:30 +00:00
2008-02-26 08:19:38 +00:00
$status_str = array ();
$status_str [ '' ] = i18n ( " Any Status " );
$status_str [ 'complete' ] = i18n ( " Complete " );
2005-01-14 20:56:51 +00:00
//if there is no reg fee, then we dont need to show this status, because nobody will ever be in this status
2008-02-26 08:19:38 +00:00
if ( $config [ 'regfee' ] > 0 ) $status_str [ 'paymentpending' ] = i18n ( " Payment Pending " );
$status_str [ 'open' ] = i18n ( " Open " );
$status_str [ 'new' ] = i18n ( " New " );
2005-01-13 17:28:30 +00:00
2008-02-26 08:32:00 +00:00
$showstatus = $_GET [ 'showstatus' ];
2008-02-26 08:28:20 +00:00
foreach ( $status_str as $s => $str ) {
2008-02-26 08:32:00 +00:00
$sel = ( $showstatus == $s ) ? " selected= \" selected \" " : '' ;
2008-02-26 08:19:38 +00:00
echo " <option $sel value= \" $s\ " > $str </ option > \n " ;
}
2005-01-07 04:45:17 +00:00
echo " </select> " ;
echo " </form> " ;
2008-01-24 18:51:05 +00:00
$q = mysql_query ( " SELECT * FROM projectcategories WHERE year=' $year ' ORDER BY id " );
2007-12-12 23:35:51 +00:00
while ( $r = mysql_fetch_object ( $q ))
$cats [ $r -> id ] = $r -> category ;
2008-01-24 18:51:05 +00:00
$q = mysql_query ( " SELECT * FROM projectdivisions WHERE year=' $year ' ORDER BY id " );
2007-12-12 23:35:51 +00:00
while ( $r = mysql_fetch_object ( $q ))
$divs [ $r -> id ] = $r -> division ;
2008-02-26 08:32:00 +00:00
if ( $showstatus ) $wherestatus = " AND status=' $showstatus ' " ;
2005-01-07 04:45:17 +00:00
else $wherestatus = " " ;
2005-01-14 17:00:24 +00:00
switch ( $_GET [ 'sort' ])
{
case 'status' : $ORDERBY = " registrations.status DESC, projects.title " ; break ;
case 'num' : $ORDERBY = " registrations.num " ; break ;
2008-01-15 18:20:56 +00:00
case 'projnum' : $ORDERBY = " projects.projectsort, projects.projectnumber " ; break ;
2005-01-14 17:00:24 +00:00
case 'title' : $ORDERBY = " projects.title, registrations.status DESC " ; break ;
case 'cat' : $ORDERBY = " projects.projectcategories_id, projects.title " ; break ;
case 'div' : $ORDERBY = " projects.projectdivisions_id, projects.title " ; break ;
default : $ORDERBY = " registrations.status DESC, projects.title " ; break ;
}
2005-01-07 04:45:17 +00:00
$q = mysql_query ( " SELECT registrations.id AS reg_id,
registrations . num AS reg_num ,
registrations . status ,
2007-03-02 15:02:14 +00:00
registrations . email ,
2005-01-07 04:45:17 +00:00
projects . title ,
2006-12-15 18:45:06 +00:00
projects . projectnumber ,
2005-01-13 16:51:43 +00:00
projects . projectcategories_id ,
projects . projectdivisions_id
2005-01-07 04:45:17 +00:00
FROM
registrations
left outer join projects on projects . registrations_id = registrations . id
WHERE
1
2008-01-24 18:51:05 +00:00
AND registrations . year = '$year'
2005-01-07 04:45:17 +00:00
$wherestatus
ORDER BY
2005-01-14 17:00:24 +00:00
$ORDERBY
2005-01-07 04:45:17 +00:00
" );
echo mysql_error ();
2005-01-13 16:51:43 +00:00
2008-08-20 20:25:42 +00:00
echo " <table class= \" tableview \" > " ;
2005-01-07 04:45:17 +00:00
echo " <tr> " ;
2008-02-26 08:32:00 +00:00
if ( $showstatus ) $stat = " &showstatus= " . $showstatus ;
2005-01-14 17:00:24 +00:00
echo " <th><a href= \" registration_list.php?sort=status $stat\ " > " .i18n( " Status " ). " </ a ></ th > " ;
2007-03-02 15:02:14 +00:00
echo " <th><a href= \" registration_list.php?sort=email \" > " . i18n ( " Email Address " ) . " </a></th> " ;
2005-01-14 17:00:24 +00:00
echo " <th><a href= \" registration_list.php?sort=num $stat\ " > " .i18n( " Reg Num " ). " </ a ></ th > " ;
2006-12-15 18:45:06 +00:00
echo " <th><a href= \" registration_list.php?sort=projnum $stat\ " > " .i18n( " Proj Num " ). " </ a ></ th > " ;
2005-01-14 17:00:24 +00:00
echo " <th><a href= \" registration_list.php?sort=title $stat\ " > " .i18n( " Project Title " ). " </ a ></ th > " ;
echo " <th><a href= \" registration_list.php?sort=cat $stat\ " > " .i18n( " Age Category " ). " </ a ></ th > " ;
echo " <th><a href= \" registration_list.php?sort=div $stat\ " > " .i18n( " Division " ). " </ a ></ th > " ;
2005-01-13 15:56:27 +00:00
echo " <th> " . i18n ( " School(s) " ) . " </th> " ;
echo " <th> " . i18n ( " Student(s) " ) . " </th> " ;
2006-10-25 17:35:51 +00:00
echo " <th> " . i18n ( " Action " ) . " </th> " ;
2005-01-07 04:45:17 +00:00
echo " </tr> " ;
2005-01-13 18:00:36 +00:00
$stats_totalprojects = 0 ;
$stats_totalstudents = 0 ;
$stats_divisions = array ();
$stats_categories = array ();
2007-12-12 23:35:51 +00:00
$stats_students_catdiv = array ();
$stats_projects_catdiv = array ();
$stats_students_schools = array ();
$stats_projects_schools = array ();
$schools_names = array ();
2005-01-07 04:45:17 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
2005-01-13 18:00:36 +00:00
$stats_totalprojects ++ ;
$stats_divisions [ $r -> projectdivisions_id ] ++ ;
$stats_categories [ $r -> projectcategories_id ] ++ ;
2007-12-12 23:35:51 +00:00
$stats_projects_catdiv [ $r -> projectcategories_id ][ $r -> projectdivisions_id ] ++ ;
2005-01-13 18:00:36 +00:00
2005-01-07 04:45:17 +00:00
switch ( $r -> status )
{
case " new " : $status_text = " New " ; break ;
case " open " : $status_text = " Open " ; break ;
case " paymentpending " : $status_text = " Payment Pending " ; break ;
case " complete " : $status_text = " Complete " ; break ;
}
2005-01-13 15:56:27 +00:00
$status_text = i18n ( $status_text );
2005-01-07 04:45:17 +00:00
echo " <tr> " ;
echo " <td> $status_text </td> " ;
2007-03-02 15:02:14 +00:00
echo " <td> $r->email </td> " ;
2005-01-07 04:45:17 +00:00
echo " <td> $r->reg_num </td> " ;
2006-12-15 18:45:06 +00:00
echo " <td> $r->projectnumber </td> " ;
echo " <td><a title= \" " . i18n ( " Click to edit " ) . " \" href= \" project_editor.php?registration_id= $r->reg_id\ " > $r -> title </ a ></ td > " ;
2005-01-13 16:51:43 +00:00
2007-12-12 23:35:51 +00:00
echo " <td> " . i18n ( $cats [ $r -> projectcategories_id ]) . " </td> " ;
echo " <td> " . i18n ( $divs [ $r -> projectdivisions_id ]) . " </td> " ;
2005-01-07 04:45:17 +00:00
$sq = mysql_query ( " SELECT students.firstname,
students . lastname ,
2006-03-28 23:32:43 +00:00
students . id ,
2007-12-12 23:35:51 +00:00
schools . school ,
2008-01-24 18:51:05 +00:00
schools . board ,
2007-12-12 23:35:51 +00:00
schools . id AS schools_id
2005-01-07 04:45:17 +00:00
FROM
students , schools
WHERE
students . registrations_id = '$r->reg_id'
AND
students . schools_id = schools . id
" );
echo mysql_error ();
$studnum = 1 ;
$schools = " " ;
$students = " " ;
while ( $studentinfo = mysql_fetch_object ( $sq ))
{
2006-12-15 18:45:06 +00:00
$students .= " <a href= \" student_editor.php?registration_id= $r->reg_id\ " > $studentinfo -> firstname $studentinfo -> lastname </ a >< br /> " ;
2005-01-07 04:45:17 +00:00
$schools .= " $studentinfo->school <br /> " ;
2005-01-13 18:00:36 +00:00
$stats_totalstudents ++ ;
2007-12-12 23:35:51 +00:00
$stats_students_catdiv [ $r -> projectcategories_id ][ $r -> projectdivisions_id ] ++ ;
$stats_students_schools [ $r -> projectcategories_id ][ $studentinfo -> schools_id ] ++ ;
2008-01-24 18:51:05 +00:00
$schools_names [ $studentinfo -> schools_id ] = $studentinfo -> school . " ( $studentinfo->board ) " ;
2007-12-12 23:35:51 +00:00
$lastschoolid = $studentinfo -> schools_id ;
2005-01-07 04:45:17 +00:00
}
2007-12-12 23:35:51 +00:00
//this really isnt right, its only taking the school from the last student in the project to count towards the school's project totals
//but there's really no other way
$stats_projects_schools [ $r -> projectcategories_id ][ $lastschoolid ] ++ ;
2005-01-07 04:45:17 +00:00
echo " <td> $schools </td> " ;
echo " <td> $students </td> " ;
2006-10-25 17:35:51 +00:00
echo " <td align= \" center \" > " ;
2008-01-24 18:51:05 +00:00
if ( $year == $config [ 'FAIRYEAR' ]) {
echo " <a href= \" registration_list.php?action=delete&delete= $r->reg_id\ " onclick = \ " return confirmClick(' " . i18n ( " Are you sure you want to completely delete this registration? " ) . " '); \" > " ;
echo " <img src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" border=0> " ;
echo " </a> " ;
}
2006-10-25 17:35:51 +00:00
echo " </td> " ;
2005-01-07 04:45:17 +00:00
echo " </tr> " ;
}
echo " </table> \n " ;
echo " <br /> " ;
2005-01-13 18:00:36 +00:00
echo " <table style= \" margin-left: 50px; \" > " ;
2008-02-26 08:19:38 +00:00
echo " <tr><td colspan= \" 2 \" ><h3> { $status_str [ $showstatus ] } - " . i18n ( " Students / projects per age category / division " ) . " </h3></td></tr> " ;
2007-12-12 20:57:51 +00:00
echo " <tr><td colspan= \" 2 \" > " ;
2007-12-12 23:35:51 +00:00
echo " <table class= \" tableview \" width= \" 100% \" > " ;
echo " <tr><td width= \" 50% \" ></td> " ;
2007-12-12 20:57:51 +00:00
foreach ( $cats AS $c => $cn ) {
2007-12-12 23:35:51 +00:00
echo " <th> $cn <br /><nobr> " . i18n ( " Stud | Proj " ) . " </nobr></th> " ;
2007-12-12 20:57:51 +00:00
}
2007-12-12 23:35:51 +00:00
echo " <th> " . i18n ( " Total " ) . " <br /><nobr> " . i18n ( " Stud | Proj " ) . " </th> " ;
2007-12-12 20:57:51 +00:00
echo " </tr> " ;
foreach ( $divs AS $d => $dn ) {
2007-12-12 23:35:51 +00:00
echo " <tr><td> $dn </td> " ;
$tstud = 0 ;
$tproj = 0 ;
2007-12-12 20:57:51 +00:00
foreach ( $cats AS $c => $cn )
2007-12-12 23:35:51 +00:00
{
echo " <td align= \" center \" > " ;
echo ( $stats_students_catdiv [ $c ][ $d ] ? $stats_students_catdiv [ $c ][ $d ] : 0 );
echo " " ;
echo ( $stats_projects_catdiv [ $c ][ $d ] ? $stats_projects_catdiv [ $c ][ $d ] : 0 );
echo " </td> " ;
$tstud += $stats_students_catdiv [ $c ][ $d ];
$tproj += $stats_projects_catdiv [ $c ][ $d ];
$tstudcat [ $c ] += $stats_students_catdiv [ $c ][ $d ];
$tprojcat [ $c ] += $stats_projects_catdiv [ $c ][ $d ];
}
echo " <td align= \" center \" ><b> " ;
echo ( $tstud ? $tstud : 0 );
echo " " ;
echo ( $tproj ? $tproj : 0 );
echo " </b></td> " ;
2007-12-12 20:57:51 +00:00
echo " </tr> " ;
}
echo " <tr><td><b> " . i18n ( " Total " ) . " </b></td> " ;
2008-02-26 08:19:38 +00:00
$tstud = 0 ;
$tproj = 0 ;
2007-12-12 20:57:51 +00:00
foreach ( $cats AS $c => $cn ) {
2007-12-12 23:35:51 +00:00
echo " <td align= \" center \" ><b> " ;
echo ( $tstudcat [ $c ] ? $tstudcat [ $c ] : 0 );
echo " " ;
echo ( $tprojcat [ $c ] ? $tprojcat [ $c ] : 0 );
echo " </b></td> " ;
2008-02-26 08:19:38 +00:00
$tstud += $tstudcat [ $c ];
$tproj += $tprojcat [ $c ];
2007-12-12 20:57:51 +00:00
}
2007-12-12 23:35:51 +00:00
echo " <td align= \" center \" ><b> " ;
2008-02-26 08:19:38 +00:00
echo ( $tstud );
2007-12-12 23:35:51 +00:00
echo " " ;
2008-02-26 08:19:38 +00:00
echo ( $tproj );
2007-12-12 23:35:51 +00:00
echo " </b></td> " ;
2007-12-12 20:57:51 +00:00
echo " </tr> " ;
2005-01-13 18:00:36 +00:00
echo " </table> " ;
2007-12-12 23:35:51 +00:00
echo " </td></tr> " ;
echo " <tr><td colspan= \" 2 \" ><br /></td></tr> " ;
2008-02-26 08:19:38 +00:00
echo " <tr><td colspan= \" 2 \" ><h3> { $status_str [ $showstatus ] } - " . i18n ( " Students / projects per age category / school " ) . " </h3></td></tr> " ;
2007-12-12 23:35:51 +00:00
echo " <tr><td colspan= \" 2 \" > " ;
echo " <table class= \" tableview \" width= \" 100% \" > " ;
echo " <tr><td width= \" 50% \" ></td> " ;
foreach ( $cats AS $c => $cn ) {
echo " <th> $cn <br /><nobr> " . i18n ( " Stud | Proj " ) . " </nobr></th> " ;
}
echo " <th> " . i18n ( " Total " ) . " <br /><nobr> " . i18n ( " Stud | Proj " ) . " </nobr></th> " ;
echo " </tr> " ;
asort ( $schools_names );
foreach ( $schools_names AS $id => $sn )
{
echo " <tr><td> $sn </td> " ;
$tstud = 0 ;
$tproj = 0 ;
foreach ( $cats AS $c => $cn ) {
echo " <td align= \" center \" > " . ( $stats_students_schools [ $c ][ $id ] ? $stats_students_schools [ $c ][ $id ] : 0 );
echo " " ;
echo ( $stats_projects_schools [ $c ][ $id ] ? $stats_projects_schools [ $c ][ $id ] : 0 ) . " </td> " ;
$tstud += $stats_students_schools [ $c ][ $id ];
$tproj += $stats_projects_schools [ $c ][ $id ];
}
echo " <td align= \" center \" ><b> " . ( $tstud ? $tstud : 0 );
echo " " ;
echo ( $tproj ? $tproj : 0 ) . " </b></td> " ;
echo " </tr> " ;
}
echo " </table> " ;
echo i18n ( " %1 schools total " , array ( count ( $schools_names )));
echo " </td></tr> " ;
echo " </table> " ;
2005-01-13 18:00:36 +00:00
echo " <br /> " ;
echo i18n ( " Note: statistics reflect the numbers of the current 'Status' selected at the top of the page " );
echo " <br /> " ;
echo " <br /> " ;
2005-01-07 04:45:17 +00:00
send_footer ();
?>