2007-03-18 07:10:54 +00:00
< ?
/*
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 .
*/
?>
< ?
2007-12-10 02:50:53 +00:00
require_once ( " ../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' );
2007-03-18 07:10:54 +00:00
require_once ( 'reports.inc.php' );
2009-10-15 07:11:43 +00:00
2007-03-18 07:10:54 +00:00
$id = intval ( $_GET [ 'id' ]);
2007-12-10 02:50:53 +00:00
$type = stripslashes ( $_GET [ 'type' ]);
$stock = stripslashes ( $_GET [ 'stock' ]);
2007-10-20 04:04:14 +00:00
$year = intval ( $_GET [ 'year' ]);
2009-11-06 08:57:13 +00:00
$include_incomplete_registrations = ( $_GET [ 'include_incomplete_registrations' ] == 'yes' ) ? 'yes' : '' ;
2007-12-10 02:50:53 +00:00
$show_options = array_key_exists ( 'show_options' , $_GET );
2007-10-20 04:04:14 +00:00
if ( $year < 1000 ) $year = $config [ 'FAIRYEAR' ];
2007-03-18 07:10:54 +00:00
2007-12-08 00:00:26 +00:00
/* If it's a system report, turn that into the actual report id */
2009-10-15 07:11:43 +00:00
if ( array_key_exists ( 'sid' , $_GET )) {
$sid = intval ( $_GET [ 'sid' ]);
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT id FROM reports WHERE system_report_id=' $sid ' " );
$q -> execute ();
$r = $q -> fetch ( PDO :: FETCH_OBJ );
2007-12-08 00:00:26 +00:00
$id = $r [ 'id' ];
}
2009-10-15 07:11:43 +00:00
2009-10-16 18:18:38 +00:00
$report = report_load ( $id );
/* Add a custom filter if specified */
$filter_args = '' ;
if ( is_array ( $_GET [ 'filter' ])) {
foreach ( $_GET [ 'filter' ] as $f => $v ) {
$report [ 'filter' ][] = array ( 'field' => $v [ 'field' ], 'x' => $v [ 'x' ], 'value' => $v [ 'value' ]);
$filter_args .= " &filter[ $f ][field]= { $v [ 'field' ] } &filter[ $f ][x]= { $v [ 'x' ] } &filter[ $f ][value]= { $v [ 'value' ] } " ;
}
}
2009-10-15 07:11:43 +00:00
switch ( $_GET [ 'action' ]) {
case 'dialog_gen' :
2010-03-15 06:02:25 +00:00
if ( $id < 0 ) {
$u = " { $config [ 'SFIABDIRECTORY' ] } / { $report_custom [ - $id ][ 'custom_url' ] } " ;
?>
< script type = " text/javascript " >
window . location . href = " <?= $u ?> " ;
</ script >
< ?
exit ;
}
2009-10-15 07:11:43 +00:00
?>
< div id = " report_dialog_gen " title = " Generate Report " style = " display: none " >
2009-11-06 08:57:13 +00:00
< div id = " report_gen_tabs " >
< ul >< li >< a href = " #report_gen_tab_info " >< span >< ? = i18n ( 'Report Information' ) ?> </span></a></li>
< li >< a href = " #report_gen_tab_advanced " >< span >< ? = i18n ( 'Advanced Options' ) ?> </span></a></li>
</ ul >
2009-10-15 07:11:43 +00:00
< form id = " report_dialog_form " >
2009-11-06 08:57:13 +00:00
< div id = " report_gen_tab_info " >
2009-10-15 07:11:43 +00:00
< input type = " hidden " name = " id " value = " <?= $id ?> " />
< table class = " editor " style = " width:95% " >< tr >
< td colspan = " 2 " >< br />< h3 >< ? = i18n ( 'Report Information' ) ?> </h3><br /></td>
</ tr >< tr >
< td class = " label " >< b >< ? = i18n ( " Report Name " ) ?> </b>:</td>
< td class = " input " >< ? = $report [ 'name' ] ?> </b></td>
</ tr >< tr >
< td class = " label " >< b >< ? = i18n ( " Description " ) ?> </b>:</td>
< td class = " input " >< ? = $report [ 'desc' ] ?> </b></td>
</ tr >< tr >
< td class = " label " >< b >< ? = i18n ( " Created By " ) ?> </b>:</td>
< td class = " input " >< ? = $report [ 'creator' ] ?> </td>
</ tr >< tr >
< ?
/* See if the report is in this committee member's list */
2024-12-08 07:42:00 +00:00
$q = $pd -> prepare ( " SELECT * FROM reports_committee
2009-10-15 07:11:43 +00:00
WHERE users_id = '{$_SESSION[' users_uid ']}'
AND reports_id = '{$report[' id ']}' " );
2024-12-08 07:42:00 +00:00
$q -> execute ();
if ( $q -> rowCount () > 0 ) {
$i = $q -> fetch ( PDO :: FETCH_ASSOC );
2009-10-15 07:11:43 +00:00
?>
< td colspan = " 2 " >< hr />< h3 >< ? = i18n ( 'My Reports Info' ) ?> </h3></td>
</ tr >< tr >
< td class = " label " >< b >< ? = i18n ( " Category " ) ?> </b>:</td>
< td class = " input " >< ? = $i [ 'category' ] ?> </b></td>
</ tr >< tr >
< td class = " label " >< b >< ? = i18n ( " Comment " ) ?> </b>:</td>
< td class = " input " >< ? = $i [ 'comment' ] ?> </b></td>
</ tr >< tr >
< ? } ?>
< td colspan = " 2 " >< br />< hr />< h3 >< ? = i18n ( 'Report Options' ) ?> </h3><br /></td>
</ tr >
< ?
$format = $report [ 'options' ][ 'type' ];
$stock = $report [ 'options' ][ 'stock' ];
$year = $config [ 'FAIRYEAR' ];
/* Out of all the report optins, we really only want these ones */
$option_keys = array ( 'type' , 'stock' );
foreach ( $report_options as $ok => $o ) {
if ( ! in_array ( $ok , $option_keys )) continue ;
echo " <tr><td class= \" label \" ><b> { $o [ 'desc' ] } </b>:</td> " ;
echo " <td class= \" input \" ><select name= \" $ok\ " id = \ " $ok\ " > " ;
foreach ( $o [ 'values' ] as $k => $v ) {
2009-12-16 19:11:00 +00:00
$sel = ( $report [ 'option' ][ $ok ] == $k ) ? 'selected="selected"' : '' ;
2009-12-16 18:49:53 +00:00
echo " <option value= \" $k\ " $sel > " .htmlspecialchars( $v ). " </ option > " ;
2009-10-15 07:11:43 +00:00
}
2009-12-16 18:49:53 +00:00
echo " </select></td></tr> \n " ;
2009-10-15 07:11:43 +00:00
}
/* Find all the years */
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT DISTINCT year FROM config WHERE year>1000 ORDER BY year DESC " );
$q -> execute ();
2009-10-15 07:11:43 +00:00
echo " <tr><td class= \" label \" ><b> " . i18n ( 'Year' ) . " </b>:</td> " ;
echo " <td class= \" input \" ><select name= \" year \" id= \" year \" > " ;
2024-12-08 07:42:00 +00:00
while ( $i = $q -> fetch ( PDO :: FETCH_ASSOC )) {
2009-10-15 07:11:43 +00:00
$y = $i [ 'year' ];
2009-12-16 18:43:57 +00:00
$sel = ( $config [ 'FAIRYEAR' ] == $y ) ? 'selected="selected"' : '' ;
2009-10-15 07:11:43 +00:00
echo " <option value= \" $y\ " $sel > $y </ option > " ;
}
2009-12-16 18:49:53 +00:00
echo " </select></td></tr> \n " ;
2009-10-15 07:11:43 +00:00
?>
</ table >
2009-11-06 08:57:13 +00:00
</ div >
< div id = " report_gen_tab_advanced " >
< table class = " editor " style = " width:95% " >< tr >
< td colspan = " 2 " >< br />< h4 >< ? = i18n ( 'Advanced Options' ) ?> </h4><br /></td>
</ tr >< tr >
< td class = " label " >< input type = " checkbox " name = " include_incomplete_registrations " value = " yes " /></ td >
2009-11-06 09:00:02 +00:00
< td class = " input " >< ? = i18n ( 'Include student and project data from incomplete registrations. The registration only needs to have a division and category selected.' ) ?> </td>
2009-11-06 08:57:13 +00:00
</ table >
</ div >
</ form >
</ div ></ div >
2009-10-15 07:11:43 +00:00
< script type = " text/javascript " >
2009-11-06 08:57:13 +00:00
$ ( " #report_gen_tabs " ) . tabs ();
2009-10-15 07:11:43 +00:00
$ ( " #report_dialog_gen " ) . dialog ({
bgiframe : true , autoOpen : true ,
modal : true , resizable : false ,
draggable : false ,
width : 800 , //(document.documentElement.clientWidth * 0.8);
2009-11-06 08:24:54 +00:00
height : 600 , //(document.documentElement.clientHeight * 0.7),
2009-10-15 07:11:43 +00:00
close : function () {
$ ( this ) . dialog ( 'destroy' );
$ ( '#report_dialog_gen' ) . remove ();
2009-11-06 08:24:54 +00:00
},
buttons : { " <?=i18n( " Cancel " )?> " : function () {
$ ( '#report_dialog_gen' ) . dialog ( " close " );
return false ;
},
2010-02-16 22:07:46 +00:00
" <?=i18n( " Download Report " )?> " : function () {
2009-11-06 08:24:54 +00:00
var dlargs = $ ( '#report_dialog_form' ) . serialize () + " <?= $filter_args ?> " ;
var dlurl = " <?= $config['SFIABDIRECTORY'] ?>/admin/reports_gen.php? " + dlargs ;
2009-11-06 08:57:13 +00:00
$ ( '#debug' ) . html ( dlurl );
2009-11-06 08:24:54 +00:00
// alert(dlurl);
// $('#content').attr('src',dlurl);
window . location . href = dlurl ;
$ ( '#report_dialog_gen' ) . dialog ( " close " );
return false ;
2010-02-03 16:02:45 +00:00
}
}
2009-10-15 07:11:43 +00:00
});
</ script >
< ?
exit ;
}
2007-12-08 00:00:26 +00:00
2007-12-10 02:50:53 +00:00
if ( $show_options == false ) {
if ( $id && $year ) {
$report [ 'year' ] = $year ;
if ( $type != '' ) $report [ 'option' ][ 'type' ] = $type ;
if ( $stock != '' ) $report [ 'option' ][ 'stock' ] = $stock ;
2009-11-06 08:57:13 +00:00
if ( $include_incomplete_registrations != '' ) $report [ 'option' ][ 'include_incomplete_registrations' ] = 'yes' ;
2007-12-10 02:50:53 +00:00
report_gen ( $report );
} else {
exit ;
header ( " Location: reports.php " );
}
exit ;
}
send_header ( 'Report Options' , array (
'Committee Main' => 'committee_main.php' ,
2007-12-10 22:06:41 +00:00
'My Reports' => 'admin/reports.php' ));
2007-12-10 02:50:53 +00:00
2009-09-27 01:20:12 +00:00
echo '<form method=\"get\" action="reports_gen.php">' ;
echo " <input type= \" hidden \" name= \" id \" value= \" $id\ " > " ;
2007-12-11 18:22:27 +00:00
echo '<table class="tableedit">' ;
2007-12-10 02:50:53 +00:00
echo " <tr><td><b> " . i18n ( 'Report Name' ) . " </b>:</td> " ;
echo " <td> { $report [ 'name' ] } </td></tr> " ;
echo " <tr><td><b> " . i18n ( 'Description' ) . " </b>:</td> " ;
echo " <td> { $report [ 'desc' ] } </td></tr> " ;
echo " <tr><td><b> " . i18n ( 'Created By' ) . " </b>:</td> " ;
echo " <td> { $report [ 'creator' ] } </td></tr> " ;
2007-03-18 07:10:54 +00:00
2007-12-10 02:50:53 +00:00
echo '<tr><td colspan="2"><hr /></td></tr>' ;
/* See if the report is in this committee member's list */
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT * FROM reports_committee
2009-09-09 00:26:12 +00:00
WHERE users_id = '{$_SESSION[' users_uid ']}'
2007-12-10 02:50:53 +00:00
AND reports_id = '{$report[' id ']}' " );
2024-12-08 07:42:00 +00:00
$q -> execute ();
2009-09-27 01:20:12 +00:00
echo " <tr><td colspan= \" 2 \" ><h3> " . i18n ( 'My Reports Info' ) . " </h3></td></tr> " ;
2024-12-08 07:42:00 +00:00
if ( $q -> rowCount () > 0 ) {
2007-12-10 02:50:53 +00:00
/* Yes, it is */
2024-12-08 07:42:00 +00:00
$i = $q -> fetch ( PDO :: FETCH_OBJ );
2007-12-10 02:50:53 +00:00
echo " <tr><td><b> " . i18n ( 'Category' ) . " </b>:</td> " ;
echo " <td> { $i -> category } </td></tr> " ;
echo " <tr><td><b> " . i18n ( 'Comment' ) . " </b>:</td> " ;
echo " <td> { $i -> comment } </td></tr> " ;
} else {
2009-09-27 03:07:39 +00:00
echo " <tr><td></td><td> " . i18n ( 'This report is NOT in your \'My Reports\' list.' ) . " </td></tr> " ;
2007-10-25 20:30:58 +00:00
}
2009-09-27 01:20:12 +00:00
echo '<tr><td colspan="2"><hr /></td></tr>' ;
echo " <tr><td colspan= \" 2 \" ><h3> " . i18n ( 'Report Options' ) . " </h3></td></tr> " ;
2007-12-10 02:50:53 +00:00
$format = $report [ 'options' ][ 'type' ];
$stock = $report [ 'options' ][ 'stock' ];
$year = $config [ 'FAIRYEAR' ];
/* Out of all the report optoins, we really only want these ones */
$option_keys = array ( 'type' , 'stock' );
foreach ( $report_options as $ok => $o ) {
if ( ! in_array ( $ok , $option_keys )) continue ;
echo " <tr><td><b> { $o [ 'desc' ] } </b>:</td> " ;
echo " <td><select name= \" $ok\ " id = \ " $ok\ " > " ;
foreach ( $o [ 'values' ] as $k => $v ) {
2009-12-16 18:43:57 +00:00
$sel = ( $report [ 'option' ][ $ok ] == $k ) ? 'selected="selected"' : '' ;
2007-12-10 02:50:53 +00:00
echo " <option value= \" $k\ " $sel > $v </ option > " ;
}
echo " </select></td></tr> " ;
}
/* Find all the years */
2024-12-08 07:42:00 +00:00
$q = $pdo -> prepare ( " SELECT DISTINCT year FROM config WHERE year>1000 ORDER BY year DESC " );
$q -> execute ();
2007-12-10 02:50:53 +00:00
echo " <tr><td><b> " . i18n ( 'Year' ) . " </b>:</td> " ;
echo " <td><select name= \" year \" id= \" year \" > " ;
2024-12-08 07:42:00 +00:00
while ( $i = $q -> fetch ( PDO :: FETCH_ASSOC )) {
2007-12-10 02:50:53 +00:00
$y = $i [ 'year' ];
2009-12-16 18:43:57 +00:00
$sel = ( $config [ 'FAIRYEAR' ] == $y ) ? 'selected="selected"' : '' ;
2007-12-10 02:50:53 +00:00
echo " <option value= \" $y\ " $sel > $y </ option > " ;
}
echo " </select></td></tr> " ;
echo " </table> " ;
echo '<br />' ;
echo " <input type= \" submit \" value= \" " . i18n ( 'Generate Report' ) . " \" /> " ;
echo '</form>' ;
send_footer ();
2007-03-18 07:10:54 +00:00
?>