science-ation/admin/fundraising_campaigns_prospecting.php
james 5aa7cf541a Remove debugging from user.inc
Begin the searching in the prospecting tool
2009-10-09 00:42:47 +00:00

135 lines
4.8 KiB
PHP

<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 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');
require("fundraising_common.inc.php");
$userslist=array();
$otherlist=array();
if($_POST['donortype']=="organization") {
$q=mysql_query("SELECT id, organization AS name, address, address2, city, province_code, postalcode FROM sponsors ORDER BY name");
echo mysql_error();
if(!$_POST['contacttype'])
$contacttype=array("primary","secondary");
else
$contacttype=$_POST['contacttype'];
$primary="";
while($r=mysql_fetch_object($q)) {
foreach($contacttype AS $ct) {
switch($ct) {
case "primary":
$primary="yes";
break;
case "secondary":
$primary="no";
break;
}
$cq=mysql_query("SELECT * FROM users_sponsor WHERE `primary`='$primary' AND sponsors_id='$r->id'");
echo mysql_error();
while($cr=mysql_fetch_object($cq)) {
if(!$userslist[$cr->users_id])
$userslist[$cr->users_id]=user_load($cr->users_id);
}
}
}
}
else if($_POST['donortype']=="individual") {
if(!$_POST['individual_type'])
$individual_type=array("judge","teacher","sciencehead","principal","parent","mentor","committee","volunteer","students");
else
$individual_type=$_POST['individual_type'];
foreach($individual_type AS $t) {
switch($t) {
case "judge":
case "volunteer":
case "committee":
$query="SELECT *,MAX(year) FROM users WHERE types LIKE '%$t%' GROUP BY uid HAVING deleted='no' ORDER BY lastname,firstname";
$q=mysql_query($query);
echo mysql_error();
while($r=mysql_fetch_object($q)) {
if(!$userslist[$r->uid])
$userslist[$r->uid]=user_load_by_uid($r->uid);
}
break;
case "teacher":
$q=mysql_query("SELECT DISTINCT(teacheremail) AS email, teachername AS name FROM students ORDER BY teachername");
while($r=mysql_fetch_assoc($q)) {
$otherlist[]=$r;
}
break;
case "sciencehead":
$q=mysql_query("SELECT DISTINCT(scienceheademail) AS email, sciencehead AS name, scienceheadphone AS phone FROM schools WHERE year='{$config['FAIRYEAR']}' ORDER BY name");
while($r=mysql_fetch_assoc($q)) {
$otherlist[]=$r;
}
break;
case "principal":
$q=mysql_query("SELECT DISTINCT(schoolemail) AS email, principal AS name FROM schools WHERE year='{$config['FAIRYEAR']}' ORDER BY name");
while($r=mysql_fetch_assoc($q)) {
$otherlist[]=$r;
}
break;
case "parent":
//unfortunately, this doesnt exist anywhere in sfiab
break;
case "mentor":
$q=mysql_query("SELECT DISTINCT(email) AS email, CONCAT(firstname, ' ', lastname) AS name, phone FROM mentors ORDER BY email");
echo mysql_error();
while($r=mysql_fetch_assoc($q)) {
$otherlist[]=$r;
}
break;
case "students":
$q=mysql_query("SELECT DISTINCT(email) AS email, CONCAT(firstname, ' ', lastname) AS name, address, city, province, postalcode, phone FROM students ORDER BY email");
echo mysql_error();
while($r=mysql_fetch_assoc($q)) {
$otherlist[]=$r;
}
break;
}
}
}
$usersnum=count($userslist);
$othernum=count($otherlist);
echo "$usersnum users results <br />";
echo "$othernum other results <br />";
//print_r($userslist);
//print_r($otherlist);
echo "<br /><br />";
echo nl2br(print_r($_POST,true));
?>