2005-02-25 19:16:05 +00:00
< ?
2025-01-29 03:30:48 +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 .
*/
2005-02-25 19:16:05 +00:00
?>
< ?
2025-01-29 03:30:48 +00:00
require_once ( '../common.inc.php' );
require_once ( '../user.inc.php' );
user_auth_required ( 'committee' , 'admin' );
require_once ( 'awards.inc.php' );
2009-09-10 08:29:16 +00:00
2025-01-29 03:30:48 +00:00
$_GET [ 'action' ] = $_GET [ 'action' ] ? ? '' ;
2009-09-10 08:29:16 +00:00
2025-01-29 03:30:48 +00:00
switch ( $_GET [ 'action' ]) {
2025-01-28 17:33:03 -05:00
case 'awardinfo_load' :
2025-02-09 18:41:20 +00:00
;
2025-01-28 17:33:03 -05:00
$id = intval ( get_value_from_array ( $_GET , 'id' ));
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_awards WHERE id=? " );
$q -> execute ([ $id ]);
2025-01-28 17:33:03 -05:00
$ret = $q -> fetch ( PDO :: FETCH_ASSOC );
2025-01-29 03:30:48 +00:00
// json_encode NEEDS UTF8 DATA, but we store it in the database as ISO :(
foreach ( $ret AS $k => $v ) {
$ret [ $k ] = iconv ( 'ISO-8859-1' , 'UTF-8' , $v );
2025-01-28 17:33:03 -05:00
}
2025-01-29 03:30:48 +00:00
// echo iconv("ISO-8859-1","UTF-8",json_encode($ret));
2025-01-28 17:33:03 -05:00
echo json_encode ( $ret );
exit ;
2009-09-10 08:29:16 +00:00
2025-01-28 17:33:03 -05:00
case 'award_delete' :
2025-01-29 03:30:48 +00:00
$id = intval ( $_GET [ 'id' ]);
2025-01-28 17:33:03 -05:00
award_delete ( $id );
exit ;
case 'awardinfo_save' :
/* Scrub the data while we save it */
2025-01-29 03:30:48 +00:00
$id = intval ( $_POST [ 'id' ]);
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
if ( $id == - 1 ) {
2025-01-28 17:33:03 -05:00
$q = $pdo -> prepare ( " INSERT INTO award_awards (year,self_nominate,schedule_judges)
2025-02-09 17:24:37 +00:00
VALUES ( ? , 'yes' , 'yes' ) " );
$q -> execute ([ $config [ 'FAIRYEAR' ]]);
2025-01-28 17:33:03 -05:00
$id = $pdo -> lastInsertId ();
2025-01-29 03:30:48 +00:00
happy_ ( 'Award Created' );
2025-01-28 17:33:03 -05:00
/* Set the award_id in the client */
echo " <script type= \" text/javascript \" >award_id= $id ;</script> " ;
}
$q = " UPDATE award_awards SET
2025-01-29 03:30:48 +00:00
award_types_id = '" . intval($_POST[' award_types_id ']) . "' ,
presenter = '" . iconv(' UTF - 8 ', ' ISO - 8859 - 1 ', 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 ') . "' ,
description = '" . iconv(' UTF - 8 ', ' ISO - 8859 - 1 ', stripslashes($_POST[' description '])) . "' " ;
if ( array_key_exists ( 'name' , $_POST )) {
/*
* These values may be disabled , if they name key exists , assume
* they aren ' t disabled and save them too
*/
$q .= " ,name=' " . iconv ( 'UTF-8' , 'ISO-8859-1' , stripslashes ( $_POST [ 'name' ])) . " ',
criteria = '" . iconv(' UTF - 8 ', ' ISO - 8859 - 1 ', stripslashes($_POST[' criteria '])) . "' ,
sponsors_id = '" . intval($_POST[' sponsors_id ']) . "' " ;
2025-01-28 17:33:03 -05:00
}
2025-02-09 17:24:37 +00:00
$q .= " WHERE id=? " ;
2025-01-28 17:33:03 -05:00
$q = $pdo -> prepare ( $q );
2025-02-09 17:24:37 +00:00
$q -> execute ([ $id ]);
2025-02-09 18:41:20 +00:00
2025-01-28 17:33:03 -05:00
show_pdo_errors_if_any ( $pdo );
2025-01-29 03:30:48 +00:00
happy_ ( 'Award information saved' );
2025-01-28 17:33:03 -05:00
exit ;
case 'eligibility_load' :
$id = intval ( $_GET [ 'id' ]);
2025-01-29 03:30:48 +00:00
// select the current categories that this award is linked to
$ret = array ( 'categories' => array (), 'divisions' => array ());
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_awards_projectcategories WHERE award_awards_id=? " );
$q -> execute ([ $id ]);
2025-01-29 03:30:48 +00:00
while ( $r = $q -> fetch ( PDO :: FETCH_ASSOC )) {
2025-01-28 17:33:03 -05:00
$ret [ 'categories' ][] = $r [ 'projectcategories_id' ];
}
2009-09-18 07:50:32 +00:00
2025-01-29 03:30:48 +00:00
// select the current categories that this award is linked to
2025-02-09 17:24:37 +00:00
$q = $pdo -> $prepare ( " SELECT * FROM award_awards_projectdivisions WHERE award_awards_id=? " );
$q -> execute ([ $id ]);
2025-01-29 03:30:48 +00:00
while ( $r = $q -> fetch ( PDO :: FETCH_ASSOC )) {
2025-01-28 17:33:03 -05:00
$ret [ 'divisions' ][] = $r [ 'projectdivisions_id' ];
}
echo json_encode ( $ret );
exit ;
2009-09-09 17:06:11 +00:00
2025-01-28 17:33:03 -05:00
case 'eligibility_save' :
$id = intval ( $_POST [ 'award_awards_id' ]);
2009-09-09 00:26:12 +00:00
2025-01-29 03:30:48 +00:00
// now add the new ones
if ( ! is_array ( $_POST [ 'categories' ]) || ! is_array ( $_POST [ 'divisions' ])) {
error_ ( 'Invalid data' );
2025-01-28 17:33:03 -05:00
exit ;
}
2025-01-29 03:30:48 +00:00
// wipe out any old award-category links
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " DELETE FROM award_awards_projectcategories WHERE award_awards_id=? " );
$q -> execute ([ $id ]);
2025-01-29 03:30:48 +00:00
foreach ( $_POST [ 'categories' ] AS $key => $cat ) {
2025-01-28 17:33:03 -05:00
$c = intval ( $cat );
2025-01-29 03:30:48 +00:00
$q = $pdo -> prepare ( ' INSERT INTO award_awards_projectcategories ( award_awards_id , projectcategories_id , year )
VALUES ( : id , : c , : year ) ' );
2025-01-28 17:33:03 -05:00
$q -> bindParam ( ':id' , $id , PDO :: PARAM_INT );
$q -> bindParam ( ':c' , $c , PDO :: PARAM_INT );
$q -> bindParam ( ':year' , $config [ 'FAIRYEAR' ], PDO :: PARAM_INT );
$q -> execute ();
}
2025-01-29 03:30:48 +00:00
// wipe out any old award-divisions links
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " DELETE FROM award_awards_projectdivisions WHERE award_awards_id=? " );
$q -> execute ([ $id ]);
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
// now add the new ones
foreach ( $_POST [ 'divisions' ] AS $key => $div ) {
2025-01-28 17:33:03 -05:00
$d = intval ( $div );
2025-01-29 03:30:48 +00:00
$q = $pdo -> prepare ( ' INSERT INTO award_awards_projectdivisions ( award_awards_id , projectdivisions_id , year )
VALUES ( : id , : d , : year ) ' );
2025-01-28 17:33:03 -05:00
$q -> bindParam ( ':id' , $id , PDO :: PARAM_INT );
$q -> bindParam ( ':d' , $d , PDO :: PARAM_INT );
$q -> bindParam ( ':year' , $config [ 'FAIRYEAR' ], PDO :: PARAM_INT );
2009-09-09 00:26:12 +00:00
2025-01-28 17:33:03 -05:00
$q -> execute ();
show_pdo_errors_if_any ( $pdo );
}
2025-01-29 03:30:48 +00:00
happy_ ( 'Eligibility information saved' );
2009-09-10 08:29:16 +00:00
exit ;
2025-01-28 17:33:03 -05:00
case 'prize_order' :
$order = 0 ;
2025-01-29 03:30:48 +00:00
foreach ( $_GET [ 'prizelist' ] as $position => $id ) {
if ( $id == '' )
continue ;
2025-01-28 17:33:03 -05:00
$order ++ ;
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " UPDATE `award_prizes` SET `order`=? WHERE `id`=? " );
$q -> execute ([ $order , $id ]);
2025-01-29 03:30:48 +00:00
}
// print_r($_GET);
happy_ ( 'Order Updated.' );
2025-01-28 17:33:03 -05:00
exit ;
case 'award_order' :
$order = 0 ;
2025-01-29 03:30:48 +00:00
foreach ( $_GET [ 'awardlist' ] as $position => $id ) {
if ( $id == '' )
continue ;
2025-01-28 17:33:03 -05:00
$order ++ ;
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " UPDATE `award_awards` SET `order`=? WHERE `id`=? " );
$q -> execute ([ $order , $id ]);
2025-01-28 17:33:03 -05:00
}
2025-01-29 03:30:48 +00:00
happy_ ( 'Order updated' );
2025-01-28 17:33:03 -05:00
exit ;
case 'prizeinfo_load' :
$id = intval ( $_GET [ 'id' ]);
2025-01-29 03:30:48 +00:00
if ( $id == - 1 ) {
2025-02-09 18:41:20 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order` " );
2025-01-28 17:33:03 -05:00
$q -> execute ();
} else {
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_prizes WHERE award_awards_id=? ORDER BY `order` " );
$q -> execute ([ $id ]);
2025-01-28 17:33:03 -05:00
}
2025-01-29 03:30:48 +00:00
while ( $r = $q -> fetch ( PDO :: FETCH_ASSOC )) {
foreach ( $r AS $k => $v ) {
$r [ $k ] = iconv ( 'ISO-8859-1' , 'UTF-8' , $v );
2025-01-28 17:33:03 -05:00
}
$ret [] = $r ;
}
echo json_encode ( $ret );
exit ;
case 'prize_load' :
$id = intval ( $_GET [ 'id' ]);
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_prizes WHERE id=? " );
$q -> execute ([ $id ]);
2025-01-28 17:33:03 -05:00
$ret = $q -> fetch ( PDO :: FETCH_ASSOC );
2025-01-29 03:30:48 +00:00
foreach ( $ret AS $k => $v ) {
$ret [ $k ] = iconv ( 'ISO-8859-1' , 'UTF-8' , $v );
2025-01-28 17:33:03 -05:00
}
echo json_encode ( $ret );
exit ;
2009-09-10 08:29:16 +00:00
2025-01-28 17:33:03 -05:00
case 'prize_create' :
$aaid = intval ( $_GET [ 'award_awards_id' ]);
$year = $config [ 'FAIRYEAR' ];
2025-01-29 03:30:48 +00:00
if ( $aaid == - 1 ) {
2025-01-28 17:33:03 -05:00
$aaid = 0 ;
$year = - 1 ;
}
2025-01-29 03:30:48 +00:00
$q = $pdo -> prepare ( 'INSERT INTO award_prizes (award_awards_id, year) VALUES (:aaid, :year)' );
2025-01-28 17:33:03 -05:00
$q -> bindParam ( ':aaid' , $aaid , PDO :: PARAM_INT );
$q -> bindParam ( ':year' , $year , PDO :: PARAM_INT );
2009-09-10 08:29:16 +00:00
2024-12-06 20:54:02 -05:00
$q -> execute ();
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
$ret = array ( 'id' => $pdo -> lastInsertId ());
2025-01-28 17:33:03 -05:00
echo json_encode ( $ret );
exit ;
case 'prize_save' :
$id = intval ( $_POST [ 'id' ]);
2025-01-29 03:30:48 +00:00
$q = $pdo -> prepare ( ' UPDATE award_prizes SET
2025-01-28 17:33:03 -05:00
prize = : prize ,
cash = : cash ,
scholarship = : scholarship ,
value = : value ,
number = : number ,
excludefromac = : excludefromac ,
trophystudentkeeper = : trophystudentkeeper ,
trophystudentreturn = : trophystudentreturn ,
trophyschoolkeeper = : trophyschoolkeeper ,
trophyschoolreturn = : trophyschoolreturn
2025-01-29 03:30:48 +00:00
WHERE id = : id ' );
$q -> bindParam ( ':prize' , stripslashes ( iconv ( 'UTF-8' , 'ISO-8859-1' , $_POST [ 'prize' ])), PDO :: PARAM_STR );
2025-02-09 18:41:20 +00:00
$q -> bindValue ( ':cash' , intval ( $_POST [ 'cash' ]), PDO :: PARAM_INT );
$q -> bindValue ( ':scholarship' , intval ( $_POST [ 'scholarship' ]), PDO :: PARAM_INT );
$q -> bindValue ( ':value' , intval ( $_POST [ 'value' ]), PDO :: PARAM_INT );
$q -> bindValue ( ':number' , intval ( $_POST [ 'number' ]), PDO :: PARAM_INT );
$q -> bindValue ( ':excludefromac' , ( $_POST [ 'excludefromac' ] == 1 ) ? 1 : 0 , PDO :: PARAM_INT );
$q -> bindValue ( ':trophystudentkeeper' , ( $_POST [ 'trophystudentkeeper' ] == 1 ) ? 1 : 0 , PDO :: PARAM_INT );
$q -> bindValue ( ':trophystudentreturn' , ( $_POST [ 'trophystudentreturn' ] == 1 ) ? 1 : 0 , PDO :: PARAM_INT );
$q -> bindValue ( ':trophyschoolkeeper' , ( $_POST [ 'trophyschoolkeeper' ] == 1 ) ? 1 : 0 , PDO :: PARAM_INT );
$q -> bindValue ( ':trophyschoolreturn' , ( $_POST [ 'trophyschoolreturn' ] == 1 ) ? 1 : 0 , PDO :: PARAM_INT );
$q -> bindValue ( ':id' , $id , PDO :: PARAM_INT );
2025-01-28 17:33:03 -05:00
2024-12-06 20:54:02 -05:00
$q -> execute ();
2009-09-10 01:23:58 +00:00
2025-01-29 03:30:48 +00:00
happy_ ( 'Prize saved' );
2025-01-28 17:33:03 -05:00
exit ;
case 'prize_delete' :
$id = intval ( $_GET [ 'id' ]);
award_prize_delete ( $id );
2025-01-29 03:30:48 +00:00
happy_ ( 'Prize deleted' );
2025-01-28 17:33:03 -05:00
exit ;
case 'feeder_load' :
$id = intval ( $_GET [ 'id' ]);
/* Prepare two lists of fair IDs, for which fairs can upload and download this award */
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " SELECT * FROM fairs_awards_link WHERE award_awards_id=? " );
$q -> execute ([ $id ]);
2025-01-29 03:30:48 +00:00
$ul = array ();
2025-01-28 17:33:03 -05:00
$dl = array ();
2025-01-29 03:30:48 +00:00
while ( $r = $q -> fetch ( PDO :: FETCH_ASSOC )) {
if ( $r [ 'upload_winners' ] == 'yes' )
$ul [ $r [ 'fairs_id' ]] = true ;
if ( $r [ 'download_award' ] == 'yes' )
$dl [ $r [ 'fairs_id' ]] = true ;
2025-01-28 17:33:03 -05:00
}
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " SELECT * FROM award_awards WHERE id=? " );
$q -> execute ([ $id ]);
2025-01-28 17:33:03 -05:00
$a = $q -> fetch ( PDO :: FETCH_ASSOC );
2025-01-29 03:30:48 +00:00
?>
< h4 >< ? = i18n ( 'Feeder Fairs' ) ?> </h4>
2025-01-28 17:33:03 -05:00
< form id = " feeder_form " >
2025-01-29 03:30:48 +00:00
< input type = " hidden " id = " feeder_id " name = " award_awards_id " value = " <?= $a['id'] ?> " />
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
< ? $ch = $a [ 'per_fair' ] == 'yes' ? 'checked="checked"' : '' ; ?>
< p >< input type = " checkbox " name = " per_fair " value = " yes " < ? = $ch ?> />
< ? = i18n ( 'Treat this award as a separate award for each feeder fair (instead of as a single award across the whole system). This will allow winners to be assigned to prizes for each feeder fair. If disabled, only a single group if winners will be permitted across all feeder fairs.' ) ?> </p>
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
< ? $ch = ( count ( $ul ) || count ( $dl )) ? 'checked="checked"' : '' ; ?>
< p >< input type = " checkbox " id = " feeder_enable " name = " enable " value = " yes " < ? = $ch ?> />
< ? = i18n ( 'Allow feeder fairs to download this award.' ) ?> </p>
2025-01-28 17:33:03 -05:00
< div id = " feeder_en " >
< table class = " editor " >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Unique Name' ) ?> :</td>
< td >< input type = " text " name = " identifier " value = " <?= $a['external_identifier'] ?> " size = " 40 " maxlength = " 128 " /></ td ></ tr >
< ? $ch = $a [ 'external_additional_materials' ] ? 'checked="checked"' : '' ; ?>
< tr >< td >< input type = " checkbox " name = " register_winners " value = " 1 " < ? = $ch ?> /></td>
< td >< ? = i18n ( 'Winners uploaded by a feeder fair should be registered as participants at this fair (both download award and upload winners should be turned on below)' ) ?> </td></tr>
< ? $ch = $a [ 'external_register_winners' ] ? 'checked="checked"' : '' ; ?>
< tr >< td >< input type = " checkbox " name = " additional_materials " value = " 1 " < ? = $ch ?> /></td>
< td >< ? = i18n ( 'There is additional material for this award (e.g. forms, instructions). If a feeder fair assigns a winner to this award, they will be told they need to contact this fair to get the additional material.' ) ?> </td></tr>
2025-01-28 17:33:03 -05:00
</ table >
2025-01-29 03:30:48 +00:00
< p >< ? = i18n ( 'Select which feeder fairs can download this award and upload winners.' ) ?> </p>
2025-01-28 17:33:03 -05:00
< table class = " tableview " >
2025-01-29 03:30:48 +00:00
< tr >< th >< ? = i18n ( 'Fair' ) ?> </th>
< th style = " width: 5em " >< ? = i18n ( 'Download Award' ) ?> </th>
< th style = " width: 5em " >< ? = i18n ( 'Upload Winners' ) ?> </th>
2025-01-28 17:33:03 -05:00
</ tr >
< ?
2025-01-29 03:30:48 +00:00
$q = $pdo -> prepare ( " SELECT * FROM fairs WHERE type='feeder' " );
$q -> execute ();
while ( $r = $q -> fetch ( PDO :: FETCH_ASSOC )) {
echo " <tr><td style= \" padding-left:1em;padding-right:1em \" > { $r [ 'name' ] } </td> " ;
$ch = $dl [ $r [ 'id' ]] == true ? 'checked="checked"' : '' ;
echo " <td style= \" text-align:center \" ><input type= \" checkbox \" name= \" feeder_dl[] \" value= \" { $r [ 'id' ] } \" $ch ></td> " ;
$ch = $ul [ $r [ 'id' ]] == true ? 'checked="checked"' : '' ;
echo " <td style= \" text-align:center \" ><input type= \" checkbox \" name= \" feeder_ul[] \" value= \" { $r [ 'id' ] } \" $ch ></td> " ;
echo '</tr>' ;
}
2025-01-28 17:33:03 -05:00
?>
</ table >
</ div >
< br />
2025-01-29 03:30:48 +00:00
< button id = " feeder_save " >< ? = i18n ( 'Save' ) ?> </button>
2025-01-28 17:33:03 -05:00
</ form >
< ?
exit ;
2009-09-13 07:08:12 +00:00
2025-01-28 17:33:03 -05:00
case 'feeder_save' :
$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 ();
2009-09-13 07:08:12 +00:00
2025-01-28 17:33:03 -05:00
/* Prepare a fair-wise list */
$data = array ();
2025-01-29 03:30:48 +00:00
foreach ( $dl AS $fairs_id )
$data [ $fairs_id ][ 'dl' ] = true ;
foreach ( $ul AS $fairs_id )
$data [ $fairs_id ][ 'ul' ] = true ;
2009-09-13 07:08:12 +00:00
2025-01-28 17:33:03 -05:00
/* Now save each one */
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " DELETE FROM fairs_awards_link WHERE award_awards_id=? " );
$q -> execute ([ $id ]);
2025-01-03 14:55:12 -05:00
show_pdo_errors_if_any ( $pdo );
2025-01-29 03:30:48 +00:00
foreach ( $data as $fairs_id => $f ) {
2025-01-28 17:33:03 -05:00
$dl = ( $f [ 'dl' ] == true ) ? 'yes' : 'no' ;
$ul = ( $f [ 'ul' ] == true ) ? 'yes' : 'no' ;
2025-01-29 03:30:48 +00:00
2025-01-28 17:33:03 -05:00
$q = $pdo -> prepare ( " INSERT INTO fairs_awards_link (award_awards_id,fairs_id,download_award,upload_winners)
2025-02-09 17:24:37 +00:00
VALUES ( ? , ? , ? , ? ) " );
$q -> execute ([ $id , $fairs_id , $dl , $ul ]);
2025-01-28 17:33:03 -05:00
show_pdo_errors_if_any ( $pdo );
}
2025-01-29 03:30:48 +00:00
$ident = stripslashes ( $_POST [ 'identifier' ]);
2025-01-28 17:33:03 -05:00
$per_fair = $_POST [ 'per_fair' ] == 'yes' ? 'yes' : 'no' ;
$mat = intval ( $_POST [ 'additional_materials' ]);
$w = intval ( $_POST [ 'register_winners' ]);
2025-01-29 03:30:48 +00:00
2025-02-09 17:24:37 +00:00
$q = $pdo -> prepare ( " UPDATE award_awards SET external_identifier=?,
external_additional_materials = ? ,
external_register_winners = ? ,
per_fair = ?
WHERE id = ? " );
$q -> execute ([[ $ident , $mat , $w ], $per_fair , $id ]);
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
happy_ ( 'Feeder Fair information saved' );
2025-01-28 17:33:03 -05:00
exit ;
2025-01-29 03:30:48 +00:00
}
2009-09-09 00:26:12 +00:00
2025-01-29 03:30:48 +00:00
send_header ( 'Awards Management' ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'Awards Main' => 'admin/awards.php' ));
2009-09-09 00:26:12 +00:00
2025-01-29 03:30:48 +00:00
?>
2025-01-28 17:33:03 -05: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 ;
2009-09-20 18:45:32 +00:00
var award_tab_update = new Array ();
2009-09-09 00:26:12 +00:00
2025-02-09 18:41:20 +00:00
2009-09-09 00:26:12 +00:00
function update_awardinfo ()
2025-02-09 18:41:20 +00:00
{
2009-09-20 18:45:32 +00:00
if ( award_tab_update [ 'awardinfo' ] == award_id ) return ;
award_tab_update [ 'awardinfo' ] = award_id ;
2009-09-18 07:50:32 +00:00
// alert(award_id);
if ( award_id == - 1 ) {
2009-09-20 19:25:42 +00:00
// $("#awardinfo input:text").val('');
2009-09-18 07:50:32 +00:00
/* New award, set defaults and clear everythign else */
$ ( " #awardinfo_id " ) . val ( - 1 );
$ ( " #awardinfo_name " ) . val ( " " );
$ ( " #awardinfo_sponsors_id " ) . val ( 0 );
$ ( " #awardinfo_presenter " ) . val ( " " );
$ ( " #awardinfo_description " ) . val ( " " );
$ ( " #awardinfo_criteria " ) . val ( " " );
$ ( " #awardinfo_award_types_id " ) . val ( 5 );
// For some reason, with checkboxes, these have to be arrays
$ ( " #awardinfo_excludefromac " ) . val ([]);
$ ( " #awardinfo_cwsfaward " ) . val ([]);
$ ( " #awardinfo_selfnominate " ) . val ([ " yes " ]);
$ ( " #awardinfo_schedulejudges " ) . val ([ " yes " ]);
return ;
}
2009-09-19 08:06:21 +00:00
/* Enable all fields */
2009-09-20 21:50:51 +00:00
$ ( " #awardinfo * " ) . removeAttr ( 'disabled' );
2009-09-19 08:06:21 +00:00
2025-01-29 03:30:48 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=awardinfo_load&id= " + award_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 );
2009-09-20 18:45:32 +00:00
$ ( " #awardinfo_award_source_fairs_id " ) . val ( json . award_source_fairs_id );
2009-09-09 00:26:12 +00:00
$ ( " #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-18 07:50:32 +00:00
2009-09-19 08:14:59 +00:00
/* Disable fields we don ' t want the user to edit
* for downloaded awards */
2025-01-28 17:33:03 -05:00
if ( json . award_source_fairs_id > 0 ) {
2009-09-20 21:50:51 +00:00
$ ( " #awardinfo_name " ) . attr ( 'disabled' , 'disabled' );
$ ( " #awardinfo_sponsors_id " ) . attr ( 'disabled' , 'disabled' );
$ ( " #awardinfo_criteria " ) . attr ( 'disabled' , 'disabled' );
2009-09-19 08:06:21 +00:00
}
2009-09-20 18:45:32 +00:00
/* Update the dialog title */
2025-01-29 03:30:48 +00:00
$ ( '#popup_editor' ) . dialog ( 'option' , 'title' , " <?= i18n('Award') ?>: " + $ ( '#awardinfo_name' ) . val ());
2009-09-20 18:45:32 +00:00
/* Update the status */
2025-01-28 17:33:03 -05:00
if ( $ ( '#awardinfo_award_source_fairs_id' ) . val () != 0 ) {
2025-01-29 03:30:48 +00:00
$ ( '#popup_status' ) . html ( " <?= addslashes(notice(i18n('This award was downloaded, some fields are not edittable'))) ?> " );
2009-09-20 18:45:32 +00:00
} else {
$ ( '#popup_status' ) . html ( " " );
}
2009-09-09 00:26:12 +00:00
});
}
2009-09-10 08:56:58 +00:00
function awardinfo_save ()
2009-09-09 00:26:12 +00:00
{
2009-09-18 07:50:32 +00:00
var reload = ( award_id == - 1 ) ? true : false ;
/* This is sneaky , we ' re going to make the awardinfo_save possibly emit
* javascript to set a new award_id , so it will ALWAYS be correct
* after the . load finishes */
2025-01-29 03:30:48 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=awardinfo_save " , $ ( " #awardinfo " ) . serializeArray (),
2009-09-18 07:50:32 +00:00
function ( responseText , textStatus , XMLHttpRequest )
{
/* At this point, award_id has been updated by the load */
/* We want to do this AFTER the load completes .
* Somehow , the value of reload properly makes
* it into this function */
if ( reload ) {
$ ( " #popup_editor " ) . dialog ( 'close' );
popup_editor ( award_id , '' );
}
});
return false ;
2009-09-09 00:26:12 +00:00
}
function update_eligibility ()
{
2009-09-20 18:45:32 +00:00
if ( award_tab_update [ 'eligibility' ] == award_id ) return ;
award_tab_update [ 'eligibility' ] = award_id ;
2025-01-29 03:30:48 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=eligibility_load&id= " + award_id ,
2009-09-09 00:26:12 +00:00
function ( json ){
2009-09-10 08:56:58 +00:00
$ ( " [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 ()
{
2025-01-28 17:33:03 -05:00
//FIXME Table DnD remove CANNOT reorder prizes now or open to edit, create new award not working either (test the rest of the software)
2009-09-10 08:56:58 +00:00
$ ( " #prizelist " ) . tableDnD ({
onDrop : function ( table , row ) {
var order = $ . tableDnD . serialize ();
2025-01-29 03:30:48 +00:00
$ ( " #prizeinfo_info " ) . load ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_order& " + order );
2009-09-10 08:56:58 +00:00
/* Change the order */
var rows = table . tBodies [ 0 ] . rows ;
for ( var i = 0 ; i < rows . length ; i ++ ) {
$ ( " #prizelist_order_ " + rows [ i ] . id ) . html ( i );
}
},
2010-01-21 20:48:18 +00:00
dragHandle : " drag_handle "
2009-09-10 08:56:58 +00:00
});
}
2009-09-10 17:32:16 +00:00
2009-09-10 01:23:58 +00:00
function update_prizeinfo ()
{
2009-09-20 18:45:32 +00:00
/* We can ' t do this filtering here , sometimes we need to fiorce
* a prizeinfo reload */
// if(award_tab_update['prizeinfo'] == award_id) return;
// award_tab_update['prizeinfo'] = award_id;
2009-09-18 07:50:32 +00:00
/* This also works for the prize template, id=-1 */
2025-01-29 03:30:48 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prizeinfo_load&id= " + award_id ,
2009-09-10 01:23:58 +00:00
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; \" > " +
2025-01-29 03:30:48 +00:00
" <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> " +
2009-09-10 08:29:16 +00:00
" </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 )
{
2025-01-29 03:30:48 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_load&id= " + id ,
2009-09-10 01:23:58 +00:00
function ( json ){
2025-01-29 03:30:48 +00:00
$ ( " #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-21 01:33:55 +00:00
$ ( " #eligibility_award_awards_id " ) . val ( award_id );
2025-01-29 03:30:48 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=eligibility_save " , $ ( " #eligibility " ) . serializeArray ());
2009-09-18 07:50:32 +00:00
return false ;
2009-09-10 08:56:58 +00:00
}
2009-09-10 01:23:58 +00:00
function prize_save ()
{
2025-01-29 03:30:48 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=prize_save " , $ ( " #prizeinfo " ) . serializeArray (),
2009-09-26 08:11:34 +00:00
function ( responseText , textStatus , XMLHttpRequest )
{
update_prizeinfo ();
});
2009-09-18 07:50:32 +00:00
return false ;
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 ) {
2025-01-29 03:30:48 +00:00
$ ( " #prizeinfo_info " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=prize_delete&id= " + id , null ,
2009-09-26 08:11:34 +00:00
function ( responseText , textStatus , XMLHttpRequest )
{
$ ( " .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 ()
{
2025-01-29 03:30:48 +00:00
$ . getJSON ( " <?= $_SERVER['PHP_SELF'] ?>?action=prize_create&award_awards_id= " + award_id ,
2009-09-10 17:32:16 +00:00
function ( json ){
$ ( " .prizeinfo " ) . val ( " " );
$ ( " #prizeinfo_id " ) . val ( json . id );
2025-01-29 03:30:48 +00:00
$ ( " #prizeinfo_edit_header " ) . html ( " <?= i18n('New Prize') ?> " );
2009-09-10 17:32:16 +00:00
$ ( " .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 ()
{
2009-09-20 18:45:32 +00:00
if ( award_tab_update [ 'feeder' ] == award_id ) return ;
award_tab_update [ 'feeder' ] = award_id ;
2010-01-27 20:24:17 +00:00
2025-01-29 03:30:48 +00:00
$ ( " #editor_tab_feeder " ) . load ( " <?= $_SERVER['PHP_SELF'] ?>?action=feeder_load&id= " + award_id , '' ,
2010-01-27 20:24:17 +00:00
function ( responseText , textStatus , XMLHttpRequest ) {
/* Register buttons and handlers */
$ ( " #feeder_enable " ) . change ( function () {
update_feeder_enable ();
});
$ ( " #feeder_save " ) . click ( function () {
2025-01-29 03:30:48 +00:00
$ ( " #debug " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=feeder_save " , $ ( " #feeder_form " ) . serializeArray ());
2010-01-27 20:24:17 +00:00
return false ;
});
2009-09-24 01:39:05 +00:00
update_feeder_enable ();
});
}
2009-09-13 08:33:54 +00:00
2009-09-24 01:39:05 +00:00
function update_feeder_enable ()
{
var checked = $ ( '#feeder_enable:checkbox' ) . is ( ':checked' );
if ( checked == true ) {
2010-01-27 20:24:17 +00:00
$ ( '#feeder_en *' ) . removeAttr ( 'disabled' );
2009-09-24 01:39:05 +00:00
} else {
2010-01-27 20:24:17 +00:00
$ ( " #feeder_en * " ) . attr ( 'disabled' , 'disabled' );
2009-09-24 01:39:05 +00:00
$ ( '#feeder_enable' ) . removeAttr ( 'disabled' );
}
2009-09-13 07:08:12 +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 () {
2025-02-09 18:41:20 +00:00
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-18 07:50:32 +00:00
draggable : false ,
2025-01-28 17:33:03 -05:00
create : function () {
2009-09-18 07:50:32 +00:00
var $tabs = $ ( '#editor_tabs' ) . tabs ();
var selected = $tabs . tabs ( 'option' , 'selected' );
if ( award_id == - 1 && selected == 0 ) {
2025-01-29 03:30:48 +00:00
notice_ ( " <?= i18n('New Award Cancelled') ?> " );
2025-01-28 17:33:03 -05:00
}
2009-09-18 07:50:32 +00:00
}
2009-09-09 17:06:11 +00:00
});
2009-09-10 22:52:04 +00:00
2009-09-11 06:12:17 +00:00
$ ( " #editor_tabs " ) . tabs ({
2025-02-09 18:41:20 +00:00
create : function ( event , ui ) {
update_awardinfo ();
update_eligibility ();
update_prizeinfo ();
update_feeder ();
},
activate : function ( event , ui ) {
2025-01-22 00:47:58 -05:00
update_awardinfo ();
update_eligibility ();
update_prizeinfo ();
update_feeder ();
},
2025-01-28 17:33:03 -05:00
active : - 1
2025-01-22 00:47:58 -05:00
});
// $("#editor_tabs").tabs({
// show: function(event, ui) {
// switch(ui.panel.id) {
// case 'editor_tab_awardinfo':
// update_awardinfo();
// break;
// case 'editor_tab_eligibility':
// update_eligibility();
// break;
// case 'editor_tab_prizes':
// update_prizeinfo();
// break;
// case 'editor_tab_feeder':
// update_feeder();
// break;
// }
// return true;
// },
// collapsible: true,
// selected: -1 /* None selected */
// });
2025-02-09 18:41:20 +00:00
})
2009-09-10 22:52:04 +00:00
2009-09-09 00:26:12 +00:00
</ script >
2009-09-20 18:45:32 +00:00
< ?
2025-01-29 03:30:48 +00:00
/* Begin popup */
2009-09-10 01:23:58 +00:00
?>
2009-09-20 18:45:32 +00:00
< div id = " popup_editor " title = " Award Editor " style = " display: none " >
< div id = " popup_status " ></ div >
2009-09-10 22:52:04 +00:00
< div id = " editor_tabs " >
2025-01-29 03:30:48 +00:00
< 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>
< 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 " >
2025-01-29 03:30:48 +00:00
< h4 >< ? = i18n ( 'Award Info' ) ?> </h4>
2009-09-20 18:45:32 +00:00
< form >
2025-01-29 03:30:48 +00:00
< ? /*
* We dont ' want to ever change this, but we want it' s value , so put it in
* a form by itself
*/
?>
2009-09-20 18:45:32 +00:00
< input type = " hidden " name = " award_source_fairs_id " id = " awardinfo_award_source_fairs_id " value = " 0 " />
</ form >
2009-09-10 01:23:58 +00:00
< form id = " awardinfo " >
< input type = " hidden " name = " id " id = " awardinfo_id " value = " 0 " />
2009-10-01 04:42:55 +00:00
< table class = " editor " >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Name' ) ?> :</td>
2009-09-26 08:11:34 +00:00
< td >< 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 >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Sponsor' ) ?> :</td><td>
2009-09-10 01:23:58 +00:00
< ?
2025-01-29 03:30:48 +00:00
$sq = $pdo -> prepare ( 'SELECT id,organization FROM sponsors ORDER BY organization' );
$sq -> execute ();
echo '<select id="awardinfo_sponsors_id" name="sponsors_id">' ;
echo '<option value="">' . i18n ( 'Choose a sponsor' ) . " </option> \n " ;
while ( $sr = $sq -> fetch ( PDO :: FETCH_OBJ )) {
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 >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Presenter' ) ?> :</td>
2009-09-26 08:11:34 +00:00
< td >< input type = " text " id = " awardinfo_presenter " name = " presenter " value = " Loading... " size = " 50 " maxlength = " 128 " />
2009-09-10 08:29:16 +00:00
</ td ></ tr >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Type' ) ?> :</td><td>
< ?
2025-02-09 17:24:37 +00:00
$tq = $pdo -> prepare ( " SELECT id,type FROM award_types WHERE year=? ORDER BY type " );
$tq -> execute ([ $config [ 'FAIRYEAR' ]]);
2025-01-29 03:30:48 +00:00
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 = $tq -> fetch ( PDO :: FETCH_OBJ )) {
echo " <option value= \" $tr->id\ " > " . i18n( $tr->type ) . '</option>';
}
2009-09-10 08:29:16 +00:00
?>
</ select ></ td ></ tr >
2025-01-29 03:30:48 +00:00
< tr >< td >< label >< ? = i18n ( 'Criteria' ) ?> :</label></td>
2009-09-26 08:11:34 +00:00
< td >< textarea class = " translatable " id = " awardinfo_criteria " name = " criteria " rows = " 3 " cols = " 50 " > Loading ...</ textarea ></ td ></ tr >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Description' ) ?> :</td>
2009-09-26 08:11:34 +00:00
< td >< 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-10-01 04:42:55 +00:00
< table class = " editor " >
< tr > < td >< input type = " checkbox " id = " awardinfo_excludefromac " name = " excludefromac " value = " 1 " ></ td >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Exclude this award from the award ceremony script' ) ?> </td>
2009-10-01 04:42:55 +00:00
</ tr >< tr >
< td >< input type = " checkbox " id = " awardinfo_cwsfaward " name = " cwsfaward " value = " 1 " ></ td >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'This award identifies the students that will be attending the Canada-Wide Science Fair' ) ?> </td>
2009-10-01 04:42:55 +00:00
</ tr >< tr >
< td >< input type = " checkbox " id = " awardinfo_selfnominate " name = " self_nominate " value = " yes " ></ td >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Students can self-nominate for this award (this is usually checked for special awards)' ) ?> </td>
2009-10-01 04:42:55 +00:00
</ tr >< tr >
< td >< input type = " checkbox " id = " awardinfo_schedulejudges " name = " schedule_judges " value = " yes " ></ td >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Allow the Automatic Judge Scheduler to assign judges to this award (usually checked)' ) ?> </td>
2009-10-01 04:42:55 +00:00
</ tr ></ table >
2009-09-18 07:50:32 +00:00
< input type = " submit " onClick = " awardinfo_save();return false; " value = " Save " />
</ form >
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 " >
2025-01-29 03:30:48 +00:00
< h4 >< ? = i18n ( 'Eligibility' ) ?> </h4>
2009-09-14 05:34:31 +00:00
< br />
2009-09-10 08:56:58 +00:00
< form id = " eligibility " >
2009-09-21 01:33:55 +00:00
< input type = " hidden " id = " eligibility_award_awards_id " name = " award_awards_id " value = " " />
2009-10-01 04:42:55 +00:00
< table class = " editor " >
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Age Categories' ) ?> :</td><td>
2009-09-10 08:29:16 +00:00
< ?
2009-09-09 00:26:12 +00:00
// if(count($currentcategories)==0) $class="class=\"error\""; else $class="";
2025-01-29 03:30:48 +00:00
// now select all the categories so we can list them all
2024-12-06 20:54:02 -05:00
2025-01-29 03:30:48 +00:00
$cq = $pdo -> prepare ( 'SELECT * FROM projectcategories WHERE year = :year ORDER BY mingrade' );
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
$cq -> bindParam ( ':year' , $config [ 'FAIRYEAR' ], PDO :: PARAM_INT );
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
$cq -> execute ();
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
show_pdo_errors_if_any ( $pdo );
while ( $cr = $cq -> fetch ( PDO :: FETCH_OBJ )) {
echo " <input type= \" checkbox \" id= \" eligibility_categories_ { $cr -> id } \" name= \" categories[] \" value= \" $cr->id\ " /> " . i18n( $cr->category ) . '<br />';
}
2009-09-10 08:56:58 +00:00
?>
</ td ></ tr >
2009-09-09 00:26:12 +00:00
2025-01-29 03:30:48 +00:00
< tr >< td >< ? = i18n ( 'Divisions' ) ?> :</td><td>
2009-09-10 08:56:58 +00:00
< ?
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
$dq = $pdo -> prepare ( 'SELECT * FROM projectdivisions WHERE year = :year ORDER BY division' );
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
$dq -> bindParam ( ':year' , $config [ 'FAIRYEAR' ], PDO :: PARAM_INT );
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
$dq -> execute ();
while ( $dr = $dq -> fetch ( PDO :: FETCH_OBJ )) {
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 >
2009-09-18 07:50:32 +00:00
< input type = " submit " onClick = " eligibility_save();return false; " value = " Save " />
2009-09-10 08:56:58 +00:00
</ form >
2009-09-10 22:52:04 +00:00
</ div >
2009-09-09 00:26:12 +00:00
2025-01-29 03:30:48 +00:00
< ? /* Next Tab */ ?>
2009-09-10 22:52:04 +00:00
< div id = " editor_tab_prizes " >
2025-01-29 03:30:48 +00:00
< h4 >< ? = i18n ( 'Prizes' ) ?> </h4>
2009-09-10 08:29:16 +00:00
< br />
< table id = " prizelist " class = " tableview " >
< tr class = " nodrop nodrag " >
2025-01-29 03:30:48 +00:00
< 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>
2009-09-10 08:29:16 +00:00
</ tr ></ table >
2009-09-10 01:23:58 +00:00
< br >
2025-01-29 03:30:48 +00:00
* < ? = i18n ( 'Click on the Script Order and drag to re-order the prizes' ) ?>
2009-09-10 01:23:58 +00:00
< 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-10-01 04:42:55 +00:00
< table class = " editor " >
2009-09-14 05:34:31 +00:00
< tr >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Number available' ) ?> :</td>
2009-09-26 08:11:34 +00:00
< td >< input type = " text " id = " prizeinfo_number " class = " prizeinfo " name = " number " value = " " size = " 3 " maxlength = " 5 " disabled = " disabled " /></ td >
2009-09-14 05:34:31 +00:00
</ tr >< tr >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Prize Description' ) ?> :</td>
2009-09-26 08:11:34 +00:00
< td >< 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 >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Cash Amount' ) ?> ($):</td>
2009-09-26 08:11:34 +00:00
< td >< 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 >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Scholarship Amount' ) ?> ($):</td>
2009-09-26 08:11:34 +00:00
< td >< 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 >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Prize Value' ) ?> ($):</td>
2009-09-26 08:11:34 +00:00
< td >< 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 >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Plaque/Trophy' ) ?> :</td>
2009-09-26 08:11:34 +00:00
< td >
< table >
< tr > < td style = " width:5%; " >< input type = " checkbox " id = " prizeinfo_trophystudentkeeper " class = " prizeinfo " name = " trophystudentkeeper " value = " 1 " disabled = " disabled " ></ td >
2025-01-29 03:30:48 +00:00
< td style = " width:45% " >< ? = i18n ( 'Student(s) keeper trophy' ) ?> </td>
2009-10-01 04:42:55 +00:00
< td style = " width:5%; " >< input type = " checkbox " id = " prizeinfo_trophystudentreturn " class = " prizeinfo " name = " trophystudentreturn " value = " 1 " disabled = " disabled " ></ td >
2025-01-29 03:30:48 +00:00
< td style = " width:45% " >< ? = i18n ( 'Student(s) annual return/reuse trophy' ) ?> </td>
2009-09-09 17:06:11 +00:00
</ tr >< tr >
2009-09-26 08:11:34 +00:00
< td style = " width:5%; " >< input type = " checkbox " id = " prizeinfo_trophyschoolkeeper " class = " prizeinfo " name = " trophyschoolkeeper " value = " 1 " disabled = " disabled " ></ td >
2025-01-29 03:30:48 +00:00
< td style = " width:45%; " >< ? = i18n ( 'School keeper trophy' ) ?> </td>
2009-09-26 08:11:34 +00:00
< td style = " width:5%; " >< input type = " checkbox " id = " prizeinfo_trophyschoolreturn " class = " prizeinfo " name = " trophyschoolreturn " value = " 1 " disabled = " disabled " ></ td >
2025-01-29 03:30:48 +00:00
< td style = " width:45%; " >< ? = i18n ( 'School annual return/reuse trophy' ) ?> </td>
2009-09-09 17:06:11 +00:00
</ tr ></ table ></ td >
</ tr >< tr >
2025-01-29 03:30:48 +00:00
< td >< ? = i18n ( 'Awards Ceremony' ) ?> :</td>
< td >< 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 />
2009-09-18 07:50:32 +00:00
< form >
2025-01-29 03:30:48 +00:00
< input type = " submit " onClick = " prize_create();return false; " value = " <?= i18n('Create New Prize') ?> " />
< input type = " submit " id = " prizeinfo_save " onClick = " prize_save();return false; " value = " <?= i18n('Save Prize') ?> " disabled = " disabled " />
2009-09-18 07:50:32 +00:00
</ form >
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 */ ?>
2010-01-27 20:24:17 +00:00
< div id = " editor_tab_feeder " ></ 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
< ?
2025-01-29 03:30:48 +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 08:29:16 +00:00
?>
2009-09-10 22:52:04 +00:00
2009-09-10 08:29:16 +00:00
< script type = " text/javascript " >
2009-09-18 07:50:32 +00:00
function popup_editor ( id , mode )
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
award_id = id ;
2009-09-20 18:45:32 +00:00
/* We don 't really need this, but we' ll force all the tabs to reload on
* activation anyway */
award_tab_update = new Array ();
2009-09-18 07:50:32 +00:00
/* Force no tabs to be selected , need to set collapsible
* to true first */
$ ( '#editor_tabs' ) . tabs ( 'option' , 'collapsible' , true );
$ ( '#editor_tabs' ) . tabs ( 'option' , 'selected' , - 1 );
/* Then we'll select a tab to force a reload */
switch ( mode ) {
case 'new' :
$ ( '#editor_tabs' ) . tabs ( 'option' , 'disabled' , [ 1 , 2 , 3 ]);
2025-02-09 18:41:20 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'active' , 0 );
2009-09-18 07:50:32 +00:00
break ;
case 'template' :
2009-09-17 19:25:14 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'disabled' , [ 0 , 1 , 3 ]);
2025-02-09 18:41:20 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'active' , 2 );
2009-09-18 07:50:32 +00:00
break ;
default :
2009-09-10 22:52:04 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'disabled' , []);
2025-02-09 18:41:20 +00:00
$ ( '#editor_tabs' ) . tabs ( 'option' , 'active' , 0 );
2009-09-18 07:50:32 +00:00
break ;
2009-09-10 17:32:16 +00:00
}
2009-09-18 07:50:32 +00:00
/* Don't let anything collapse */
$ ( '#editor_tabs' ) . tabs ( 'option' , 'collapsible' , false );
2009-09-20 18:45:32 +00:00
/* Force an awardinfo update, there's some info in there that we want now */
update_awardinfo ();
2009-09-18 07:50:32 +00:00
/* Show the dialog */
$ ( '#popup_editor' ) . dialog ( 'option' , 'width' , w );
$ ( '#popup_editor' ) . dialog ( 'option' , 'height' , h );
$ ( " #popup_editor " ) . dialog ( 'open' );
2009-09-20 18:45:32 +00:00
2009-09-18 07:50:32 +00:00
return true ;
2009-09-10 08:29:16 +00:00
}
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);
2025-01-29 03:30:48 +00:00
$ ( " #award_info " ) . load ( " <?= $_SERVER['PHP_SELF'] ?>?action=award_order& " + order );
2009-09-10 08:56:58 +00:00
/* 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_delete ( id )
{
2025-01-29 03:30:48 +00:00
var conf = confirmClick ( '<?= i18n(' Are you sure you want to remove this award ? ') ?>' );
2009-09-10 08:29:16 +00:00
if ( conf == true ) {
2025-01-29 03:30:48 +00:00
$ ( " #info_info " ) . load ( " <? $_SERVER['PHP_SELF'] ?>?action=award_delete&id= " + id );
2009-09-10 08:29:16 +00:00
/* 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
});
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
2025-01-29 03:30:48 +00:00
/* List filtering */
if ( get_value_from_array ( $_GET , 'sponsors_id' ) && $_GET [ 'sponsors_id' ] != 'all' )
$_SESSION [ 'sponsors_id' ] = $_GET [ 'sponsors_id' ];
else if ( get_value_from_array ( $_GET , 'sponsors_id' ) == 'all' )
2009-09-10 08:29:16 +00:00
unset ( $_SESSION [ 'sponsors_id' ]);
2005-02-25 19:16:05 +00:00
2025-01-29 03:30:48 +00:00
if ( get_value_from_array ( $_GET , 'award_types_id' ) && $_GET [ 'award_types_id' ] != 'all' )
$_SESSION [ 'award_types_id' ] = $_GET [ 'award_types_id' ];
else if ( get_value_from_array ( $_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
/*
2025-01-29 03:30:48 +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 = get_value_from_array ( $_SESSION , 'award_types_id' );
$sponsors_id = get_value_from_array ( $_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 = $pdo -> prepare ( 'SELECT id,organization FROM sponsors ORDER BY organization' );
2024-12-06 20:54:02 -05:00
$q -> execute ();
2025-01-29 03:30:48 +00:00
echo '<select name="sponsors_id" onchange="document.forms.filterchange.submit()">' ;
echo '<option value="all">' . i18n ( 'All Sponsors' ) . '</option>' ;
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ )) {
if ( $r -> id == $sponsors_id ) {
$sel = 'selected="selected"' ;
$sponsors_organization = $r -> organization ;
2009-09-10 08:29:16 +00:00
} else
2025-01-29 03:30:48 +00:00
$sel = '' ;
echo " <option $sel value= \" $r->id\ " > " . i18n( $r->organization ) . '</option>';
2009-09-10 08:29:16 +00:00
}
2025-01-29 03:30:48 +00:00
echo '</select>' ;
echo '</td></tr>' ;
echo '<tr><td>' ;
2009-09-10 08:29:16 +00:00
2025-01-29 03:30:48 +00:00
$q = $pdo -> prepare ( 'SELECT id, type FROM award_types WHERE year = :year ORDER BY type' );
2025-01-28 17:33:03 -05:00
$q -> bindParam ( ':year' , $config [ 'FAIRYEAR' ], PDO :: PARAM_INT );
2024-12-06 20:54:02 -05:00
$q -> execute ();
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
echo '<select name="award_types_id" onchange="document.forms.filterchange.submit()">' ;
echo '<option value="all">' . i18n ( 'All Award Types' ) . '</option>' ;
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ )) {
if ( $r -> id == $award_types_id ) {
$sel = 'selected="selected"' ;
$award_types_type = $r -> type ;
2009-09-10 08:29:16 +00:00
} else
2025-01-29 03:30:48 +00:00
$sel = '' ;
echo " <option $sel value= \" $r->id\ " > " . i18n( $r->type ) . '</option>';
2009-09-10 08:29:16 +00:00
}
2025-01-29 03:30:48 +00:00
echo '</select>' ;
echo '</td><td>' ;
2008-03-20 20:37:33 +00:00
2009-09-09 00:26:12 +00:00
/*
2025-01-29 03:30:48 +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..
*
* 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 />
2009-09-17 17:10:02 +00:00
< form >
2025-01-29 03:30:48 +00:00
< input type = " button " onClick = " popup_editor(-1, 'new'); " value = " <?= i18n('Create New Award') ?> " />
< input type = " button " onClick = " popup_editor(-1, 'template'); " value = " <?= i18n('Edit Generic Prize Template') ?> " />
2009-09-17 17:10:02 +00:00
</ form >
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
< ?
2025-01-29 03:30:48 +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
2025-01-28 17:33:03 -05:00
$where_asi = $where_asi ? ? '' ;
$where_ati = $where_ati ? ? '' ;
2025-01-29 03:30:48 +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
2025-01-29 03:30:48 +00:00
$orderby = $orderby ? ? '' ;
2025-01-28 17:33:03 -05:00
2025-01-29 03:30:48 +00:00
if ( ! $orderby )
$orderby = 'ORDER BY `order`' ;
2025-01-28 17:33:03 -05:00
$q = $pdo -> prepare ( " SELECT
award_awards . id ,
award_awards . name ,
award_awards . order ,
award_awards . award_source_fairs_id ,
award_types . type ,
sponsors . organization
FROM
award_awards
LEFT JOIN sponsors ON sponsors . id = award_awards . sponsors_id
LEFT JOIN award_types ON award_types . id = award_awards . award_types_id
WHERE
2025-02-09 17:24:37 +00:00
award_awards . year = ?
2009-09-10 08:29:16 +00:00
$where_asi
$where_ati
2025-02-09 17:24:37 +00:00
AND \taward_types . year = ?
2025-01-28 17:33:03 -05:00
$orderby
" );
2025-02-09 17:24:37 +00:00
$q -> execute ([ $config [ 'FAIRYEAR' ], $config [ 'FAIRYEAR' ]]);
2025-01-28 17:33:03 -05:00
show_pdo_errors_if_any ( $pdo );
2005-02-25 19:16:05 +00:00
2025-01-29 03:30:48 +00:00
if ( $q -> rowCount ()) {
echo '* ' . i18n ( 'Click on the Script Order and drag to re-order the awards' );
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 = $q -> fetch ( PDO :: FETCH_OBJ )) {
if ( $r -> award_source_fairs_id ) {
$cl = 'externalaward' ;
$hasexternal = true ;
} else
$cl = '' ;
$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 " ;
2025-02-09 17:24:37 +00:00
$numq = $pdo -> prepare ( " SELECT SUM(number) AS num FROM award_prizes WHERE award_awards_id=? " );
$numq -> execute ([ $r -> id ]);
2025-01-29 03:30:48 +00:00
$numr = $numq -> fetch ( PDO :: FETCH_ASSOC );
if ( ! $numr [ 'num' ])
$numr [ 'num' ] = 0 ;
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 " ;
2009-09-10 08:29:16 +00:00
echo " </tr> \n " ;
}
2025-01-29 03:30:48 +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>";
2025-01-29 03:30:48 +00:00
if ( $_GET [ 'action' ] == 'edit_prize_template' ) {
?> <script type="text/javascript">
2009-09-17 19:30:32 +00:00
$ ( document ) . ready ( function () {
2009-09-18 07:50:32 +00:00
popup_editor ( - 1 , 'template' );
2009-09-17 19:30:32 +00:00
});
2009-09-10 17:32:16 +00:00
</ script >
< ?
2025-01-29 03:30:48 +00:00
}
2005-02-25 19:16:05 +00:00
2009-09-10 08:29:16 +00:00
send_footer ();
2025-01-29 03:30:48 +00:00
?>