Start fixing hte sponsor queries, add some debugging so we can see who's in the lists, commit so i can get daves help :)

This commit is contained in:
james 2009-09-18 15:57:35 +00:00
parent 51d3f692c7
commit 17c3e4a732
2 changed files with 47 additions and 2 deletions

View File

@ -45,14 +45,46 @@
"participants_complete_allyears"=>array("name"=>"Participants complete all years","query"=>
"SELECT DISTINCT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"),
"special_award_sponsors_confirmed"=>array("name"=>"Special award sponsors (confirmed only)","query"=>
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.award_sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_sponsors.confirmed='yes' AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
"sponsors"=>array("name"=>"Organization sponsors","query"=>
"SELECT id, organization, email FROM sponsors WHERE email!='' ORDER BY email"),
"sponsors_primarycontacts"=>array("name"=>"Organization sponsors (primary contacts)","query"=>
"SELECT uid, MAX(users.year) AS year, sponsors.organization, users.firstname, users.lastname, users.email, deleted, users_sponsor.primary
FROM sponsors,
users_sponsor,
users
WHERE
users.id=users_sponsor.users_id
AND users_sponsor.sponsors_id=sponsors.id
AND users.types LIKE '%sponsor%'
AND users.email!=''
GROUP BY uid
HAVING deleted='no' AND users_sponsor.primary='yes'
ORDER BY users.email
"),
"sponsors_allcontacts"=>array("name"=>"Organization sponsors (all contacts)","query"=>
"SELECT DISTINCT(users.email), sponsors.organization, users.firstname, users.lastname, users.email
FROM sponsors,
users_sponsor,
users
WHERE
users.id=users_sponsor.users_id
AND users_sponsor.sponsors_id=sponsors.id
AND users.types LIKE '%sponsor%'
AND users.deleted='no'
AND users.email!=''
ORDER BY users.email
"),
/*
"special_award_sponsors_unconfirmed"=>array("name"=>"Special award sponsors (unconfirmed only)","query"=>
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.award_sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_sponsors.confirmed='no' AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
"special_award_sponsors_all"=>array("name"=>"Special award sponsors (all)","query"=>
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.award_sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
*/
"school_principals"=>array("name"=>"School principals","query"=>
"SELECT school, principal AS firstname, schoolemail AS email FROM schools WHERE schools.year='".$config['FAIRYEAR']."' AND schoolemail!=''"),
"school_scienceheads"=>array("name"=>"School science heads","query"=>

View File

@ -115,10 +115,20 @@
echo "<tr><td><b>To:</b></td><td>";
echo "<select name=\"to\">";
echo " <option value=\"\">Choose Email Recipients</option>";
$str="";
foreach($mailqueries AS $k=>$mq)
{
$tq=mysql_query($mq['query']);
if(mysql_error()) {
echo mysql_error();
exit;
}
$num=mysql_num_rows($tq);
$str.="<h2>".$mq['name']." $num </h2>";
while($tr=mysql_fetch_object($tq)) {
$str.="[".$tr->uid."][".$tr->year."] ".$tr->firstname." ".$tr->lastname." &lt;{$tr->email}&gt;<br />";
}
echo " <option value=\"$k\">".i18n($mq['name'])." (".i18n("%1 recipients",array($num),array("number")).")</option>";
}
echo "</select>";
@ -149,6 +159,7 @@
echo "</td></tr>";
echo "</table>";
}
echo $str;
}
else if($_GET['action']=="reallysend" && $_GET['reallysend'] && $_GET['to'])
{
@ -296,6 +307,8 @@
echo "</tr>";
}
echo "</table>";
}
send_footer();