science-ation/admin/donors_search.php
james f01eac5b7b Add a date class for all date entry boxes to use
Update fundraising dashboard to pull all To-Do list items from the corresponding database tables/fields
Update donor contacts code to not be crazy
Update donor organization info page as per carolyn's suggestions
2009-10-07 17:58:11 +00:00

99 lines
3.8 KiB
PHP

<?
/*
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');
echo "<br />\n";
//$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;
$numq=mysql_query("SELECT COUNT(id) AS num FROM fundraising_donations WHERE fiscalyear='".$config['FISCALYEAR']."' AND sponsors_id='$r->id'");
$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 &nbsp;";
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 &nbsp;";
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 &nbsp;";
// 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";
?>