/
EventAttendance.php
244 lines (231 loc) · 10.4 KB
/
EventAttendance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
/*******************************************************************************
*
* filename : Attendance.php
* last change : 2005-09-18
* website : http://www.churchdb.org
* copyright : Copyright 2005 Todd Pillars
*
* function : List all Church Events
*
* ChurchInfo 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; either version 2 of the License, or
* (at your option) any later version.
*
******************************************************************************/
require "Include/Config.php";
require "Include/Functions.php";
if ($_POST['Action']== "Retrieve" && !empty($_POST['Event']))
{
if ($_POST['Choice'] == "Attendees")
{
$sSQL = "SELECT t1.per_ID, t1.per_Title, t1.per_FirstName, t1.per_MiddleName, t1.per_LastName, t1.per_Suffix, t1.per_Email, t1.per_HomePhone, t1.per_Country, t1.per_MembershipDate, t4.fam_HomePhone, t4.fam_Country
FROM person_per AS t1, events_event AS t2, event_attend AS t3, family_fam AS t4
WHERE t1.per_ID = t3.person_id AND t2.event_id = t3.event_id AND t3.event_id = ".$_POST['Event']." AND t1.per_fam_ID = t4.fam_ID AND per_cls_ID IN ('1','2','5')
ORDER BY t1.per_LastName, t1.per_ID";
$sPageTitle = gettext("Event Attendees");
}
elseif ($_POST['Choice'] == "Nonattendees")
{
$aSQL = "SELECT DISTINCT(person_id) FROM event_attend WHERE event_id = ".$_POST['Event'];
$raOpps = RunQuery($aSQL);
while ($aRow = mysql_fetch_row($raOpps))
{
$aArr[] = $aRow[0];
}
if (count($aArr) > 0)
{
$aArrJoin = join(",",$aArr);
$sSQL = "SELECT t1.per_ID, t1.per_Title, t1.per_FirstName, t1.per_MiddleName, t1.per_LastName, t1.per_Suffix, t1.per_Email, t1.per_HomePhone, t1.per_Country, t1.per_MembershipDate, t2.fam_HomePhone, t2.fam_Country
FROM person_per AS t1, family_fam AS t2
WHERE t1.per_fam_ID = t2.fam_ID AND t1.per_ID NOT IN (".$aArrJoin.") AND per_cls_ID IN ('1','2','5')
ORDER BY t1.per_LastName, t1.per_ID";
}
else
{
$sSQL = "SELECT t1.per_ID, t1.per_Title, t1.per_FirstName, t1.per_MiddleName, t1.per_LastName, t1.per_Suffix, t1.per_Email, t1.per_HomePhone, t1.per_Country, t1.per_MembershipDate, t2.fam_HomePhone, t2.fam_Country
FROM person_per AS t1, family_fam AS t2
WHERE t1.per_fam_ID = t2.fam_ID AND per_cls_ID IN ('1','2','5')
ORDER BY t1.per_LastName, t1.per_ID";
}
$sPageTitle = gettext("Event Nonattendees");
}
elseif ($_POST['Choice'] == "Guests")
{
$sSQL = "SELECT t1.per_ID, t1.per_Title, t1.per_FirstName, t1.per_MiddleName, t1.per_LastName, t1.per_Suffix, t1.per_HomePhone, t1.per_Country
FROM person_per AS t1, events_event AS t2, event_attend AS t3
WHERE t1.per_ID = t3.person_id AND t2.event_id = t3.event_id AND t3.event_id = ".$_POST['Event']." AND per_cls_ID IN ('0','3')
ORDER BY t1.per_LastName, t1.per_ID";
$sPageTitle = gettext("Event Guests");
}
}
elseif ($_GET['Action']== "List" && !empty($_GET['Event']))
{
$sSQL = "SELECT * FROM events_event WHERE event_type = ".$_GET['Event']." ORDER BY event_start";
$sPageTitle = gettext("All ".$_GET['Type']." Events");
}
require "Include/Header.php";
?>
<table cellpadding="4" align="center" cellspacing="0" width="100%">
<tr>
<td align="center"><input type="button" class="icButton" <?php echo 'value="' . gettext("Back to Report Menu") . '"'; ?> Name="Exit" onclick="javascript:document.location='ReportList.php';"></td>
</tr>
</table>
<?php
// Get data for the form as it now exists..
$rsOpps = RunQuery($sSQL);
$numRows = mysql_num_rows($rsOpps);
// Create arrays of the attendees.
for ($row = 1; $row <= $numRows; $row++)
{
$aRow = mysql_fetch_assoc($rsOpps);
extract($aRow);
if ($_GET['Action'] == "List")
{
$aEventID[$row] = $event_id;
$aEventTitle[$row] = htmlentities(stripslashes($event_title),ENT_NOQUOTES, "UTF-8");
$aEventStartDateTime[$row] = $event_start;
}
else
{
$aPersonID[$row] = $per_ID;
$aTitle[$row] = $per_Title;
$aFistName[$row] = $per_FirstName;
$aMiddleName[$row] = $per_MiddleName;
$aLastName[$row] = $per_LastName;
$aSuffix[$row] = $per_Suffix;
$aEmail[$row] = $per_Email;
$aHomePhone[$row] = SelectWhichInfo(ExpandPhoneNumber($per_HomePhone,$per_Country,$dummy), ExpandPhoneNumber($fam_HomePhone,$fam_Country,$dummy), True);
}
}
// Construct the form
?>
<table cellpadding="4" align="center" cellspacing="0" width="60%">
<?php
if ($_GET['Action'] == "List" && $numRows > 0)
{
?>
<caption>
<h3><?php echo gettext("There ".($numRows == 1 ? "is ".$numRows." event":"are ".$numRows." events"))." in this category"; ?></h3>
</caption>
<tr class="TableHeader">
<td width="33%"><strong><?php echo gettext("Event Title"); ?></strong></td>
<td width="33%"><strong><?php echo gettext("Event Date"); ?></strong></td>
<td colspan="3" width="34%" align="center"><strong><?php echo gettext("Generate Report"); ?></strong></td>
</tr>
<?php
//Set the initial row color
$sRowClass = "RowColorA";
for ($row=1; $row <= $numRows; $row++)
{
//Alternate the row color
$sRowClass = AlternateRowStyle($sRowClass);
//Display the row
?>
<tr class="<?php echo $sRowClass; ?>">
<td class="TextColumn"><?php echo $aEventTitle[$row]; ?></td>
<td class="TextColumn"><?php echo FormatDate($aEventStartDateTime[$row],1); ?></td>
<td class="TextColumn" align="center">
<form name="Attend" action="EventAttendance.php" method="POST">
<input type="hidden" name="Event" value="<?php echo $aEventID[$row]; ?>">
<input type="hidden" name="Type" value="<?php echo $_GET['Type']; ?>">
<input type="hidden" name="Action" value="Retrieve">
<input type="hidden" name="Choice" value="Attendees">
<?php
$cSQL = "SELECT COUNT(per_ID) AS cCount
FROM person_per as t1, events_event as t2, event_attend as t3
WHERE t1.per_ID = t3.person_id AND t2.event_id = t3.event_id AND t3.event_id = ".$aEventID[$row]." AND per_cls_ID IN ('1','2','5')";
$cOpps = RunQuery($cSQL);
$cNumAttend = mysql_result($cOpps, 0);
$tSQL = "SELECT COUNT(per_ID) AS tCount
FROM person_per
WHERE per_cls_ID IN ('1','2','5')";
$tOpps = RunQuery($tSQL);
$tNumTotal = mysql_result($tOpps, 0);
?>
<input type="submit" name="Type" value="<?php echo gettext("Attending Members").' ['.$cNumAttend.']'; ?>" class="icButton">
</form>
</td>
<td class="TextColumn">
<form name="NonAttend" action="EventAttendance.php" method="POST">
<input type="hidden" name="Event" value="<?php echo $aEventID[$row]; ?>">
<input type="hidden" name="Type" value="<?php echo $_GET['Type']; ?>">
<input type="hidden" name="Action" value="Retrieve">
<input type="hidden" name="Choice" value="Nonattendees">
<?php
?>
<input type="submit" name="Type" value="<?php echo gettext("Non-Attending Members").' ['.($tNumTotal - $cNumAttend).']'; ?>" class="icButton">
</form>
</td>
<td class="TextColumn">
<form name="GuestAttend" action="EventAttendance.php" method="POST">
<input type="hidden" name="Event" value="<?php echo $aEventID[$row]; ?>">
<input type="hidden" name="Type" value="<?php echo $_GET['Type']; ?>">
<input type="hidden" name="Action" value="Retrieve">
<input type="hidden" name="Choice" value="Guests">
<?php
$gSQL = "SELECT COUNT(per_ID) AS gCount
FROM person_per as t1, events_event as t2, event_attend as t3
WHERE t1.per_ID = t3.person_id AND t2.event_id = t3.event_id AND t3.event_id = ".$aEventID[$row]." AND per_cls_ID = 3";
$gOpps = RunQuery($gSQL);
$gNumGuestAttend = mysql_result($gOpps, 0);
?>
<input type="hidden" name="EventIDs" value="<?php echo $EventIDs; ?>">
<input <?php echo ($gNumGuestAttend == 0 ? "type=\"button\"":"type=\"submit\""); ?> name="Type" value="<?php echo gettext("Guests").' ['.$gNumGuestAttend.']'; ?>" class="icButton">
</form>
</td>
</tr>
<?php
}
?>
<tr><td colspan="5"> </td></tr>
<?php
}
elseif ($_POST['Action']== "Retrieve" && $numRows > 0)
{
?>
<caption>
<h3><?php echo gettext("There ".($numRows == 1 ? "was ".$numRows." ".$_POST['Choice']:"were ".$numRows." ".$_POST['Choice']))." for this Event"; ?></h3>
</caption>
<tr class="TableHeader">
<td width="35%"><strong><?php echo gettext("Name"); ?></strong></td>
<td width="25%"><strong><?php echo gettext("Email"); ?></strong></td>
<td width="25%"><strong><?php echo gettext("Home Phone"); ?></strong></td>
<td width="15%" nowrap><strong><?php /* echo gettext("Cart"); */ ?> </strong></td>
</tr>
<?php
//Set the initial row color
$sRowClass = "RowColorA";
for ($row=1; $row <= $numRows; $row++)
{
//Alternate the row color
$sRowClass = AlternateRowStyle($sRowClass);
//Display the row
?>
<tr class="<?php echo $sRowClass; ?>">
<td class="TextColumn"><?php echo FormatFullName($aTitle[$row],$aFistName[$row],$aMiddleName[$row],$aLastName[$row],$aSuffix[$row],3); ?></td>
<td class="TextColumn"><?php echo ($aEmail[$row] ? '<a href="mailto:'.$aEmail[$row].'" title="Send Email">'.$aEmail[$row].'</a>':'Not Available'); ?></td>
<td class="TextColumn"><?php echo ($aHomePhone[$row] ? ExpandPhoneNumber($aHomePhone[$row],$aPhoneCountry[$row],$dummy):'Not Available'); ?></td>
<?php
// AddToCart call to go here
?>
<td class="TextColumn"><?php /* echo '<a onclick="return AddToCart('.$aPersonID[$row].');" href="blank.html">'.gettext("Add to Cart").'</a>'; */ ?> </td>
</tr>
<?php
}
}
else
{
?>
<caption>
<h3><?php echo ($_GET ? gettext("There are no events in this category"):gettext("There are no Records")); ?><br><br></h3>
</caption>
<tr><td> </td></tr>
<?php
}
?>
</table>
<?php
require "Include/Footer.php";
?>