2005-02-25 19:16:05 +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 .
*/
?>
< ?
2009-09-09 00:26:12 +00:00
require_once ( '../common.inc.php' );
require_once ( '../user.inc.php' );
2007-11-18 23:50:23 +00:00
user_auth_required ( 'committee' , 'admin' );
2005-02-25 19:16:05 +00:00
2009-09-09 00:26:12 +00:00
switch ( $_GET [ 'action' ]) {
2009-09-10 01:23:58 +00:00
case 'awardinfo_load' :
2009-09-09 00:26:12 +00:00
$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 ;
2009-09-10 01:23:58 +00:00
case 'awardinfo_save' :
2009-09-09 17:06:11 +00:00
$id = intval ( $_GET [ 'id' ]);
$q = " UPDATE award_awards SET
name = '".mysql_escape_string(stripslashes($_GET[' name ']))."' ,
`order` = '".intval($_GET[' order '])."' ,
sponsors_id = '".intval($_GET[' sponsors_id '])."' ,
award_types_id = '".intval($_GET[' award_types_id '])."' ,
presenter = '".mysql_escape_string(stripslashes($_GET[' presenter ']))."' ,
excludefromac = '".(($_GET[' excludefromac '] == 1) ? 1 : 0)."' ,
cwsfaward = '".(($_GET[' cwsfaward '] == 1) ? 1 : 0)."' ,
self_nominate = '".(($_GET[' self_nominate '] == ' yes ') ? ' yes ' : ' no ')."' ,
schedule_judges = '".(($_GET[' schedule_judges '] == ' yes ') ? ' yes ' : ' no ')."' ,
criteria = '".mysql_escape_string(stripslashes($_GET[' criteria ']))."' ,
description = '".mysql_escape_string(stripslashes($_GET[' description ']))."'
WHERE id = '$id' " ;
echo $q ;
echo happy ( i18n ( 'Settings Saved' ));
// mysql_query($q);
/*
//whipe out any old award-category links
mysql_query ( " DELETE FROM award_awards_projectcategories WHERE award_awards_id=' $id ' " );
2009-09-09 00:26:12 +00:00
2009-09-09 17:06:11 +00:00
//now add the new ones
if ( is_array ( $_POST [ 'eligiblecategories' ]))
{
foreach ( $_POST [ 'eligiblecategories' ] AS $cat )
{
mysql_query ( " INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES (' $id ',' $cat ',' " . $config [ 'FAIRYEAR' ] . " ') " );
}
}
//whipe out any old award-divisions links
mysql_query ( " DELETE FROM award_awards_projectdivisions WHERE award_awards_id=' $id ' " );
//now add the new ones
if ( is_array ( $_POST [ 'eligibledivisions' ]))
{
foreach ( $_POST [ 'eligibledivisions' ] AS $div )
{
mysql_query ( " INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES (' $id ',' $div ',' " . $config [ 'FAIRYEAR' ] . " ') " );
}
}
2009-09-09 00:26:12 +00:00
2009-09-09 17:06:11 +00:00
if ( $_POST [ 'save' ] == " add " )
echo happy ( " Award successfully added " );
else
echo happy ( " Successfully saved changes to award " );
*/
2009-09-09 00:26:12 +00:00
exit ;
2009-09-09 17:06:11 +00:00
2009-09-10 01:23:58 +00:00
case 'eligibilty_load' :
2009-09-09 00:26:12 +00:00
$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 ;
2009-09-10 01:23:58 +00:00
case 'prize_order' :
$order = 0 ;
foreach ( $_GET [ 'prizelist' ] as $position => $id ) {
if ( $id == '' ) continue ;
$order ++ ;
mysql_query ( " UPDATE `award_prizes` SET `order`=' $order ' WHERE `id`=' $id ' " );
2009-09-09 00:26:12 +00:00
}
2009-09-10 01:23:58 +00:00
echo happy ( i18n ( " Order Updated. " ));
exit ;
case 'prizeinfo_load' :
$id = intval ( $_GET [ 'id' ]);
$q = mysql_query ( " SELECT * FROM award_prizes WHERE award_awards_id=' $id ' ORDER BY `order` " );
while ( $r = mysql_fetch_assoc ( $q )) {
$ret [] = $r ;
}
echo json_encode ( $ret );
exit ;
case 'prize_load' :
$id = intval ( $_GET [ 'id' ]);
$q = mysql_query ( " SELECT * FROM award_prizes WHERE id=' $id ' " );
$ret = mysql_fetch_assoc ( $q );
echo json_encode ( $ret );
exit ;
case 'prize_save' :
print_R ( $_GET );
$id = intval ( $_GET [ 'id' ]);
if ( $id == - 1 ) {
$aaid = intval ( $_GET [ 'award_awards_id' ]);
mysql_query ( " INSERT INTO award_prizes(award_awards_id,year) VALUES (' $aaid ',' { $config [ 'FAIRYEAR' ] } '); " );
$id = mysql_insert_id ();
echo happy ( i18n ( " Created new prize " ));
}
$q = " UPDATE award_prizes SET
prize = '".mysql_escape_string(stripslashes($_GET[' prize ']))."' ,
cash = '".intval($_GET[' cash '])."' ,
scholarship = '".intval($_GET[' scholarship '])."' ,
value = '".intval($_GET[' value '])."' ,
number = '".intval($_GET[' number '])."' ,
excludefromac = '".(($_GET[' excludefromac ']==1)? 1 : 0)."' ,
trophystudentkeeper = '".(($_GET[' trophystudentkeeper ']==1) ? 1 : 0)."' ,
trophystudentreturn = '".(($_GET[' trophystudentreturn ']==1) ? 1 : 0)."' ,
trophyschoolkeeper = '".(($_GET[' trophyschoolkeeper ']==1) ? 1 : 0)."' ,
trophyschoolreturn = '".(($_GET[' trophyschoolreturn ']==1) ? 1 : 0)."'
WHERE id = '$id' " ;
mysql_query ( $q );
2009-09-10 01:24:57 +00:00
// echo $q;
// echo mysql_error();
2009-09-10 01:23:58 +00:00
echo happy ( i18n ( " Prize saved " ));
exit ;
case 'prize_delete' :
$id = intval ( $_GET [ 'id' ]);
mysql_query ( " DELETE FROM award_prizes WHERE id=' $id ' " );
// echo "DELETE FROM award_prizes WHERE id='$id'";
echo happy ( i18n ( " Prize deleted " ));
2009-09-09 00:26:12 +00:00
exit ;
}
2007-11-23 20:23:46 +00:00
if ( $_GET [ 'action' ] == " edit " || $_GET [ 'action' ] == " add " ) {
send_header (( $_GET [ 'action' ] == " edit " ) ? " Edit Award " : " Add Award " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'Awards Main' => 'admin/awards.php' ,
'Awards Management' => 'admin/award_awards.php' ) );
} else {
send_header ( " Awards Management " ,
2007-11-18 23:50:23 +00:00
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'Awards Main' => 'admin/awards.php' ) );
2007-11-23 20:23:46 +00:00
}
2005-02-25 19:16:05 +00:00
2009-09-09 00:26:12 +00:00
if ( $_GET [ 'sponsors_id' ] && $_GET [ 'sponsors_id' ] != " all " )
$_SESSION [ 'sponsors_id' ] = $_GET [ 'sponsors_id' ];
else if ( $_GET [ 'sponsors_id' ] == " all " )
unset ( $_SESSION [ 'sponsors_id' ]);
2005-02-25 19:16:05 +00:00
2007-03-28 18:03:15 +00:00
if ( $_GET [ 'award_types_id' ] && $_GET [ 'award_types_id' ] != " all " )
$_SESSION [ 'award_types_id' ] = $_GET [ 'award_types_id' ];
2009-09-09 00:26:12 +00:00
else if ( $_GET [ 'award_types_id' ] == " all " )
unset ( $_SESSION [ 'award_types_id' ]);
2005-02-25 19:16:05 +00:00
2009-09-09 00:26:12 +00:00
/*
2008-03-20 20:37:33 +00:00
if ( $_GET [ 'award_sponsors_confirmed' ] && $_GET [ 'award_sponsors_confirmed' ] != " all " )
$_SESSION [ 'award_sponsors_confirmed' ] = $_GET [ 'award_sponsors_confirmed' ];
2009-09-09 00:26:12 +00:00
if ( $_GET [ 'sponsors_id' ] == " all " )
unset ( $_SESSION [ 'sponsors_id' ]);
2007-03-28 18:03:15 +00:00
if ( $_GET [ 'award_types_id' ] == " all " )
unset ( $_SESSION [ 'award_types_id' ]);
2008-03-20 20:37:33 +00:00
if ( $_GET [ 'award_sponsors_confirmed' ] == " all " )
unset ( $_SESSION [ 'award_sponsors_confirmed' ]);
2009-09-09 00:26:12 +00:00
*/
2005-02-25 19:16:05 +00:00
2007-03-28 18:03:15 +00:00
$award_types_id = $_SESSION [ 'award_types_id' ];
2009-09-09 00:26:12 +00:00
$sponsors_id = $_SESSION [ 'sponsors_id' ];
//$award_sponsors_confirmed=$_SESSION['award_sponsors_confirmed'];
function popup_begin ( $name , $title , $width = 0 , $height = 0 )
{
2009-09-09 17:06:11 +00:00
echo " <div id= \" popup_ $name\ " title = \ " $title\ " > " ;
2009-09-09 00:26:12 +00:00
}
function popup_end ()
{
2009-09-09 17:06:11 +00:00
echo " </div> " ;
2009-09-09 00:26:12 +00:00
}
2005-02-25 19:16:05 +00:00
2009-09-09 00:26:12 +00:00
require_once ( '../htabs.inc.php' );
?>
2009-09-10 01:23:58 +00:00
< script type = " text/javascript " src = " ../js/jquery.tablednd_0_5.js " ></ script >
2009-09-09 00:26:12 +00:00
< script type = " text/javascript " >
var award_id = 0 ;
function popup_editor ( id )
{
2009-09-09 17:06:11 +00:00
var w = ( document . documentElement . clientWidth * 0.8 );
var h = ( document . documentElement . clientHeight * 0.8 );
$ ( '#popup_editor' ) . dialog ( 'option' , 'width' , w );
$ ( '#popup_editor' ) . dialog ( 'option' , 'height' , h );
$ ( " #popup_editor " ) . dialog ( 'open' );
2009-09-09 00:26:12 +00:00
award_id = id ;
htabs_open ( " editortabs " );
}
function update_awardinfo ()
{
var id = award_id ;
// alert("id="+award_id);
2009-09-10 01:23:58 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=awardinfo_load&id= " + id ,
2009-09-09 00:26:12 +00:00
function ( json ){
2009-09-09 17:06:11 +00:00
$ ( " #awardinfo_id " ) . val ( json . id );
2009-09-09 00:26:12 +00:00
$ ( " #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 ()
{
2009-09-10 01:23:58 +00:00
$ ( " #awardinfo_info " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=awardinfo_save " , $ ( " #awardinfo " ) . serialize ());
2009-09-09 00:26:12 +00:00
return 0 ;
}
function update_eligibility ()
{
var id = award_id ;
2009-09-10 01:23:58 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=eligibilty_load&id= " + id ,
2009-09-09 00:26:12 +00:00
function ( json ){
$ ( " [name=eligiblecategories] " ) . val ( json . categories );
$ ( " [name=eligibledivisions] " ) . val ( json . divisions );
});
}
2009-09-10 01:23:58 +00:00
function update_prizeinfo ()
{
var id = award_id ;
/* This is wasteful, but it saves inlining the code below */
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prizeinfo_load&id= " + id ,
function ( json ) {
$ ( " #prizelist " ) . html ( " " );
$ ( " #prizelist " ) . append ( " <tr><th style= \" width:4em \" ><?=i18n( " Script Order " )?></th> " +
" <th><?=i18n( " # Available")?></th>"+
" <th style= \" width: 15em \" ><?=i18n( " Prize Description " )?></th> " +
" <th><?=i18n( " Cash " )?></th> " +
" <th><?=i18n( " Scholarship " )?></th> " +
" <th><?=i18n( " Value " )?></th> " +
" <th><?=i18n( " Actions " )?></th></tr> " );
for ( var i in json ) {
var p = json [ i ];
$ ( " #prizelist " ) . append ( " <tr id= \" " + p . id + " \" ><td style= \" text-align:center; \" > " + p . order + " </td> " +
" <td style= \" text-align:center; \" > " + p . number + " </td> " +
" <td> " + p . prize + " </td> " +
" <td style= \" width:4em; text-align:right; padding-left:2em; padding-right:2em; \" > " + p . cash + " </td> " +
" <td style= \" width:4em; text-align:right; padding-left:2em; padding-right:2em; \" > " + p . scholarship + " </td> " +
" <td style= \" width:4em; text-align:right; padding-left:2em; padding-right:2em; \" > " + p . value + " </td> " +
" <td style= \" text-align:center; \" > " +
" <a onclick= \" edit_prize( " + p . id + " ); \" href= \" # \" ><img border= \" 0 \" src= \" <?= $config['SFIABDIRECTORY'] ?>/images/16/edit.<?= $config['icon_extension'] ?> \" ></a> " +
" <a onclick= \" prize_delete( " + p . id + " ); \" href= \" # \" ><img border=0 src= \" <?= $config['SFIABDIRECTORY'] ?>/images/16/button_cancel.<?= $config['icon_extension'] ?> \" ></a> " +
" </td></tr> " );
}
$ ( " #prizelist " ) . tableDnD ({
onDrop : function ( table , row ) {
var order = $ . tableDnD . serialize ();
$ ( " #prizeinfo_info " ) . load ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_order& " + order );
update_prizeinfo ();
}
});
});
}
function edit_prize ( id )
{
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_load&id= " + id ,
function ( json ){
$ ( " #prizeinfo_edit_header " ) . html ( " <?=i18n( " Edit Prize " )?> " );
$ ( " #prizeinfo_id " ) . val ( json . id );
$ ( " #prizeinfo_prize " ) . val ( json . prize );
$ ( " #prizeinfo_cash " ) . val ( json . cash );
$ ( " #prizeinfo_scholarship " ) . val ( json . scholarship );
$ ( " #prizeinfo_value " ) . val ( json . value );
$ ( " #prizeinfo_number " ) . val ( json . number );
$ ( " #prizeinfo_trophystudentkeeper " ) . val ([ json . trophystudentkeeper ]);
$ ( " #prizeinfo_trophystudentreturn " ) . val ([ json . trophystudentreturn ]);
$ ( " #prizeinfo_trophyschoolreturn " ) . val ([ json . trophyschoolreturn ]);
$ ( " #prizeinfo_trophyschoolkeeper " ) . val ([ json . trophyschoolkeeper ]);
$ ( " #prizeinfo_excludefromac " ) . val ([ json . excludefromac ]);
$ ( " .prizeinfo " ) . removeAttr ( " disabled " );
$ ( " #prizeinfo_save " ) . removeAttr ( " disabled " );
});
}
function prize_save ()
{
$ ( " #prizeinfo_info " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=prize_save " , $ ( " #prizeinfo " ) . serialize ());
update_prizeinfo ();
return 0 ;
}
function prize_delete ( id )
{
var confirm = confirmClick ( 'Are you sure you want to delete this prize?' );
if ( confirm == true ) {
$ ( " #prizeinfo_info " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=prize_delete&id= " + id );
update_prizeinfo ();
}
return 0 ;
}
function prize_create ()
{
var id = award_id ;
$ ( " .prizeinfo " ) . val ( " " );
$ ( " #prizeinfo_id " ) . val ( " -1 " );
$ ( " #prizeinfo_award_awards_id " ) . val ( id );
$ ( " #prizeinfo_edit_header " ) . html ( " <?=i18n( " New Prize " )?> " );
$ ( " .prizeinfo " ) . removeAttr ( " disabled " );
$ ( " #prizeinfo_save " ) . removeAttr ( " disabled " );
}
2009-09-09 00:26:12 +00:00
// When the document is ready set up our sortable with it's inherant function(s)
$ ( document ) . ready ( function () {
2009-09-09 17:06:11 +00:00
$ ( " #popup_editor " ) . dialog ({
bgiframe : true ,
autoOpen : false ,
modal : true ,
resizable : false ,
draggable : false
});
2009-09-09 00:26:12 +00:00
});
</ script >
< ?
2009-09-09 17:06:11 +00:00
/* Begin popup */
2009-09-10 01:23:58 +00:00
echo " <div id= \" popup_editor \" title= \" Award Editor \" style= \" display: none \" > " ;
2009-09-09 00:26:12 +00:00
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' ,
2009-09-10 01:23:58 +00:00
'callback' => 'update_prizeinfo' ),
2009-09-09 00:26:12 +00:00
), 'awardinfo' );
htabs_tab_begin ( 'awardinfo' );
2009-09-10 01:23:58 +00:00
?>
< div id = " awardinfo_info " ></ div >
< form id = " awardinfo " >
< input type = " hidden " name = " id " id = " awardinfo_id " value = " 0 " />
< table class = " tableedit " >
< 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 >
< 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 >
< tr >< td class = " left " >< ? = i18n ( " Sponsor " ) ?> :</td><td class="right">
< ?
2009-09-09 00:26:12 +00:00
$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 > " ;
}
2009-09-10 01:23:58 +00:00
?>
</ select ></ td ></ tr >
< 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 >
< tr >< td class = " left " >< ? = i18n ( " Type " ) ?> :</td><td class="right">
< ?
2009-09-09 00:26:12 +00:00
$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' );
?>
2009-09-10 01:23:58 +00:00
< br />
< div id = " prizeinfo_info " ></ div >
< table id = " prizelist " class = " tableview " > </ table >
< br >
* < ? = i18n ( " Click on the Script Order and drag to re-order the prizes " ) ?>
< br >
< hr >
< br />< h2 id = " prizeinfo_edit_header " > Click on a prize to edit </ h2 >< br />
< form id = " prizeinfo " >
< input type = " hidden " id = " prizeinfo_id " name = " id " value = " " />
< input type = " hidden " id = " prizeinfo_award_awards_id " name = " award_awards_id " value = " " />
2009-09-09 17:06:11 +00:00
< table class = " tableedit " >
< tr > < td class = " left " >< ? = i18n ( " Prize Description " ) ?> :</td>
2009-09-10 01:23:58 +00:00
< td class = " right " >< input type = " text " id = " prizeinfo_prize " class = " prizeinfo " name = " prize " value = " " size = " 40 " maxlength = " 128 " disabled = " disabled " />< script type = " text/javascript " > translateButton ( 'prize' ); </ script ></ td >
2009-09-09 17:06:11 +00:00
</ tr >< tr >
< td class = " left " >< ? = i18n ( " Cash Amount " ) ?> ($):</td>
2009-09-10 01:23:58 +00:00
< td class = " right " >< input type = " text " id = " prizeinfo_cash " class = " prizeinfo " name = " cash " value = " " size = " 10 " maxlength = " 10 " disabled = " disabled " /></ td >
2009-09-09 17:06:11 +00:00
</ tr >< tr >
< td class = " left " >< ? = i18n ( " Scholarship Amount " ) ?> ($):</td>
2009-09-10 01:23:58 +00:00
< td class = " right " >< input type = " text " id = " prizeinfo_scholarship " class = " prizeinfo " name = " scholarship " value = " " size = " 10 " maxlength = " 10 " disabled = " disabled " /></ td >
2009-09-09 17:06:11 +00:00
</ tr >< tr >
< td class = " left " >< ? = i18n ( " Prize Value " ) ?> ($):</td>
2009-09-10 01:23:58 +00:00
< td class = " right " >< input type = " text " id = " prizeinfo_value " class = " prizeinfo " name = " value " value = " " size = " 10 " maxlength = " 10 " disabled = " disabled " /></ td >
2009-09-09 17:06:11 +00:00
</ tr >< tr >
< td class = " left " >< ? = i18n ( " Number available " ) ?> :</td>
2009-09-10 01:23:58 +00:00
< td class = " right " >< input type = " text " id = " prizeinfo_number " class = " prizeinfo " name = " number " value = " " size = " 3 " maxlength = " 5 " disabled = " disabled " /></ td >
2009-09-09 17:06:11 +00:00
</ tr >< tr >
< td class = " left " valign = " top " >< ? = i18n ( " Plaque/Trophy " ) ?> :</td>
< td class = " right " >
< table class = " tableedit " cols = " 4 " >
2009-09-10 01:23:58 +00:00
< tr > < td align = " right " >< input type = " checkbox " id = " prizeinfo_trophystudentkeeper " class = " prizeinfo " name = " trophystudentkeeper " value = " 1 " disabled = " disabled " ></ td >
2009-09-09 17:06:11 +00:00
< td >< ? = i18n ( " Student(s) keeper trophy " ) ?> </td>
2009-09-10 01:23:58 +00:00
< td align = " right " >< input type = " checkbox " id = " prizeinfo_trophystudentreturn " class = " prizeinfo " name = " trophystudentreturn " value = " 1 " disabled = " disabled " ></ td >
2009-09-09 17:06:11 +00:00
< td >< ? = i18n ( " Student(s) annual return/reuse trophy " ) ?> </td>
</ tr >< tr >
2009-09-10 01:23:58 +00:00
< td align = " right " >< input type = " checkbox " id = " prizeinfo_trophyschoolkeeper " class = " prizeinfo " name = " trophyschoolkeeper " value = " 1 " disabled = " disabled " ></ td >
2009-09-09 17:06:11 +00:00
< td >< ? = i18n ( " School keeper trophy " ) ?> </td>
2009-09-10 01:23:58 +00:00
< td align = " right " >< input type = " checkbox " id = " prizeinfo_trophyschoolreturn " class = " prizeinfo " name = " trophyschoolreturn " value = " 1 " disabled = " disabled " ></ td >
2009-09-09 17:06:11 +00:00
< td >< ? = i18n ( " School annual return/reuse trophy " ) ?> </td>
</ tr ></ table ></ td >
</ tr >< tr >
< td class = " left " >< ? = i18n ( " Awards Ceremony " ) ?> :</td>
2009-09-10 01:23:58 +00:00
< td class = " right " >< input type = " checkbox " id = " prizeinfo_excludefromac " class = " prizeinfo " name = " excludefromac " value = " 1 " disabled = " disabled " >< ? = i18n ( " Exclude this prize from the award ceremony script " ) ?> </td>
2009-09-09 17:06:11 +00:00
</ tr >
</ table >
2009-09-10 01:23:58 +00:00
</ form >
< br />
< input type = " submit " onClick = " prize_create(); " value = " <?=i18n( " Create New Prize " )?> " />
< input type = " submit " id = " prizeinfo_save " onClick = " prize_save(); " value = " <?=i18n( " Save Prize " )?> " disabled = " disabled " />
2009-09-09 17:06:11 +00:00
2009-09-09 00:26:12 +00:00
< ?
htabs_tab_end ();
htabs_end ();
2009-09-09 17:06:11 +00:00
/* End popup */
echo '</div>' ;
2009-09-09 00:26:12 +00:00
if ( $_POST [ 'save' ] == " edit " || $_POST [ 'save' ] == " add " )
{
2005-03-04 03:40:03 +00:00
if ( ! $_POST [ 'award_types_id' ]) {
echo error ( i18n ( " Award Type is required " ));
$_GET [ 'action' ] = $_POST [ 'save' ];
}
2009-09-09 00:26:12 +00:00
else if ( ! $_POST [ 'sponsors_id' ]) {
2005-03-04 03:40:03 +00:00
echo error ( i18n ( " Award Sponsor is required " ));
$_GET [ 'action' ] = $_POST [ 'save' ];
2005-02-25 19:16:05 +00:00
}
else
2005-03-04 03:40:03 +00:00
{
2005-02-25 19:16:05 +00:00
2005-03-04 03:40:03 +00:00
if ( $_POST [ 'save' ] == " add " )
{
2009-09-09 00:26:12 +00:00
$q = mysql_query ( " INSERT INTO award_awards (sponsors_id,award_types_id,year) VALUES (' " . $_POST [ 'sponsors_id' ] . " ',' " . $_POST [ 'award_types_id' ] . " ',' " . $config [ 'FAIRYEAR' ] . " ') " );
2005-03-04 03:40:03 +00:00
$id = mysql_insert_id ();
}
else
$id = $_POST [ 'id' ];
2005-02-25 19:16:05 +00:00
2008-01-24 07:46:12 +00:00
$self_nominate = ( $_POST [ 'self_nominate' ] == 'yes' ) ? 'yes' : 'no' ;
$schedule_judges = ( $_POST [ 'schedule_judges' ] == 'yes' ) ? 'yes' : 'no' ;
2005-03-04 03:40:03 +00:00
$exec = " UPDATE award_awards SET " .
" name=' " . mysql_escape_string ( stripslashes ( $_POST [ 'name' ])) . " ', " .
" `order`=' " . mysql_escape_string ( stripslashes ( $_POST [ 'order' ])) . " ', " .
2009-09-09 00:26:12 +00:00
" sponsors_id=' " . mysql_escape_string ( stripslashes ( $_POST [ 'sponsors_id' ])) . " ', " .
2005-03-04 03:40:03 +00:00
" award_types_id=' " . mysql_escape_string ( stripslashes ( $_POST [ 'award_types_id' ])) . " ', " .
2005-04-26 18:59:38 +00:00
" presenter=' " . mysql_escape_string ( stripslashes ( $_POST [ 'presenter' ])) . " ', " .
2006-02-01 05:06:48 +00:00
" excludefromac=' " . mysql_escape_string ( stripslashes ( $_POST [ 'excludefromac' ])) . " ', " .
2006-10-19 21:39:30 +00:00
" cwsfaward=' " . mysql_escape_string ( stripslashes ( $_POST [ 'cwsfaward' ])) . " ', " .
2008-01-24 07:46:12 +00:00
" self_nominate=' $self_nominate ', " .
" schedule_judges=' $schedule_judges ', " .
2007-11-23 21:21:37 +00:00
" criteria=' " . mysql_escape_string ( stripslashes ( $_POST [ 'criteria' ])) . " ', " .
" description=' " . mysql_escape_string ( stripslashes ( $_POST [ 'description' ])) . " ' " .
2005-03-04 03:40:03 +00:00
" WHERE id=' $id ' " ;
2005-02-25 19:16:05 +00:00
2005-03-04 03:40:03 +00:00
mysql_query ( $exec );
echo mysql_error ();
2005-02-25 19:16:05 +00:00
2005-03-04 03:40:03 +00:00
//whipe out any old award-category links
mysql_query ( " DELETE FROM award_awards_projectcategories WHERE award_awards_id=' $id ' " );
//now add the new ones
if ( is_array ( $_POST [ 'eligiblecategories' ]))
2005-02-25 19:16:05 +00:00
{
2005-03-04 03:40:03 +00:00
foreach ( $_POST [ 'eligiblecategories' ] AS $cat )
{
mysql_query ( " INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES (' $id ',' $cat ',' " . $config [ 'FAIRYEAR' ] . " ') " );
}
2005-02-25 19:16:05 +00:00
}
2005-03-04 03:40:03 +00:00
//whipe out any old award-divisions links
mysql_query ( " DELETE FROM award_awards_projectdivisions WHERE award_awards_id=' $id ' " );
2005-02-25 19:16:05 +00:00
2005-03-04 03:40:03 +00:00
//now add the new ones
if ( is_array ( $_POST [ 'eligibledivisions' ]))
2005-02-25 19:16:05 +00:00
{
2005-03-04 03:40:03 +00:00
foreach ( $_POST [ 'eligibledivisions' ] AS $div )
{
mysql_query ( " INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES (' $id ',' $div ',' " . $config [ 'FAIRYEAR' ] . " ') " );
}
2005-02-25 19:16:05 +00:00
}
2005-03-04 03:40:03 +00:00
if ( $_POST [ 'save' ] == " add " )
echo happy ( " Award successfully added " );
else
echo happy ( " Successfully saved changes to award " );
}
2005-02-25 19:16:05 +00:00
}
if ( $_POST [ 'action' ] == " reorder " )
{
if ( is_array ( $_POST [ 'reorder' ]))
{
foreach ( $_POST [ 'reorder' ] AS $key => $val )
{
mysql_query ( " UPDATE award_awards SET `order`=' $val ' WHERE id=' $key ' " );
}
echo happy ( " Awards successfully reordered " );
}
}
if ( $_GET [ 'action' ] == " delete " && $_GET [ 'delete' ])
{
mysql_query ( " DELETE FROM award_awards WHERE id=' " . $_GET [ 'delete' ] . " ' " );
echo happy ( " Award successfully deleted " );
}
2005-03-04 03:40:03 +00:00
if ( $_GET [ 'action' ] == " edit " || $_GET [ 'action' ] == " add " )
2005-02-25 19:16:05 +00:00
{
2005-03-04 03:40:03 +00:00
//define these here so we dont forget :)
$currentcategories = array ();
$currentdivisions = array ();
2005-02-25 19:16:05 +00:00
if ( $_GET [ 'action' ] == " edit " )
{
$buttontext = " Save Award " ;
$q = mysql_query ( " SELECT
award_awards . id ,
award_awards . name ,
award_awards . criteria ,
2007-11-23 21:21:37 +00:00
award_awards . description ,
2005-02-25 19:16:05 +00:00
award_awards . order ,
2005-04-26 18:59:38 +00:00
award_awards . presenter ,
2006-02-01 05:06:48 +00:00
award_awards . excludefromac ,
2006-10-19 21:39:30 +00:00
award_awards . cwsfaward ,
2008-01-24 07:46:12 +00:00
award_awards . self_nominate ,
award_awards . schedule_judges ,
2005-02-25 19:16:05 +00:00
award_types . id AS award_types_id ,
award_types . type ,
2009-09-09 00:26:12 +00:00
sponsors . id AS sponsors_id ,
sponsors . organization
2005-02-25 19:16:05 +00:00
FROM
award_awards ,
award_types ,
2009-09-09 00:26:12 +00:00
sponsors
2005-02-25 19:16:05 +00:00
WHERE
award_awards . year = '".$config[' FAIRYEAR ']."'
AND award_awards . id = '".$_GET[' edit ']."'
2009-09-09 00:26:12 +00:00
AND award_awards . sponsors_id = sponsors . id
2005-02-25 19:16:05 +00:00
AND award_awards . award_types_id = award_types . id
" );
echo mysql_error ();
$r = mysql_fetch_object ( $q );
2005-03-04 03:40:03 +00:00
$award_awards_id = $r -> id ;
$award_awards_name = $r -> name ;
$award_awards_order = $r -> order ;
$award_awards_criteria = $r -> criteria ;
2007-11-23 21:21:37 +00:00
$award_awards_description = $r -> description ;
2005-03-04 03:40:03 +00:00
$award_types_id = $r -> award_types_id ;
$award_type = $r -> type ;
2009-09-09 00:26:12 +00:00
$sponsors_id = $r -> sponsors_id ;
2005-03-04 03:40:03 +00:00
$award_sponsor = $r -> organization ;
2005-04-26 18:59:38 +00:00
$award_awards_presenter = $r -> presenter ;
2006-02-01 05:06:48 +00:00
$award_awards_excludefromac = $r -> excludefromac ;
2006-10-19 21:39:30 +00:00
$award_awards_cwsfaward = $r -> cwsfaward ;
2008-01-24 07:46:12 +00:00
$award_awards_self_nominate = $r -> self_nominate ;
$award_awards_schedule_judges = $r -> schedule_judges ;
2005-03-04 03:40:03 +00:00
//select the current categories that this award is linked to
$ccq = mysql_query ( " SELECT * FROM award_awards_projectcategories WHERE award_awards_id=' $r->id ' " );
while ( $ccr = mysql_fetch_object ( $ccq ))
$currentcategories [] = $ccr -> projectcategories_id ;
//select the current categories that this award is linked to
$cdq = mysql_query ( " SELECT * FROM award_awards_projectdivisions WHERE award_awards_id=' $r->id ' " );
while ( $cdr = mysql_fetch_object ( $cdq ))
$currentdivisions [] = $cdr -> projectdivisions_id ;
2005-02-25 19:16:05 +00:00
}
2005-03-04 03:40:03 +00:00
else if ( $_GET [ 'action' ] == " add " )
2005-02-25 19:16:05 +00:00
{
$buttontext = " Add Award " ;
$firstsponsor = " <option value= \" \" > " . i18n ( " Choose a sponsor " ) . " </option> \n " ;
$firsttype = " <option value= \" \" > " . i18n ( " Choose an award type " ) . " </option> \n " ;
2008-01-24 07:46:12 +00:00
/* We want these two on by default for new
* awards */
$award_awards_self_nominate = 'yes' ;
$award_awards_schedule_judges = 'yes' ;
2005-02-25 19:16:05 +00:00
}
$buttontext = i18n ( $buttontext );
2005-03-04 03:40:03 +00:00
//if we have POST values, then they should be used instead of the db values
//esp for adding, if there is an error then the POST values will be redisplayed
if ( $_POST [ 'name' ]) $award_awards_name = $_POST [ 'name' ];
if ( $_POST [ 'order' ]) $award_awards_order = $_POST [ 'order' ];
if ( $_POST [ 'criteria' ]) $award_awards_criteria = $_POST [ 'criteria' ];
2007-11-23 21:21:37 +00:00
if ( $_POST [ 'description' ]) $award_awards_criteria = $_POST [ 'description' ];
2005-03-04 03:40:03 +00:00
if ( $_POST [ 'award_types_id' ]) $award_types_id = $_POST [ 'award_types_id' ];
2009-09-09 00:26:12 +00:00
if ( $_POST [ 'sponsors_id' ]) $sponsors_id = $_POST [ 'sponsors_id' ];
2005-03-04 03:40:03 +00:00
if ( $_POST [ 'eligiblecategories' ]) $currentcategories = $_POST [ 'eligiblecategories' ];
if ( $_POST [ 'eligibledivisions' ]) $currentdivisions = $_POST [ 'eligibledivisions' ];
2005-04-26 18:59:38 +00:00
if ( $_POST [ 'presenter' ]) $award_awards_presenter = $_POST [ 'presenter' ];
2006-02-01 05:06:48 +00:00
if ( $_POST [ 'excludefromac' ]) $award_awards_excludefromac = $_POST [ 'excludefromac' ];
2006-10-19 21:39:30 +00:00
if ( $_POST [ 'cwsfaward' ]) $award_awards_cwsfaward = $_POST [ 'cwsfaward' ];
2008-01-24 07:46:12 +00:00
if ( $_POST [ 'self_nominate' ]) $award_awards_self_nominate = $_POST [ 'self_nominate' ];
if ( $_POST [ 'schedule_judges' ]) $award_awards_schedule_judges = $_POST [ 'schedule_judges' ];
2005-03-04 03:40:03 +00:00
2005-02-25 19:16:05 +00:00
echo " <form method= \" post \" action= \" award_awards.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 " ;
2007-03-28 22:32:57 +00:00
echo " <table class= \" tableedit \" > \n " ;
2009-09-09 17:06:11 +00:00
// 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";
2005-03-04 03:40:03 +00:00
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 " ;
2005-02-25 19:16:05 +00:00
echo " <tr><td> " . i18n ( " Sponsor " ) . " </td><td> " ;
2009-09-09 00:26:12 +00:00
$sq = mysql_query ( " SELECT id,organization FROM sponsors ORDER BY organization " );
echo " <select name= \" sponsors_id \" > " ;
2005-02-25 19:16:05 +00:00
//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 ))
{
2009-09-09 00:26:12 +00:00
if ( $sr -> id == $sponsors_id )
2005-02-25 19:16:05 +00:00
$sel = " selected= \" selected \" " ;
else
$sel = " " ;
echo " <option $sel value= \" $sr->id\ " > " .i18n( $sr->organization ). " </ option > " ;
}
echo " </select> " ;
echo " </td></tr> " ;
2005-04-26 18:59:38 +00:00
echo " <tr><td> " . i18n ( " Presenter " ) . " </td><td><input type= \" text \" name= \" presenter \" value= \" " . htmlspecialchars ( $award_awards_presenter ) . " \" size= \" 50 \" maxlength= \" 128 \" /></td></tr> \n " ;
2005-02-25 19:16:05 +00:00
echo " <tr><td> " . i18n ( " Type " ) . " </td><td> " ;
2006-01-03 02:01:20 +00:00
$tq = mysql_query ( " SELECT id,type FROM award_types WHERE year=' { $config [ 'FAIRYEAR' ] } ' ORDER BY type " );
2005-02-25 19:16:05 +00:00
echo " <select 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 ))
{
2005-03-04 03:40:03 +00:00
if ( $tr -> id == $award_types_id )
2005-02-25 19:16:05 +00:00
$sel = " selected= \" selected \" " ;
else
$sel = " " ;
echo " <option $sel value= \" $tr->id\ " > " .i18n( $tr->type ). " </ option > " ;
}
echo " </select> " ;
echo " </td></tr> " ;
2009-09-09 17:06:11 +00:00
// echo "<tr><td>".i18n("Criteria")."</td><td><textarea id=\"criteria\" name=\"criteria\" rows=\"3\" cols=\"50\">".htmlspecialchars($award_awards_criteria)."</textarea><script type=\"text/javascript\">translateButton('criteria');</script></td></tr>\n";
// echo "<tr><td>".i18n("Description")."</td><td><textarea id=\"description\" name=\"description\" rows=\"3\" cols=\"50\">".htmlspecialchars($award_awards_description)."</textarea><script type=\"text/javascript\">translateButton('description');</script></td></tr>\n";
2005-02-25 19:16:05 +00:00
echo " <tr><td> " . i18n ( " Eligibility " ) . " </td><td> " ;
2008-03-27 08:06:14 +00:00
2005-02-25 19:16:05 +00:00
echo " <table> " ;
echo " <tr> " ;
echo " <th> " . i18n ( " Age Categories " ) . " </th> " ;
echo " <th> " . i18n ( " Divisions " ) . " </th> " ;
echo " </tr> " ;
2008-03-27 08:06:14 +00:00
if ( count ( $currentcategories ) == 0 ) $class = " class= \" error \" " ; else $class = " " ;
echo " <tr><td $class > " ;
2005-02-25 19:16:05 +00:00
//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 ))
{
if ( in_array ( $cr -> id , $currentcategories ))
$ch = " checked= \" checked \" " ;
else
$ch = " " ;
echo " <input $ch type= \" checkbox \" name= \" eligiblecategories[] \" value= \" $cr->id\ " /> " .i18n( $cr->category ). " < br /> " ;
}
echo " </td> " ;
2008-03-27 08:06:14 +00:00
if ( count ( $currentdivisions ) == 0 ) $class = " class= \" error \" " ; else $class = " " ;
echo " <td $class > " ;
2005-02-25 19:16:05 +00:00
$dq = mysql_query ( " SELECT * FROM projectdivisions WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY division " );
echo mysql_error ();
while ( $dr = mysql_fetch_object ( $dq ))
{
if ( in_array ( $dr -> id , $currentdivisions ))
$ch = " checked= \" checked \" " ;
else
$ch = " " ;
echo " <input $ch type= \" checkbox \" name= \" eligibledivisions[] \" value= \" $dr->id\ " /> " .i18n( $dr->division ). " < br /> " ;
}
echo " </td> " ;
echo " </tr> " ;
2008-03-27 08:06:14 +00:00
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> " ;
2005-02-25 19:16:05 +00:00
echo " </table> " ;
2008-03-27 08:06:14 +00:00
2005-02-25 19:16:05 +00:00
echo " </td></tr> " ;
2006-02-01 05:06:48 +00:00
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> " ;
2006-10-19 21:39:30 +00:00
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> " ;
2008-01-24 07:46:12 +00:00
echo " <tr><td align= \" right \" > " ;
$ch = ( $award_awards_self_nominate == 'yes' ) ? " checked= \" checked \" " : '' ;
echo " <input $ch type= \" checkbox \" name= \" self_nominate \" value= \" yes \" ></td><td> " . i18n ( " Students can self-nominate for this award (this is usually checked for special awards) " ) . " </td></tr> " ;
echo " <tr><td align= \" right \" > " ;
$ch = ( $award_awards_schedule_judges == 'yes' ) ? " checked= \" checked \" " : '' ;
echo " <input $ch type= \" checkbox \" name= \" schedule_judges \" value= \" yes \" ></td><td> " . i18n ( " Allow the Automatic Judge Scheduler to assign judges to this award (usually checked) " ) . " </td></tr> " ;
2006-02-01 05:06:48 +00:00
2005-02-25 19:16:05 +00:00
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 i18n ( " Filter By: " );
echo " <form method= \" get \" action= \" award_awards.php \" name= \" filterchange \" > " ;
2008-03-20 20:37:33 +00:00
echo " <table><tr><td colspan= \" 2 \" > " ;
2005-02-25 19:16:05 +00:00
2009-09-09 00:26:12 +00:00
$q = mysql_query ( " SELECT id,organization FROM sponsors ORDER BY organization " );
echo " <select name= \" sponsors_id \" onchange= \" document.forms.filterchange.submit() \" > " ;
2007-03-28 18:03:15 +00:00
echo " <option value= \" all \" > " . i18n ( " All Sponsors " ) . " </option> " ;
2005-02-25 19:16:05 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
2009-09-09 00:26:12 +00:00
if ( $r -> id == $sponsors_id )
2005-02-25 19:16:05 +00:00
{
$sel = " selected= \" selected \" " ;
2009-09-09 00:26:12 +00:00
$sponsors_organization = $r -> organization ;
2005-02-25 19:16:05 +00:00
}
else
$sel = " " ;
echo " <option $sel value= \" $r->id\ " > " .i18n( $r->organization ). " </ option > " ;
}
echo " </select> " ;
2008-03-20 20:37:33 +00:00
echo " </td></tr> " ;
echo " <tr><td> " ;
2005-02-25 19:16:05 +00:00
2006-01-03 02:01:20 +00:00
$q = mysql_query ( " SELECT id,type FROM award_types WHERE year=' { $config [ 'FAIRYEAR' ] } ' ORDER BY type " );
2005-02-25 19:16:05 +00:00
echo " <select name= \" award_types_id \" onchange= \" document.forms.filterchange.submit() \" > " ;
2007-03-28 18:03:15 +00:00
echo " <option value= \" all \" > " . i18n ( " All Award Types " ) . " </option> " ;
2005-02-25 19:16:05 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
if ( $r -> id == $award_types_id )
{
$sel = " selected= \" selected \" " ;
$award_types_type = $r -> type ;
}
else
$sel = " " ;
echo " <option $sel value= \" $r->id\ " > " .i18n( $r->type ). " </ option > " ;
}
echo " </select> " ;
2008-03-20 20:37:33 +00:00
echo " </td><td> " ;
2009-09-09 00:26:12 +00:00
/*
//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..
2008-03-20 20:37:33 +00:00
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> " ;
if ( $award_sponsors_confirmed == " yes " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" yes \" > " . i18n ( " Confirmed Only " ) . " </option> " ;
if ( $award_sponsors_confirmed == " no " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" no \" > " . i18n ( " Unconfirmed Only " ) . " </option> " ;
echo " </select> " ;
2009-09-09 00:26:12 +00:00
*/
2005-02-25 19:16:05 +00:00
echo " </form> " ;
echo " </td></tr> " ;
echo " </table> " ;
echo " <br /> " ;
2009-09-09 00:26:12 +00:00
echo " <a href= \" award_awards.php?sponsors_id= $sponsors_id &award_types_id= $award_types_id &action=add \" > " . i18n ( " Add New Award " ) . " </a> \n " ;
2005-02-25 19:16:05 +00:00
echo " <br /> " ;
2009-09-09 00:26:12 +00:00
if ( $sponsors_id ) $where_asi = " AND sponsors_id=' $sponsors_id ' " ;
2005-02-25 19:16:05 +00:00
if ( $award_types_id ) $where_ati = " AND award_types_id=' $award_types_id ' " ;
2009-09-09 00:26:12 +00:00
// if($award_sponsors_confirmed) $where_asc="AND award_sponsors.confirmed='$award_sponsors_confirmed'";
2005-02-25 19:16:05 +00:00
if ( ! $orderby ) $orderby = " order " ;
$q = mysql_query ( " SELECT
award_awards . id ,
award_awards . name ,
award_awards . order ,
2009-09-09 00:26:12 +00:00
award_awards . award_source_fairs_id ,
2005-02-25 19:16:05 +00:00
award_types . type ,
2009-09-09 00:26:12 +00:00
sponsors . organization
2005-02-25 19:16:05 +00:00
FROM
award_awards ,
award_types ,
2009-09-09 00:26:12 +00:00
sponsors
2005-02-25 19:16:05 +00:00
WHERE
award_awards . year = '".$config[' FAIRYEAR ']."'
$where_asi
$where_ati
2008-03-20 20:37:33 +00:00
$where_asc
2009-09-09 00:26:12 +00:00
AND award_awards . sponsors_id = sponsors . id
2005-02-25 19:16:05 +00:00
AND award_awards . award_types_id = award_types . id
2006-01-03 02:01:20 +00:00
AND award_types . year = '".$config[' FAIRYEAR ']."'
2005-02-25 19:16:05 +00:00
ORDER BY `$orderby` " );
echo mysql_error ();
if ( mysql_num_rows ( $q ))
{
echo " <form method= \" post \" action= \" award_awards.php \" > " ;
echo " <input type= \" hidden \" name= \" action \" value= \" reorder \" > " ;
2007-03-28 22:32:57 +00:00
echo " <table class= \" tableview \" > " ;
2005-02-25 19:16:05 +00:00
echo " <tr> " ;
echo " <th> " . i18n ( " Order " ) . " </th> " ;
echo " <th> " . i18n ( " Sponsor " ) . " </th> " ;
echo " <th> " . i18n ( " Type " ) . " </th> " ;
echo " <th> " . i18n ( " Name " ) . " </th> " ;
2007-12-06 04:10:09 +00:00
echo " <th> " . i18n ( " Prizes " ) . " </th> " ;
2005-02-25 19:16:05 +00:00
echo " <th> " . i18n ( " Actions " ) . " </th> " ;
echo " </tr> \n " ;
2007-11-28 21:55:14 +00:00
$hasexternal = false ;
2005-02-25 19:16:05 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
2009-09-09 00:26:12 +00:00
if ( $r -> award_source_fairs_id ){ $cl = " class= \" externalaward \" " ; $hasexternal = true ; } else $cl = " " ;
2007-11-28 21:55:14 +00:00
echo " <tr $cl > \n " ;
2005-02-25 19:16:05 +00:00
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 " ;
2009-09-09 00:26:12 +00:00
echo " <td><a onclick= \" popup_editor( { $r -> id } ); \" > $r->name </a></td> \n " ;
2005-02-25 19:16:05 +00:00
$numq = mysql_query ( " SELECT COUNT(id) AS num FROM award_prizes WHERE award_awards_id=' $r->id ' " );
$numr = mysql_fetch_object ( $numq );
$numprizes = $numr -> num ;
echo " <td align= \" center \" valign= \" top \" > " ;
echo " $numprizes " ;
echo " <a href= \" award_prizes.php?award_awards_id= $r->id\ " >< img alt = \ " view \" border= \" 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/viewmag. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " </td> " ;
echo " <td align= \" center \" > " ;
2005-03-04 03:40:03 +00:00
echo " <a href= \" award_awards.php?action=edit&edit= $r->id\ " >< img border = \ " 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" ></a> " ;
2005-02-25 19:16:05 +00:00
echo " " ;
2005-03-04 03:40:03 +00:00
echo " <a onclick= \" return confirmClick('Are you sure you want to remove this award?') \" href= \" award_awards.php?action=delete&delete= $r->id\ " >< img border = 0 src = \ " " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
2005-02-25 19:16:05 +00:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2007-11-28 21:55:14 +00:00
if ( $hasexternal )
echo " <tr class= \" externalaward \" ><td colspan= \" 6 \" > " . i18n ( " Indicates award imported from an external source " ) . " </td></tr> " ;
2005-02-25 19:16:05 +00:00
echo " </table> \n " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Re-order awards " ) . " \" /> " ;
echo " </form> " ;
}
2006-01-03 02:01:20 +00:00
echo " <br /> " ;
echo " <a href= \" award_prizes.php?award_awards_id=-1 \" >Edit prizes for the generic prize template</a> " ;
2005-02-25 19:16:05 +00:00
}
send_footer ();
?>