2009-09-30 22:38:38 +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 ) 2008 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 .
*/
?>
< ?
require ( " ../common.inc.php " );
require_once ( " ../user.inc.php " );
user_auth_required ( 'committee' , 'admin' );
//$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization");
//we want to show all years, infact that year field probably shouldnt even be there.
$sql = " " ;
if ( $_POST [ 'search' ]) $sql .= " AND organization LIKE '% " . mysql_real_escape_string ( $_POST [ 'search' ]) . " %' " ;
if ( count ( $_POST [ 'donortype' ])) {
$sql .= " AND (0 " ;
foreach ( $_POST [ 'donortype' ] AS $d ) {
$sql .= " OR donortype=' $d ' " ;
}
$sql .= " ) " ;
}
$query = " SELECT * FROM sponsors WHERE 1 $sql ORDER BY organization " ;
echo " query= $query " ;
$q = mysql_query ( $query );
echo " <table class= \" tableview \" > " ;
echo " <tr> " ;
echo " <th>Organization</th> " ;
echo " <th># of Sponsorships</th> " ;
echo " <th># of Awards</th> " ;
echo " <th># of Contacts</th> " ;
// echo " <th>Action</th>";
echo " </tr> \n " ;
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr> \n " ;
$eh = " style= \" cursor:pointer; \" onclick= \" open_editor( { $r -> id } ); \" " ;
echo " <td $eh > $r->organization </td> \n " ;
$numq = mysql_query ( " SELECT COUNT(id) AS num FROM award_awards WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' AND sponsors_id=' $r->id ' " );
$numr = mysql_fetch_object ( $numq );
$numawards = $numr -> num ;
2009-10-02 16:46:13 +00:00
$numq = mysql_query ( " SELECT COUNT(id) AS num FROM fundraising_donations WHERE fiscalyear=' " . $config [ 'FISCALYEAR' ] . " ' AND sponsors_id=' $r->id ' " );
2009-09-30 22:38:38 +00:00
$numr = mysql_fetch_object ( $numq );
$numsponsorships = $numr -> num ;
$numq = mysql_query ( " SELECT uid,MAX(year),firstname,lastname,deleted FROM users,users_sponsor WHERE types LIKE '%sponsor%' AND sponsors_id=' $r->id ' AND users_sponsor.users_id=users.id AND users.deleted='no' GROUP BY uid ORDER BY firstname " );
// $numq=mysql_query("SELECT DISTINCT(uid) FROM users_sponsor, users WHERE sponsors_id='$r->id' AND users_sponsor.users_id=users.id AND users.deleted='no'");
$numcontacts = mysql_num_rows ( $numq );
// $numr=mysql_fetch_object($numq);
// $numcontacts=$numr->num;
echo " <td align= \" center \" valign= \" top \" > " ;
echo " $numsponsorships " ;
echo " <a href= \" fundraising.php?sponsors_id= $r->id\ " >< img alt = \ " view \" border= \" 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/viewmag. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " </td> " ;
echo " <td align= \" center \" valign= \" top \" > " ;
echo " $numawards " ;
echo " <a href= \" award_awards.php?sponsors_id= $r->id\ " >< img alt = \ " view \" border= \" 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/viewmag. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " </td> " ;
echo " <td align= \" center \" valign= \" top \" > " ;
echo " $numcontacts " ;
// echo "<a href=\"sponsor_contacts.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo " </td> " ;
echo " </tr> \n " ;
}
echo " </table> \n " ;
?>