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' ]);
2009-09-10 08:29:16 +00:00
$q = mysql_query ( " SELECT * FROM award_awards WHERE id=' $id ' " );
$ret = mysql_fetch_assoc ( $q );
echo json_encode ( $ret );
exit ;
2009-09-13 07:08:12 +00:00
case 'award_create' :
2009-09-10 08:29:16 +00:00
$q = mysql_query ( " INSERT INTO award_awards (year,self_nominate,schedule_judges)
VALUES ( '{$config[' FAIRYEAR ']}' , 'yes' , 'yes' ) " );
$ret = array ( 'id' => mysql_insert_id () );
2009-09-09 00:26:12 +00:00
echo json_encode ( $ret );
exit ;
2009-09-10 08:29:16 +00:00
case 'award_delete' :
$id = intval ( $_GET [ 'id' ]);
mysql_query ( " DELETE FROM award_prizes WHERE award_awards_id=' $id ' " );
mysql_query ( " DELETE FROM award_awards_projectcategories WHERE award_awards_id=' $id ' " );
mysql_query ( " DELETE FROM award_awards_projectdivisions WHERE award_awards_id=' $id ' " );
mysql_query ( " DELETE FROM award_awards WHERE id=' $id ' " );
exit ;
2009-09-10 01:23:58 +00:00
case 'awardinfo_save' :
2009-09-10 08:29:16 +00:00
/* Scrub the data while we save it */
2009-09-11 06:12:17 +00:00
$id = intval ( $_POST [ 'id' ]);
2009-09-10 08:29:16 +00:00
2009-09-09 17:06:11 +00:00
$q = " UPDATE award_awards SET
2009-09-11 06:12:17 +00:00
name = '".mysql_escape_string(stripslashes($_POST[' name ']))."' ,
sponsors_id = '".intval($_POST[' sponsors_id '])."' ,
award_types_id = '".intval($_POST[' award_types_id '])."' ,
presenter = '".mysql_escape_string(stripslashes($_POST[' presenter ']))."' ,
excludefromac = '".(($_POST[' excludefromac '] == 1) ? 1 : 0)."' ,
cwsfaward = '".(($_POST[' cwsfaward '] == 1) ? 1 : 0)."' ,
self_nominate = '".(($_POST[' self_nominate '] == ' yes ') ? ' yes ' : ' no ')."' ,
schedule_judges = '".(($_POST[' schedule_judges '] == ' yes ') ? ' yes ' : ' no ')."' ,
criteria = '".mysql_escape_string(stripslashes($_POST[' criteria ']))."' ,
description = '".mysql_escape_string(stripslashes($_POST[' description ']))."'
2009-09-09 17:06:11 +00:00
WHERE id = '$id' " ;
2009-09-13 19:25:03 +00:00
happy_ ( " Award Information Saved. " );
2009-09-10 08:29:16 +00:00
mysql_query ( $q );
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 08:29:16 +00:00
case 'eligibility_save' :
2009-09-11 06:12:17 +00:00
$id = intval ( $_POST [ 'id' ]);
2009-09-10 08:29:16 +00:00
//now add the new ones
2009-09-11 06:12:17 +00:00
if ( ! is_array ( $_POST [ 'categories' ]) || ! is_array ( $_POST [ 'divisions' ])) {
2009-09-10 08:29:16 +00:00
echo error ( i18n ( " Invalid data " ));
exit ;
}
//wipe out any old award-category links
mysql_query ( " DELETE FROM award_awards_projectcategories WHERE award_awards_id=' $id ' " );
2009-09-11 06:12:17 +00:00
foreach ( $_POST [ 'categories' ] AS $key => $cat ) {
2009-09-17 05:53:47 +00:00
$c = intval ( $cat );
2009-09-10 08:29:16 +00:00
mysql_query ( " INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year)
2009-09-17 05:53:47 +00:00
VALUES ( '$id' , '$c' , '{$config[' FAIRYEAR ']}' ) " );
2009-09-10 08:29:16 +00:00
}
//wipe out any old award-divisions links
mysql_query ( " DELETE FROM award_awards_projectdivisions WHERE award_awards_id=' $id ' " );
//now add the new ones
2009-09-11 06:12:17 +00:00
foreach ( $_POST [ 'divisions' ] AS $key => $div ) {
2009-09-17 05:53:47 +00:00
$d = intval ( $div );
2009-09-10 08:29:16 +00:00
mysql_query ( " INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year)
2009-09-17 05:53:47 +00:00
VALUES ( '$id' , '$d' , '{$config[' FAIRYEAR ']}' ) " );
2009-09-10 08:29:16 +00:00
}
2009-09-13 19:25:03 +00:00
happy_ ( " Saved. " );
2009-09-10 08:29:16 +00:00
exit ;
2009-09-10 01:23:58 +00:00
case 'prize_order' :
$order = 0 ;
foreach ( $_GET [ 'prizelist' ] as $position => $id ) {
if ( $id == '' ) continue ;
$order ++ ;
2009-09-10 08:29:16 +00:00
mysql_query ( " UPDATE `award_prizes` SET `order`=' $order ' WHERE `id`=' $id ' " );
}
// print_r($_GET);
2009-09-13 19:25:03 +00:00
happy_ ( " Order Updated. " );
2009-09-10 08:29:16 +00:00
exit ;
case 'award_order' :
$order = 0 ;
foreach ( $_GET [ 'awardlist' ] as $position => $id ) {
if ( $id == '' ) continue ;
$order ++ ;
mysql_query ( " UPDATE `award_awards` SET `order`=' $order ' WHERE `id`=' $id ' " );
2009-09-09 00:26:12 +00:00
}
2009-09-13 19:25:03 +00:00
happy_ ( " Order Updated. " );
2009-09-10 01:23:58 +00:00
exit ;
case 'prizeinfo_load' :
$id = intval ( $_GET [ 'id' ]);
2009-09-10 17:32:16 +00:00
if ( $id == - 1 ) {
$q = mysql_query ( " SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order` " );
} else {
$q = mysql_query ( " SELECT * FROM award_prizes WHERE award_awards_id=' $id ' ORDER BY `order` " );
}
2009-09-10 01:23:58 +00:00
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 ;
2009-09-10 17:32:16 +00:00
case 'prize_create' :
$aaid = intval ( $_GET [ 'award_awards_id' ]);
$year = $config [ 'FAIRYEAR' ];
if ( $aaid == - 1 ) {
$aaid = 0 ;
$year = - 1 ;
}
mysql_query ( " INSERT INTO award_prizes(award_awards_id,year) VALUES (' $aaid ',' $year '); " );
$ret = array ( 'id' => mysql_insert_id () );
echo json_encode ( $ret );
exit ;
2009-09-10 01:23:58 +00:00
case 'prize_save' :
2009-09-11 06:12:17 +00:00
$id = intval ( $_POST [ 'id' ]);
2009-09-10 01:23:58 +00:00
$q = " UPDATE award_prizes SET
2009-09-11 06:12:17 +00:00
prize = '".mysql_escape_string(stripslashes($_POST[' prize ']))."' ,
cash = '".intval($_POST[' cash '])."' ,
scholarship = '".intval($_POST[' scholarship '])."' ,
value = '".intval($_POST[' value '])."' ,
number = '".intval($_POST[' number '])."' ,
excludefromac = '".(($_POST[' excludefromac ']==1)? 1 : 0)."' ,
trophystudentkeeper = '".(($_POST[' trophystudentkeeper ']==1) ? 1 : 0)."' ,
trophystudentreturn = '".(($_POST[' trophystudentreturn ']==1) ? 1 : 0)."' ,
trophyschoolkeeper = '".(($_POST[' trophyschoolkeeper ']==1) ? 1 : 0)."' ,
trophyschoolreturn = '".(($_POST[' trophyschoolreturn ']==1) ? 1 : 0)."'
2009-09-10 01:23:58 +00:00
WHERE id = '$id' " ;
mysql_query ( $q );
2009-09-10 01:24:57 +00:00
// echo $q;
// echo mysql_error();
2009-09-13 19:25:03 +00:00
happy_ ( " Prize saved " );
2009-09-10 01:23:58 +00:00
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'";
2009-09-13 19:25:03 +00:00
happy_ ( " Prize deleted " );
2009-09-09 00:26:12 +00:00
exit ;
2009-09-13 07:08:12 +00:00
case 'feeder_load' :
$id = intval ( $_GET [ 'id' ]);
$ret = array ();
/* Prepare two lists of fair IDs, for which fairs can upload and download this award */
$q = mysql_query ( " SELECT * FROM fairs_awards_link WHERE award_awards_id=' $id ' " );
while ( $r = mysql_fetch_assoc ( $q )) {
if ( $r [ 'download_award' ] == 'yes' ) $ret [ 'dl' ][] = $r [ 'fairs_id' ];
if ( $r [ 'upload_winners' ] == 'yes' ) $ret [ 'ul' ][] = $r [ 'fairs_id' ];
}
2009-09-13 21:58:50 +00:00
$q = mysql_query ( " SELECT * FROM award_awards WHERE id=' $id ' " );
$a = mysql_fetch_assoc ( $q );
$ret [ 'identifier' ] = $a [ 'external_identifier' ];
2009-09-13 07:08:12 +00:00
echo json_encode ( $ret );
exit ;
case 'feeder_save' :
2009-09-13 08:33:54 +00:00
// print_r($_POST);
2009-09-13 19:25:03 +00:00
2009-09-13 07:08:12 +00:00
$id = intval ( $_POST [ 'award_awards_id' ]);
$dl = is_array ( $_POST [ 'feeder_dl' ]) ? $_POST [ 'feeder_dl' ] : array ();
$ul = is_array ( $_POST [ 'feeder_ul' ]) ? $_POST [ 'feeder_ul' ] : array ();
/* Prepare a fair-wise list */
$data = array ();
foreach ( $dl AS $fairs_id ) $data [ $fairs_id ][ 'dl' ] = true ;
foreach ( $ul AS $fairs_id ) $data [ $fairs_id ][ 'ul' ] = true ;
/* Now save each one */
mysql_query ( " DELETE FROM fairs_awards_link WHERE award_awards_id=' $id ' " );
echo mysql_error ();
foreach ( $data as $fairs_id => $f ) {
$dl = ( $f [ 'dl' ] == true ) ? 'yes' : 'no' ;
$ul = ( $f [ 'ul' ] == true ) ? 'yes' : 'no' ;
mysql_query ( " INSERT INTO fairs_awards_link (award_awards_id,fairs_id,download_award,upload_winners)
VALUES ( '$id' , '$fairs_id' , '$dl' , '$ul' ) " );
echo mysql_error ();
}
2009-09-13 21:58:50 +00:00
$ident = mysql_escape_string ( stripslashes ( $_POST [ 'identifier' ]));
mysql_query ( " UPDATE award_awards SET external_identifier=' $ident ' WHERE id=' $id ' " );
2009-09-13 08:33:54 +00:00
happy_ ( " Saved " );
2009-09-13 07:08:12 +00:00
exit ;
2009-09-09 00:26:12 +00:00
}
2009-09-10 08:29:16 +00:00
send_header ( " Awards Management " ,
array ( 'Committee Main' => 'committee_main.php' ,
2007-11-18 23:50:23 +00:00
'Administration' => 'admin/index.php' ,
'Awards Main' => 'admin/awards.php' ) );
2009-09-09 00:26:12 +00:00
?>
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 update_awardinfo ()
{
var id = award_id ;
// alert("id="+award_id);
2009-09-13 19:25:03 +00:00
notice_div_id ( 'award_notice' );
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_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 ]);
});
}
2009-09-10 08:56:58 +00:00
function awardinfo_save ()
2009-09-09 00:26:12 +00:00
{
2009-09-13 19:25:03 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=awardinfo_save " , $ ( " #awardinfo " ) . serializeArray ());
2009-09-09 00:26:12 +00:00
return 0 ;
}
function update_eligibility ()
{
var id = award_id ;
2009-09-13 19:25:03 +00:00
notice_div_id ( 'eligibility_notice' );
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 ){
2009-09-10 08:56:58 +00:00
$ ( " #eligibility_id " ) . val ( json . id );
$ ( " [name=categories \\ [ \\ ]] " ) . val ( json . categories );
$ ( " [name=divisions \\ [ \\ ]] " ) . val ( json . divisions );
2009-09-09 00:26:12 +00:00
});
}
2009-09-10 08:56:58 +00:00
function prizelist_refresh ()
{
$ ( " #prizelist " ) . tableDnD ({
onDrop : function ( table , row ) {
var order = $ . tableDnD . serialize ();
$ ( " #prizeinfo_info " ) . load ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_order& " + order );
/* Change the order */
var rows = table . tBodies [ 0 ] . rows ;
for ( var i = 0 ; i < rows . length ; i ++ ) {
$ ( " #prizelist_order_ " + rows [ i ] . id ) . html ( i );
}
},
dragHandle : " drag_handle " ,
});
}
2009-09-10 17:32:16 +00:00
2009-09-10 01:23:58 +00:00
function update_prizeinfo ()
{
var id = award_id ;
2009-09-13 19:25:03 +00:00
notice_div_id ( 'prize_notice' );
2009-09-10 01:23:58 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prizeinfo_load&id= " + id ,
function ( json ) {
2009-09-10 08:29:16 +00:00
$ ( " .prizelist_tr " ) . remove ();
2009-09-10 01:23:58 +00:00
for ( var i in json ) {
var p = json [ i ];
2009-09-10 08:29:16 +00:00
var oc = " onclick= \" edit_prize( " + p . id + " ); \" " ;
$ ( " #prizelist " ) . append ( " <tr class= \" prizelist_tr \" id= \" " + p . id + " \" ><td class= \" drag_handle \" style= \" cursor:move; text-align:center; \" id= \" prizelist_order_ " + p . id + " \" > " + p . order + " </td> " +
" <td style= \" cursor:pointer; text-align:center; \" " + oc + " > " + p . number + " </td> " +
" <td style= \" cursor:pointer; \" " + oc + " > " + p . prize + " </td> " +
" <td style= \" cursor:pointer; width:4em; text-align:right; padding-left:2em; padding-right:2em; \" " + oc + " > " + p . cash + " </td> " +
" <td style= \" cursor:pointer; width:4em; text-align:right; padding-left:2em; padding-right:2em; \" " + oc + " > " + p . scholarship + " </td> " +
" <td style= \" cursor:pointer; width:4em; text-align:right; padding-left:2em; padding-right:2em; \" " + oc + " > " + 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> " );
2009-09-10 01:23:58 +00:00
}
2009-09-10 08:56:58 +00:00
prizelist_refresh ();
2009-09-10 01:23:58 +00:00
});
}
function edit_prize ( id )
{
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_load&id= " + id ,
function ( json ){
$ ( " #prizeinfo_edit_header " ) . html ( " <?=i18n( " Edit Prize " )?> " );
2009-09-10 08:29:16 +00:00
$ ( " #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 " );
2009-09-10 01:23:58 +00:00
});
}
2009-09-10 08:56:58 +00:00
function eligibility_save ()
{
2009-09-13 19:25:03 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=eligibility_save " , $ ( " #eligibility " ) . serializeArray ());
2009-09-10 08:56:58 +00:00
return 0 ;
}
2009-09-10 01:23:58 +00:00
function prize_save ()
{
2009-09-13 19:25:03 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=prize_save " , $ ( " #prizeinfo " ) . serializeArray ());
2009-09-10 01:23:58 +00:00
update_prizeinfo ();
2009-09-10 08:29:16 +00:00
return 0 ;
2009-09-10 01:23:58 +00:00
}
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 );
2009-09-10 08:56:58 +00:00
$ ( " .prizelist_tr# " + id ) . fadeTo ( 'slow' , 0 );
$ ( " .prizelist_tr# " + id ) . remove ();
prizelist_refresh ();
2009-09-10 08:29:16 +00:00
}
return 0 ;
2009-09-10 01:23:58 +00:00
}
function prize_create ()
{
var id = award_id ;
2009-09-10 17:32:16 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_create&award_awards_id= " + id ,
function ( json ){
$ ( " .prizeinfo " ) . val ( " " );
$ ( " #prizeinfo_id " ) . val ( json . id );
$ ( " #prizeinfo_edit_header " ) . html ( " <?=i18n( " New Prize " )?> " );
$ ( " .prizeinfo " ) . removeAttr ( " disabled " );
$ ( " #prizeinfo_save " ) . removeAttr ( " disabled " );
update_prizeinfo ();
});
2009-09-10 01:23:58 +00:00
}
2009-09-13 07:08:12 +00:00
function update_feeder ()
{
var id = award_id ;
2009-09-13 19:25:03 +00:00
notice_div_id ( 'feeder_notice' );
2009-09-13 07:08:12 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=feeder_load&id= " + id ,
function ( json ) {
$ ( " #feeder_id " ) . val ( id );
2009-09-13 21:58:50 +00:00
$ ( " #feeder_identifier " ) . val ( json . identifier );
2009-09-13 07:08:12 +00:00
$ ( " [name=feeder_dl \\ [ \\ ]] " ) . val ( json . dl );
$ ( " [name=feeder_ul \\ [ \\ ]] " ) . val ( json . ul );
});
2009-09-13 08:33:54 +00:00
2009-09-13 07:08:12 +00:00
}
function feeder_save ()
{
2009-09-13 19:25:03 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=feeder_save " , $ ( " #feeder_form " ) . serializeArray ());
2009-09-13 07:08:12 +00:00
return 0 ;
}
2009-09-10 01:23:58 +00:00
2009-09-10 08:29:16 +00:00
/* Setup the popup window */
2009-09-09 00:26:12 +00:00
$ ( document ) . ready ( function () {
2009-09-09 17:06:11 +00:00
$ ( " #popup_editor " ) . dialog ({
2009-09-10 08:29:16 +00:00
bgiframe : true , autoOpen : false ,
modal : true , resizable : false ,
2009-09-09 17:06:11 +00:00
draggable : false
});
2009-09-10 22:52:04 +00:00
2009-09-11 06:12:17 +00:00
$ ( " #editor_tabs " ) . tabs ({
2009-09-10 22:52:04 +00:00
show : function ( event , ui ) {
2009-09-11 06:12:17 +00:00
switch ( ui . panel . id ) {
case 'editor_tab_awardinfo' :
update_awardinfo ();
break ;
case 'editor_tab_eligibility' :
update_eligibility ();
break ;
case 'editor_tab_prizes' :
update_prizeinfo ();
2009-09-13 07:08:12 +00:00
break ;
case 'editor_tab_feeder' :
update_feeder ();
break ;
2009-09-11 06:12:17 +00:00
}
},
2009-09-10 22:52:04 +00:00
selected : - 1 ,
});
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
2009-09-10 01:23:58 +00:00
?>
2009-09-10 22:52:04 +00:00
< div id = " editor_tabs " >
< ul >< li >< a href = " #editor_tab_awardinfo " >< span >< ? = i18n ( 'Award Info' ) ?> </span></a></li>
< li >< a href = " #editor_tab_eligibility " >< span >< ? = i18n ( 'Eligibility' ) ?> </span></a></li>
< li >< a href = " #editor_tab_prizes " >< span >< ? = i18n ( 'Prizes' ) ?> </span></a></li>
2009-09-13 07:08:12 +00:00
< li >< a href = " #editor_tab_feeder " >< span >< ? = i18n ( 'Feeder Fairs' ) ?> </span></a></li>
2009-09-10 22:52:04 +00:00
</ ul >
< div id = " editor_tab_awardinfo " >
2009-09-11 06:12:17 +00:00
< h4 >< ? = i18n ( " Award Info " ) ?> </h4>
2009-09-13 19:25:03 +00:00
< div id = " award_notice " class = " notice_area " ></ div >
2009-09-10 01:23:58 +00:00
< form id = " awardinfo " >
< input type = " hidden " name = " id " id = " awardinfo_id " value = " 0 " />
< table class = " tableedit " >
< tr >< td class = " left " >< ? = i18n ( " Name " ) ?> :</td>
2009-09-11 06:35:49 +00:00
< td class = " right " >< input class = " translatable " type = " text " id = " awardinfo_name " name = " name " value = " Loading... " size = " 50 " maxlength = " 128 " >
2009-09-10 01:23:58 +00:00
</ 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
?>
2009-09-10 08:29:16 +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-10 01:23:58 +00:00
< ?
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 > " ;
}
2009-09-10 08:29:16 +00:00
?>
</ select ></ td ></ tr >
< tr >< td class = " left " >< ? = i18n ( " Criteria " ) ?> :</td>
2009-09-11 05:16:37 +00:00
< td class = " right " >< textarea class = " translatable " id = " awardinfo_criteria " name = " criteria " rows = " 3 " cols = " 50 " > Loading ...</ textarea ></ td ></ tr >
2009-09-10 08:29:16 +00:00
< tr >< td class = " left " >< ? = i18n ( " Description " ) ?> :</td>
2009-09-11 05:16:37 +00:00
< td class = " right " >< textarea class = " translatable " id = " awardinfo_description " name = " description " rows = " 3 " cols = " 50 " > Loading ...</ textarea ></ td ></ tr >
2009-09-10 08:29:16 +00:00
</ table >
2009-09-09 00:26:12 +00:00
2009-09-11 06:12:17 +00:00
< h4 > Options </ h4 >
2009-09-10 08:29:16 +00:00
< table class = " tableedit " >
< tr >< td class = " left " >
< 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>
< tr >< td class = " left " >
< 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>
< tr >< td class = " left " >
< 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>
< tr >< td class = " left " >
< 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>
</ table ></ form >
2009-09-10 08:56:58 +00:00
< input type = " submit " onClick = " awardinfo_save(); " value = " Save " />
2009-09-10 22:52:04 +00:00
</ div >
2009-09-09 00:26:12 +00:00
2009-09-10 22:52:04 +00:00
< ? /* Next Tab */ ?>
< div id = " editor_tab_eligibility " >
2009-09-11 06:12:17 +00:00
< h4 >< ? = i18n ( " Eligibility " ) ?> </h4>
2009-09-13 19:25:03 +00:00
< div id = " eligibility_notice " class = " notice_area " ></ div >
2009-09-14 05:34:31 +00:00
< br />
2009-09-10 08:56:58 +00:00
< form id = " eligibility " >
< input type = " hidden " id = " eligibility_id " name = " id " value = " " />
2009-09-10 08:29:16 +00:00
< table class = " tableedit " >
< tr >< td class = " left " >< ? = i18n ( " Age Categories " ) ?> :</td><td class="right">
< ?
2009-09-09 00:26:12 +00:00
// 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 )) {
2009-09-10 08:56:58 +00:00
echo " <input type= \" checkbox \" id= \" eligibility_categories_ { $cr -> id } \" name= \" categories[] \" value= \" $cr->id\ " /> " .i18n( $cr->category ). " < br /> " ;
2009-09-09 00:26:12 +00:00
}
2009-09-10 08:56:58 +00:00
?>
</ td ></ tr >
2009-09-09 00:26:12 +00:00
2009-09-10 08:56:58 +00:00
< tr >< td class = " left " >< ? = i18n ( " Divisions " ) ?> :</td><td class="right">
< ?
2009-09-09 00:26:12 +00:00
$dq = mysql_query ( " SELECT * FROM projectdivisions WHERE year=' { $config [ 'FAIRYEAR' ] } ' ORDER BY division " );
echo mysql_error ();
while ( $dr = mysql_fetch_object ( $dq )) {
2009-09-10 08:56:58 +00:00
echo " <input type= \" checkbox \" id= \" eligibility_divisions_ { $dr -> id } \" name= \" divisions[] \" value= \" $dr->id\ " /> " .i18n( $dr->division ). " < br /> " ;
2009-09-09 00:26:12 +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>";
2009-09-10 08:56:58 +00:00
?>
</ td ></ tr ></ table >
</ form >
< input type = " submit " onClick = " eligibility_save(); " value = " Save " />
2009-09-10 22:52:04 +00:00
</ div >
2009-09-09 00:26:12 +00:00
2009-09-10 22:52:04 +00:00
< ? /* Next Tab */ ?>
< div id = " editor_tab_prizes " >
2009-09-13 19:25:03 +00:00
< div id = " prize_notice " class = " notice_area " ></ div >
2009-09-11 06:12:17 +00:00
< h4 >< ? = i18n ( " Prizes " ) ?> </h4>
2009-09-10 08:29:16 +00:00
< br />
< table id = " prizelist " class = " tableview " >
< tr class = " nodrop nodrag " >
< 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 ></ table >
2009-09-10 01:23:58 +00:00
< br >
* < ? = i18n ( " Click on the Script Order and drag to re-order the prizes " ) ?>
< br >
< hr >
2009-09-11 06:12:17 +00:00
< br />< h4 id = " prizeinfo_edit_header " > Click on a prize to edit </ h4 >< br />
2009-09-10 01:23:58 +00:00
< 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 " >
2009-09-14 05:34:31 +00:00
< tr >
< td class = " left " >< ? = i18n ( " Number available " ) ?> :</td>
< td class = " right " >< input type = " text " id = " prizeinfo_number " class = " prizeinfo " name = " number " value = " " size = " 3 " maxlength = " 5 " disabled = " disabled " /></ td >
</ tr >< tr >
< td class = " left " >< ? = i18n ( " Prize Description " ) ?> :</td>
2009-09-11 05:16:37 +00:00
< td class = " right " >< input type = " text " id = " prizeinfo_prize " class = " prizeinfo translatable " name = " prize " value = " " size = " 40 " maxlength = " 128 " disabled = " disabled " /></ 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 " 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-10 22:52:04 +00:00
</ div >
2009-09-09 17:06:11 +00:00
2009-09-13 07:08:12 +00:00
< ? /* Next Tab */ ?>
< div id = " editor_tab_feeder " >
2009-09-13 19:25:03 +00:00
< div id = " feeder_notice " class = " notice_area " ></ div >
2009-09-13 07:08:12 +00:00
< h4 >< ? = i18n ( " Feeder Fairs " ) ?> </h4>
< form id = " feeder_form " >
< input type = " hidden " id = " feeder_id " name = " award_awards_id " value = " " />
2009-09-13 21:58:50 +00:00
< p >< ? = i18n ( " Give this award a unique name to distinguish it from any other awards the fair may download. " ) ?> </p>
< table class = " tableedit " >
< tr >< td class = " left " >< ? = i18n ( 'Unique Name' ) ?> :</td>
2009-09-13 22:23:19 +00:00
< td class = " right " >< input type = " text " id = " feeder_identifier " name = " identifier " value = " " size = " 40 " maxlength = " 128 " /></ td ></ tr >
< tr >< td class = " left " ></ td >
< td class = " right " >< input type = " checkbox " id = " feeder_advance " name = " advance " value = " yes " >< ? = i18n ( " Winners uploaded by a feeder fair will be registered as participants at this fair (both download award and upload winners should be turned on below) " ) ?> </td></tr>
2009-09-13 21:58:50 +00:00
</ tr ></ table >
< p >< ? = i18n ( " Select which feeder fairs can download this award and upload winners. " ) ?> </p>
2009-09-13 07:08:12 +00:00
< table class = " tableview " >
< tr >< th >< ? = i18n ( " Fair " ) ?> </th>
< th style = " width: 5em " >< ? = i18n ( " Download Award " ) ?> </th>
< th style = " width: 5em " >< ? = i18n ( " Upload Winners " ) ?> </th>
</ tr >
< ?
$q = mysql_query ( " SELECT * FROM fairs WHERE type='feeder' " );
while ( $r = mysql_fetch_assoc ( $q )) {
echo " <tr><td style= \" padding-left:1em;padding-right:1em \" > { $r [ 'name' ] } </td> " ;
echo " <td style= \" text-align:center \" ><input type= \" checkbox \" id= \" feeder_dl_ { $r [ 'id' ] } \" name= \" feeder_dl[] \" value= \" { $r [ 'id' ] } \" ></td> " ;
echo " <td style= \" text-align:center \" ><input type= \" checkbox \" id= \" feeder_ul_ { $r [ 'id' ] } \" name= \" feeder_ul[] \" value= \" { $r [ 'id' ] } \" ></td> " ;
echo '</tr>' ;
}
?>
</ table >
</ form >
< br />
< input type = " submit " onClick = " feeder_save(); " value = " <?=i18n( " Save " )?> " />
2009-09-10 17:32:16 +00:00
2009-09-10 22:52:04 +00:00
</ div >
2009-09-10 17:32:16 +00:00
2009-09-13 07:08:12 +00:00
< ? /* End tabs, end popup */ ?>
</ div ></ div >
2009-09-10 22:52:04 +00:00
< ?
2009-09-10 08:29:16 +00:00
/* Here ' s all the code for the award list , except for the AJAX queries which are
* at the top of this file */
?>
2009-09-10 22:52:04 +00:00
2009-09-10 08:29:16 +00:00
< script type = " text/javascript " >
function popup_editor ( id )
2009-09-09 00:26:12 +00:00
{
2009-09-10 08:29:16 +00:00
var w = ( document . documentElement . clientWidth * 0.8 );
var h = ( document . documentElement . clientHeight * 0.8 );
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
$ ( '#popup_editor' ) . dialog ( 'option' , 'width' , w );
$ ( '#popup_editor' ) . dialog ( 'option' , 'height' , h );
$ ( " #popup_editor " ) . dialog ( 'open' );
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
award_id = id ;
2009-09-10 17:32:16 +00:00
if ( id == - 1 ) {
2009-09-10 22:52:04 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'disabled' , [ 0 , 1 ]);
$ ( '#editor_tabs' ) . tabs ( 'option' , 'selected' , 2 );
2009-09-10 17:32:16 +00:00
} else {
2009-09-10 22:52:04 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'disabled' , []);
$ ( '#editor_tabs' ) . tabs ( 'option' , 'selected' , 0 );
2009-09-10 17:32:16 +00:00
}
2009-09-10 08:29:16 +00:00
return 0 ;
}
2005-02-25 19:16:05 +00:00
2009-09-10 08:56:58 +00:00
function awardlist_refresh ()
{
$ ( " #awardlist " ) . tableDnD ({
onDrop : function ( table , row ) {
var order = $ . tableDnD . serialize ();
// $(row).fadeTo('fast',1);
$ ( " #award_info " ) . load ( " <?= $_SERVER['PHP_SELF'] ?>?action=award_order& " + order );
/* Change the order */
var rows = table . tBodies [ 0 ] . rows ;
for ( var i = 0 ; i < rows . length ; i ++ ) {
$ ( " #awardlist_order_ " + rows [ i ] . id ) . html ( i );
}
},
onDragStart : function ( table , row ) {
// $(row).fadeTo('fast',0.2);
},
dragHandle : " drag_handle "
});
}
2009-09-10 08:29:16 +00:00
function award_create ()
{
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=award_create " ,
function ( json ) {
popup_editor ( json . id );
/* Ensure we open on the first tab */
2009-09-10 22:52:04 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'selected' , 0 );
2009-09-10 08:29:16 +00:00
});
// alert("ok");
return 0 ;
}
2005-02-25 19:16:05 +00:00
2009-09-10 08:56:58 +00:00
2009-09-10 08:29:16 +00:00
function award_delete ( id )
{
var conf = confirmClick ( '<?=i18n("Are you sure you want to remove this award?")?>' );
if ( conf == true ) {
$ ( " #info_info " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=award_delete&id= " + id );
/* The TRs need to have just a numeric ID , which could conflict with other lists , so
* tag each TR with a class too , and select both the class and the ID */
$ ( " .awardlist_tr# " + id ) . fadeTo ( 'slow' , 0 );
$ ( " .awardlist_tr# " + id ) . remove ();
2009-09-10 08:56:58 +00:00
/* Rows changed, need to refresh the drag list */
awardlist_refresh ();
2009-09-10 08:29:16 +00:00
}
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
}
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
$ ( document ) . ready ( function () {
2009-09-10 08:56:58 +00:00
awardlist_refresh ();
2009-09-10 08:29:16 +00:00
// $(".awardlist_tr#166").css('background-color','red');
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
});
2005-03-04 03:40:03 +00:00
2009-09-10 08:29:16 +00:00
</ script >
2005-03-04 03:40:03 +00:00
2009-09-10 17:32:16 +00:00
2009-09-10 08:29:16 +00:00
< div id = " info_info " ></ div >
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
< ?
2005-02-25 19:16:05 +00:00
2009-09-10 17:32:16 +00:00
2009-09-10 08:29:16 +00:00
/* List filtering */
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
2009-09-10 08:29:16 +00:00
if ( $_GET [ 'award_types_id' ] && $_GET [ 'award_types_id' ] != " all " )
$_SESSION [ 'award_types_id' ] = $_GET [ 'award_types_id' ];
else if ( $_GET [ 'award_types_id' ] == " all " )
unset ( $_SESSION [ 'award_types_id' ]);
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
/*
if ( $_GET [ 'award_sponsors_confirmed' ] && $_GET [ 'award_sponsors_confirmed' ] != " all " )
$_SESSION [ 'award_sponsors_confirmed' ] = $_GET [ 'award_sponsors_confirmed' ];
if ( $_GET [ 'sponsors_id' ] == " all " )
unset ( $_SESSION [ 'sponsors_id' ]);
if ( $_GET [ 'award_types_id' ] == " all " )
unset ( $_SESSION [ 'award_types_id' ]);
if ( $_GET [ 'award_sponsors_confirmed' ] == " all " )
unset ( $_SESSION [ 'award_sponsors_confirmed' ]);
*/
$award_types_id = $_SESSION [ 'award_types_id' ];
$sponsors_id = $_SESSION [ 'sponsors_id' ];
//$award_sponsors_confirmed=$_SESSION['award_sponsors_confirmed'];
echo " <br /> " ;
echo i18n ( " Filter By: " );
echo " <form method= \" get \" action= \" award_awards.php \" name= \" filterchange \" > " ;
echo " <table><tr><td colspan= \" 2 \" > " ;
$q = mysql_query ( " SELECT id,organization FROM sponsors ORDER BY organization " );
echo " <select name= \" sponsors_id \" onchange= \" document.forms.filterchange.submit() \" > " ;
echo " <option value= \" all \" > " . i18n ( " All Sponsors " ) . " </option> " ;
while ( $r = mysql_fetch_object ( $q )) {
if ( $r -> id == $sponsors_id ) {
$sel = " selected= \" selected \" " ;
$sponsors_organization = $r -> organization ;
} else
$sel = " " ;
echo " <option $sel value= \" $r->id\ " > " .i18n( $r->organization ). " </ option > " ;
}
echo " </select> " ;
echo " </td></tr> " ;
echo " <tr><td> " ;
$q = mysql_query ( " SELECT id,type FROM award_types WHERE year=' { $config [ 'FAIRYEAR' ] } ' ORDER BY type " );
echo " <select name= \" award_types_id \" onchange= \" document.forms.filterchange.submit() \" > " ;
echo " <option value= \" all \" > " . i18n ( " All Award Types " ) . " </option> " ;
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> " ;
echo " </td><td> " ;
2008-03-20 20:37:33 +00:00
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..
2009-09-10 08:29:16 +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> " ;
*/
echo " </form> " ;
echo " </td></tr> " ;
echo " </table> " ;
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
?>
< br />
< a href = " # " onClick = " award_create(); " >< ? = i18n ( " Create New Award " ) ?> </a>
2009-09-10 22:52:04 +00:00
< a href = " # " onClick = " popup_editor(-1); " >< ? = i18n ( " Edit Generic Prize Template " ) ?> </a>
2009-09-10 17:32:16 +00:00
< input type = " submit " onClick = " award_create(); " value = " <?=i18n( " Create New Award " )?> " />
2009-09-10 22:52:04 +00:00
< input type = " submit " onClick = " popup_editor(-1); " value = " <?=i18n( " Edit Generic Prize Template " )?> " />
2009-09-10 08:29:16 +00:00
< br />< br />
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
< ?
/* For some reason , this submit button opens the dialog then it closes right away , but it doesn ' t
* if the entry is done through the a href */
//<input type="submit" onClick="award_create();" value="<?=i18n("Create New Award")>" />
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
if ( $sponsors_id ) $where_asi = " AND sponsors_id=' $sponsors_id ' " ;
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
2009-09-10 08:29:16 +00:00
if ( ! $orderby ) $orderby = " order " ;
$q = mysql_query ( " SELECT
award_awards . id ,
award_awards . name ,
award_awards . order ,
award_awards . award_source_fairs_id ,
award_types . type ,
sponsors . organization
FROM
award_awards ,
award_types ,
sponsors
WHERE
award_awards . year = '{$config[' FAIRYEAR ']}'
$where_asi
$where_ati
$where_asc
AND award_awards . sponsors_id = sponsors . id
AND award_awards . award_types_id = award_types . id
AND award_types . year = '{$config[' FAIRYEAR ']}'
ORDER BY `$orderby` " );
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
echo mysql_error ();
2006-01-03 02:01:20 +00:00
2009-09-10 08:29:16 +00:00
if ( mysql_num_rows ( $q ))
{
echo " <table id= \" awardlist \" class= \" tableview \" > " ;
echo " <tr class= \" nodrop nodrag \" > " ;
echo " <th> " . i18n ( " Order " ) . " </th> " ;
echo " <th> " . i18n ( " Sponsor " ) . " </th> " ;
echo " <th> " . i18n ( " Type " ) . " </th> " ;
echo " <th> " . i18n ( " Name " ) . " </th> " ;
echo " <th> " . i18n ( " Prizes " ) . " </th> " ;
echo " <th> " . i18n ( " Actions " ) . " </th> " ;
echo " </tr> \n " ;
$hasexternal = false ;
while ( $r = mysql_fetch_object ( $q )) {
$cl = ( $r -> award_source_fairs_id ) ? externalaward : '' ;
$eh = " style= \" cursor:pointer; \" onclick= \" popup_editor( { $r -> id } ); \" " ;
echo " <tr class= \" $cl awardlist_tr \" id= \" { $r -> id } \" > \n " ;
echo " <td id= \" awardlist_order_ { $r -> id } \" class= \" drag_handle \" style= \" cursor:move; text-align:right; \" > { $r -> order } </td> \n " ;
echo " <td $eh > { $r -> organization } </td> \n " ;
echo " <td $eh > { $r -> type } </td> \n " ;
echo " <td $eh > { $r -> name } </td> \n " ;
$numq = mysql_query ( " SELECT COUNT(id) AS num FROM award_prizes WHERE award_awards_id=' { $r -> id } ' " );
$numr = mysql_fetch_assoc ( $numq );
echo " <td $eh align= \" center \" > { $numr [ 'num' ] } </td> " ;
echo " <td align= \" center \" > " ;
echo " <img border= \" 0 \" src= \" { $config [ 'SFIABDIRECTORY' ] } /images/16/edit. { $config [ 'icon_extension' ] } \" > " ;
echo " " ;
echo " <a onclick= \" award_delete( { $r -> id } ); \" href= \" # \" ><img border=0 src= \" { $config [ 'SFIABDIRECTORY' ] } /images/16/button_cancel. { $config [ 'icon_extension' ] } \" ></a> " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2005-02-25 19:16:05 +00:00
}
2009-09-10 08:29:16 +00:00
if ( $hasexternal )
echo " <tr class= \" externalaward \" ><td colspan= \" 6 \" > " . i18n ( " Indicates award imported from an external source " ) . " </td></tr> " ;
echo " </table> \n " ;
echo " </form> " ;
}
echo " <br /> " ;
2009-09-10 17:32:16 +00:00
// echo "<a href=\"award_prizes.php?award_awards_id=-1\">Edit prizes for the generic prize template</a>";
if ( $_GET [ 'action' ] == 'edit_prize_template' ) {
?> <script type="text/javascript">
2009-09-10 22:52:04 +00:00
popup_editor ( - 1 );
2009-09-10 17:32:16 +00:00
</ script >
< ?
}
2009-09-10 08:29:16 +00:00
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
send_footer ();
2005-02-25 19:16:05 +00:00
?>