-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPrintView.php
471 lines (417 loc) · 15.8 KB
/
PrintView.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
<?php
/*******************************************************************************
*
* filename : PrintView.php
* last change : 2003-01-29
*
* http://www.infocentral.org/
* Copyright 2001-2003 Phillip Hullquist, Deane Barker, Chris Gebhardt
*
* InfoCentral 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.
*
******************************************************************************/
// Include the function library
require "Include/Config.php";
require "Include/Functions.php";
// Get the person ID from the querystring
$iPersonID = FilterInput($_GET["PersonID"],'int');
// Get this person
$sSQL = "SELECT a.*, family_fam.*, cls.lst_OptionName AS sClassName, fmr.lst_OptionName AS sFamRole, b.per_FirstName AS EnteredFirstName,
b.Per_LastName AS EnteredLastName, c.per_FirstName AS EditedFirstName, c.per_LastName AS EditedLastName
FROM person_per a
LEFT JOIN family_fam ON a.per_fam_ID = family_fam.fam_ID
LEFT JOIN list_lst cls ON a.per_cls_ID = cls.lst_OptionID AND cls.lst_ID = 1
LEFT JOIN list_lst fmr ON a.per_fmr_ID = fmr.lst_OptionID AND fmr.lst_ID = 2
LEFT JOIN person_per b ON a.per_EnteredBy = b.per_ID
LEFT JOIN person_per c ON a.per_EditedBy = c.per_ID
WHERE a.per_ID = " . $iPersonID;
$rsPerson = RunQuery($sSQL);
extract(mysql_fetch_array($rsPerson));
// Save for later
$sWorkEmail = trim($per_WorkEmail);
// Get the list of custom person fields
$sSQL = "SELECT person_custom_master.* FROM person_custom_master ORDER BY custom_Order";
$rsCustomFields = RunQuery($sSQL);
$numCustomFields = mysql_num_rows($rsCustomFields);
// Get the actual custom field data
$sSQL = "SELECT * FROM person_custom WHERE per_ID = " . $iPersonID;
$rsCustomData = RunQuery($sSQL);
$aCustomData = mysql_fetch_array($rsCustomData, MYSQL_BOTH);
// Get the notes for this person
$sSQL = "SELECT nte_Private, nte_ID, nte_Text, nte_DateEntered, nte_EnteredBy, nte_DateLastEdited, nte_EditedBy, a.per_FirstName AS EnteredFirstName, a.Per_LastName AS EnteredLastName, b.per_FirstName AS EditedFirstName, b.per_LastName AS EditedLastName ";
$sSQL = $sSQL . "FROM note_nte ";
$sSQL = $sSQL . "LEFT JOIN person_per a ON nte_EnteredBy = a.per_ID ";
$sSQL = $sSQL . "LEFT JOIN person_per b ON nte_EditedBy = b.per_ID ";
$sSQL = $sSQL . "WHERE nte_per_ID = " . $iPersonID . " ";
$sSQL = $sSQL . "AND (nte_Private = 0 OR nte_Private = " . $_SESSION['iUserID'] . ")";
$rsNotes = RunQuery($sSQL);
// Get the Groups this Person is assigned to
$sSQL = "SELECT grp_ID, grp_Name, grp_hasSpecialProps, role.lst_OptionName AS roleName
FROM group_grp
LEFT JOIN person2group2role_p2g2r ON p2g2r_grp_ID = grp_ID
LEFT JOIN list_lst role ON lst_OptionID = p2g2r_rle_ID AND lst_ID = grp_RoleListID
WHERE person2group2role_p2g2r.p2g2r_per_ID = " . $iPersonID . "
ORDER BY grp_Name";
$rsAssignedGroups = RunQuery($sSQL);
// Get the Properties assigned to this Person
$sSQL = "SELECT pro_Name, pro_ID, pro_Prompt, r2p_Value, prt_Name, pro_prt_ID
FROM record2property_r2p
LEFT JOIN property_pro ON pro_ID = r2p_pro_ID
LEFT JOIN propertytype_prt ON propertytype_prt.prt_ID = property_pro.pro_prt_ID
WHERE pro_Class = 'p' AND r2p_record_ID = " . $iPersonID .
" ORDER BY prt_Name, pro_Name";
$rsAssignedProperties = RunQuery($sSQL);
// Get Field Security List Matrix
$sSQL = "SELECT * FROM list_lst WHERE lst_ID = 5 ORDER BY lst_OptionSequence";
$rsSecurityGrp = RunQuery($sSQL);
while ($aRow = mysql_fetch_array($rsSecurityGrp))
{
extract ($aRow);
$aSecurityType[$lst_OptionID] = $lst_OptionName;
}
// Format the BirthDate
$dBirthDate = FormatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, "/", $per_Flags);
//if ($per_BirthMonth > 0 && $per_BirthDay > 0)
//{
// $dBirthDate = $per_BirthMonth . "/" . $per_BirthDay;
// if (is_numeric($per_BirthYear))
// {
// $dBirthDate .= "/" . $per_BirthYear;
// }
//}
//elseif (is_numeric($per_BirthYear))
//{
// $dBirthDate = $per_BirthYear;
//}
//else
//{
// $dBirthDate = "";
//}
// Assign the values locally, after selecting whether to display the family or person information
SelectWhichAddress($sAddress1, $sAddress2, $per_Address1, $per_Address2, $fam_Address1, $fam_Address2, False);
$sCity = SelectWhichInfo($per_City, $fam_City, False);
$sState = SelectWhichInfo($per_State, $fam_State, False);
$sZip = SelectWhichInfo($per_Zip, $fam_Zip, False);
$sCountry = SelectWhichInfo($per_Country, $fam_Country, False);
$sHomePhone = SelectWhichInfo(ExpandPhoneNumber($per_HomePhone,$sCountry,$dummy), ExpandPhoneNumber($fam_HomePhone,$fam_Country,$dummy), False);
$sWorkPhone = SelectWhichInfo(ExpandPhoneNumber($per_WorkPhone,$sCountry,$dummy), ExpandPhoneNumber($fam_WorkPhone,$fam_Country,$dummy), False);
$sCellPhone = SelectWhichInfo(ExpandPhoneNumber($per_CellPhone,$sCountry,$dummy), ExpandPhoneNumber($fam_CellPhone,$fam_Country,$dummy), False);
$sUnformattedEmail = SelectWhichInfo($per_Email, $fam_Email, False);
// Set the page title and include HTML header
$sPageTitle = gettext("Printable View");
$iTableSpacerWidth = 10;
require "Include/Header-Short.php";
?>
<table width="200"><tr><td>
<p class="ShadedBox">
<?php
// Print the name and address header
echo "<b><font size=\"4\">" . $per_FirstName . " " . $per_LastName . "</font></b><br>";
echo "<font size=\"3\">";
if ($sAddress1 != "") { echo $sAddress1 . "<br>"; }
if ($sAddress2 != "") { echo $sAddress2 . "<br>"; }
if ($sCity != "") { echo $sCity . ", "; }
if ($sState != "") { echo $sState; }
if ($sZip != "") { echo " " . $sZip; }
if ($sCountry != "") {echo "<br>" . $sCountry; }
echo "</font>";
$iFamilyID = $fam_ID;
if ($fam_ID)
{
//Get the family members for this family
$sSQL = "SELECT per_ID, per_Title, per_FirstName, per_LastName, per_Suffix, per_Gender,
per_BirthMonth, per_BirthDay, per_BirthYear, cls.lst_OptionName AS sClassName,
fmr.lst_OptionName AS sFamRole
FROM person_per
LEFT JOIN list_lst cls ON per_cls_ID = cls.lst_OptionID AND cls.lst_ID = 1
LEFT JOIN list_lst fmr ON per_fmr_ID = fmr.lst_OptionID AND fmr.lst_ID = 2
WHERE per_fam_ID = " . $iFamilyID . " ORDER BY fmr.lst_OptionSequence";
$rsFamilyMembers = RunQuery($sSQL);
}
?>
</p></td></tr></table>
<BR>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" valign="top" align="left">
<table cellspacing="1" cellpadding="4">
<tr>
<td class="LabelColumn"><?php echo gettext("Home Phone:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn"><?php echo $sHomePhone; ?> </td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Work Phone:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn"><?php echo $sWorkPhone; ?> </td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Mobile Phone:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn"><?php echo $sCellPhone; ?> </td>
</tr>
<?php
$numColumn3Fields = floor($numCustomFields / 3);
$leftOverFields = $numCustomFields - $numColumn3Fields;
$numColumn1Fields = ceil($leftOverFields / 2);
$numColumn2Fields = $leftOverFields - $numColumn1Fields;
for($i = 1; $i <= $numColumn1Fields; $i++)
{
$Row = mysql_fetch_array($rsCustomFields);
extract($Row);
if (($aSecurityType[$custom_FieldSec] == 'bAll') or ($_SESSION[$aSecurityType[$custom_FieldSec]]))
{
$currentData = trim($aCustomData[$custom_Field]);
if ($type_ID == 11) $custom_Special = $sCountry;
echo "<tr><td class=\"LabelColumn\">" . $custom_Name . "</td><td width=\"" . $iTableSpacerWidth . "\"></td>";
echo "<td class=\"TextColumn\">" . displayCustomField($type_ID, $currentData, $custom_Special) . "</td></tr>";
}
}
?>
</table>
</td>
<td width="33%" valign="top" align="left">
<table cellspacing="1" cellpadding="4">
<tr>
<td class="LabelColumn"><?php echo gettext("Gender:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn">
<?php
switch (strtolower($per_Gender))
{
case 1:
echo gettext("Male");
break;
case 2:
echo gettext("Female");
break;
} ?>
</td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("BirthDate:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn"><?php echo $dBirthDate; ?> </td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Family:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn">
<?php if ($fam_Name != "") { echo $fam_Name; } else { echo "Unassigned"; } ?>
</td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Family Role:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumnWithBottomBorder"><?php if ($sFamRole != "") { echo $sFamRole; } else { echo "Unassigned"; } ?> </td>
</tr>
<?php
for($i = 1; $i <= $numColumn2Fields; $i++)
{
$Row = mysql_fetch_array($rsCustomFields);
extract($Row);
$currentData = trim($aCustomData[$custom_Field]);
if ($type_ID == 11) $custom_Special = $sCountry;
echo "<tr><td class=\"LabelColumn\">" . $custom_Name . "</td><td width=\"" . $iTableSpacerWidth . "\"></td>";
echo "<td class=\"TextColumn\">" . displayCustomField($type_ID, $currentData, $custom_Special) . "</td></tr>";
}
?>
</table>
</td>
<td width="33%" valign="top" align="left">
<table cellspacing="1" cellpadding="4">
<tr>
<td class="LabelColumn"><?php echo gettext("Email:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumnWithBottomBorder"><?php echo $sUnformattedEmail; ?> </td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Work / Other Email:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumnWithBottomBorder"><?php echo $sWorkEmail; ?> </td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Membership Date:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumn"><?php echo FormatDate($per_MembershipDate,false); ?> </td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Classification:"); ?></td>
<td width="<?php echo $iTableSpacerWidth; ?>"></td>
<td class="TextColumnWithBottomBorder"><?php echo $sClassName; ?> </td>
</tr>
<?php
for($i = 1; $i <= $numColumn3Fields; $i++)
{
$Row = mysql_fetch_array($rsCustomFields);
extract($Row);
$currentData = trim($aCustomData[$custom_Field]);
if ($type_ID == 11) $custom_Special = $sCountry;
echo "<tr><td class=\"LabelColumn\">" . $custom_Name . "</td><td width=\"" . $iTableSpacerWidth . "\"></td>";
echo "<td class=\"TextColumn\">" . displayCustomField($type_ID, $currentData, $custom_Special) . "</td></tr>";
}
?>
</table>
</td>
</tr>
</table>
<br>
<?php if ($fam_ID) { ?>
<b><?php echo gettext("Family Members:"); ?></b>
<table cellpadding=5 cellspacing=0 width="100%">
<tr class="TableHeader">
<td><?php echo gettext("Name"); ?></td>
<td><?php echo gettext("Gender"); ?></td>
<td><?php echo gettext("Role"); ?></td>
<td><?php echo gettext("Age"); ?></td>
</tr>
<?php
$sRowClass = "RowColorA";
// Loop through all the family members
while ($aRow = mysql_fetch_array($rsFamilyMembers))
{
$per_BirthYear = "";
$agr_Description = "";
extract($aRow);
// Alternate the row style
$sRowClass = AlternateRowStyle($sRowClass)
// Display the family member
?>
<tr class="<?php echo $sRowClass ?>">
<td>
<?php echo $per_FirstName . " " . $per_LastName ?>
<br>
</td>
<td>
<?php switch ($per_Gender) {case 1: echo gettext("Male"); break; case 2: echo gettext("Female"); break; default: echo "";} ?>
</td>
<td>
<?php echo $sFamRole ?>
</td>
<td>
<?php PrintAge($per_BirthMonth,$per_BirthDay,$per_BirthYear, $per_Flags); ?>
</td>
</tr>
<?php
}
echo "</table>";
}
?>
<BR>
<b><?php echo gettext("Assigned Groups:"); ?></b>
<?php
//Initialize row shading
$sRowClass = "RowColorA";
$sAssignedGroups = ",";
//Was anything returned?
if (mysql_num_rows($rsAssignedGroups) == 0)
{
echo "<p align\"center\">" . gettext("No group assignments.") . "</p>";
}
else
{
echo "<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\">";
echo "<tr class=\"TableHeader\">";
echo "<td width=\"15%\"><b>" . gettext("Group Name") . "</b>";
echo "<td><b>" . gettext("Role") . "</b></td>";
echo "</tr>";
//Loop through the rows
while ($aRow = mysql_fetch_array($rsAssignedGroups))
{
extract($aRow);
//Alternate the row style
$sRowClass = AlternateRowStyle($sRowClass);
// DISPLAY THE ROW
echo "<tr class=\"" . $sRowClass . "\">";
echo " <td>" . $grp_Name . "</td>";
echo " <td>" . $roleName . "</td>";
echo "</tr>";
// If this group has associated special properties, display those with values and prop_PersonDisplay flag set.
if ($grp_hasSpecialProps == 'true')
{
$firstRow = true;
// Get the special properties for this group
$sSQL = "SELECT groupprop_master.* FROM groupprop_master
WHERE grp_ID = " . $grp_ID . " AND prop_PersonDisplay = 'true' ORDER BY prop_ID";
$rsPropList = RunQuery($sSQL);
$sSQL = "SELECT * FROM groupprop_" . $grp_ID . " WHERE per_ID = " . $iPersonID;
$rsPersonProps = RunQuery($sSQL);
$aPersonProps = mysql_fetch_array($rsPersonProps, MYSQL_BOTH);
while ($aProps = mysql_fetch_array($rsPropList))
{
extract($aProps);
$currentData = trim($aPersonProps[$prop_Field]);
if (strlen($currentData) > 0)
{
// only create the properties table if it's actually going to be used
if ($firstRow) {
echo "<tr><td colspan=\"2\"><table width=\"50%\"><tr><td width=\"15%\"></td><td><table width=\"90%\" cellspacing=\"0\">";
echo "<tr class=\"TinyTableHeader\"><td>Property</td><td>Value</td></tr>";
$firstRow = false;
}
$sRowClass = AlternateRowStyle($sRowClass);
if ($type_ID == 11) $prop_Special = $sCountry;
echo "<tr class=\"$sRowClass\"><td>" . $prop_Name . "</td><td>" . displayCustomField($type_ID, $currentData, $prop_Special) . "</td></tr>";
}
}
if (!$firstRow) echo "</table></td></tr></table></td></tr>";
}
$sAssignedGroups .= $grp_ID . ",";
}
echo "</table>";
}
?>
<BR>
<b><?php echo gettext("Assigned Properties:"); ?></b>
<?php
//Initialize row shading
$sRowClass = "RowColorA";
$sAssignedProperties = ",";
//Was anything returned?
if (mysql_num_rows($rsAssignedProperties) == 0)
{
echo "<p align\"center\">" . gettext("No property assignments.") . "</p>";
}
else
{
echo "<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\">";
echo "<tr class=\"TableHeader\">";
echo "<td width=\"25%\" valign=\"top\"><b>" . gettext("Name") . "</b>";
echo "<td valign=\"top\"><b>" . gettext("Value") . "</td>";
echo "</tr>";
while ($aRow = mysql_fetch_array($rsAssignedProperties))
{
$pro_Prompt = "";
$r2p_Value = "";
extract($aRow);
//Alternate the row style
$sRowClass = AlternateRowStyle($sRowClass);
//Display the row
echo "<tr class=\"" . $sRowClass . "\">";
echo "<td valign=\"top\">" . $pro_Name . " </td>";
echo "<td valign=\"top\">" . $r2p_Value . " </td>";
echo "</tr>";
$sAssignedProperties .= $pro_ID . ",";
}
echo "</table>";
}
if ($_SESSION['bNotes'])
{
echo "<p><b>" . gettext("Notes:") . "</b></p>";
// Loop through all the notes
while($aRow = mysql_fetch_array($rsNotes))
{
extract($aRow);
echo "<p class=\"ShadedBox\")>" . $nte_Text . "</p>";
echo "<span class=\"SmallText\">" . gettext("Entered:") . FormatDate($nte_DateEntered,True) . "</span><br>";
if (strlen($nte_DateLastEdited))
{
echo "<span class=\"SmallText\">" . gettext("Last Edited:") . FormatDate($nte_DateLastEdited,True) . ' ' . gettext("by") . ' ' . $EditedFirstName . " " . $EditedLastName . "</span><br>";
}
}
}
require "Include/Footer-Short.php";
?>