function GenerateLabels(&$pdf, $mode, $bOnlyComplete = false) { if ($mode == "indiv") { $sSQL = "SELECT * FROM person_per LEFT JOIN family_fam ON person_per.per_fam_ID = family_fam.fam_ID WHERE per_ID IN (" . ConvertCartToString($_SESSION['aPeopleCart']) . ") ORDER BY per_LastName"; } else { $sSQL = "(SELECT *, 0 AS memberCount FROM person_per LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID = 0 AND per_ID in ( " . ConvertCartToString($_SESSION['aPeopleCart']) . " ))\n\t\tUNION (SELECT *, COUNT(*) AS memberCount FROM person_per LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID > 0 AND per_ID in ( " . ConvertCartToString($_SESSION['aPeopleCart']) . " ) GROUP BY per_fam_ID HAVING memberCount = 1)\n\t\tUNION (SELECT *, COUNT(*) AS memberCount FROM person_per LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID > 0 AND per_ID in ( " . ConvertCartToString($_SESSION['aPeopleCart']) . " ) GROUP BY per_fam_ID HAVING memberCount > 1)"; } $rsCartItems = RunQuery($sSQL); while ($aRow = mysql_fetch_array($rsCartItems)) { $sRowClass = AlternateRowStyle($sRowClass); if ($aRow['memberCount'] > 1 && $mode == "fam") { $sName = $aRow['fam_Name'] . " Family"; } else { $sName = FormatFullName($aRow['per_Title'], $aRow['per_FirstName'], "", $aRow['per_LastName'], $aRow['per_Suffix'], 1); } SelectWhichAddress($sAddress1, $sAddress2, $aRow['per_Address1'], $aRow['per_Address2'], $aRow['fam_Address1'], $aRow['fam_Address2'], false); $sCity = SelectWhichInfo($aRow['per_City'], $aRow['fam_City'], False); $sState = SelectWhichInfo($aRow['per_State'], $aRow['fam_State'], False); $sZip = SelectWhichInfo($aRow['per_Zip'], $aRow['fam_Zip'], False); $sAddress = $sAddress1; if ($sAddress2 != "") { $sAddress .= "\n" . $sAddress2; } if (!$bOnlyComplete || strlen($sAddress) && strlen($sCity) && strlen($sState) && strlen($sZip)) { $pdf->Add_PDF_Label(sprintf("%s\n%s\n%s, %s %s", $sName, $sAddress, $sCity, $sState, $sZip)); } } }
$sSQL .= "LEFT JOIN person2group2role_p2g2r ON p2g2r_per_ID = person_per.per_ID\n\t\t\tWHERE p2g2r_grp_ID = " . $iGroupID; if ($iRoleID > 0) { $sSQL .= " AND p2g2r_rle_ID = " . $iRoleID; } if ($bOnlyCartMembers && count($_SESSION['aPeopleCart']) > 0) { $sSQL .= " AND person_per.per_ID IN (" . ConvertCartToString($_SESSION['aPeopleCart']) . ")"; } $sSQL .= " ORDER BY per_LastName"; $rsRecords = RunQuery($sSQL); // This is used for the headings for the letter changes. // Start out with something that isn't a letter to force the first one to work // $sLastLetter = "0"; while ($aRow = mysql_fetch_array($rsRecords)) { $OutStr = ""; $pdf->sFamily = FormatFullName($aRow['per_Title'], $aRow['per_FirstName'], $aRow['per_MiddleName'], $aRow['per_LastName'], $aRow['per_Suffix'], 3); SelectWhichAddress($sAddress1, $sAddress2, $aRow['per_Address1'], $aRow['per_Address2'], $aRow['fam_Address1'], $aRow['fam_Address2'], false); $sCity = SelectWhichInfo($aRow['per_City'], $aRow['fam_City'], false); $sState = SelectWhichInfo($aRow['per_State'], $aRow['fam_State'], false); $sZip = SelectWhichInfo($aRow['per_Zip'], $aRow['fam_Zip'], false); $sHomePhone = SelectWhichInfo($aRow['per_HomePhone'], $aRow['fam_HomePhone'], false); $sWorkPhone = SelectWhichInfo($aRow['per_WorkPhone'], $aRow['fam_WorkPhone'], false); $sCellPhone = SelectWhichInfo($aRow['per_CellPhone'], $aRow['fam_CellPhone'], false); $sEmail = SelectWhichInfo($aRow['per_Email'], $aRow['fam_Email'], false); if (isset($_POST['GroupRoleEnable'])) { $OutStr = gettext("Role") . ": " . $aRoleNames[$aRow['p2g2r_rle_ID']] . "\n"; } if (isset($_POST['AddressEnable'])) { if (strlen($sAddress1)) { $OutStr .= $sAddress1 . "\n"; } if (strlen($sAddress2)) {
$per_DateEntered = ""; $fam_Name = ""; $fam_Address1 = ""; $fam_Address2 = ""; $fam_City = ""; $fam_State = ""; $fam_Zip = ""; $fam_Country = ""; $fam_HomePhone = ""; $fam_CellPhone = ""; $fam_Email = ""; extract($aRow); //Alternate the row color $sRowClass = AlternateRowStyle($sRowClass); // 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); //Display the row ?> <tr class="<?php echo $sRowClass; ?> ">
$rsAssignedProperties = RunQuery($sSQL); // Get all the properties $sSQL = "SELECT * FROM property_pro WHERE pro_Class = 'p' ORDER BY pro_Name"; $rsProperties = 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; } $dBirthDate = FormatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, "-", $per_Flags); $sFamilyInfoBegin = "<span style=\"color: red;\">"; $sFamilyInfoEnd = "</span>"; // 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, True); $sCity = SelectWhichInfo($per_City, $fam_City, True); $sState = SelectWhichInfo($per_State, $fam_State, True); $sZip = SelectWhichInfo($per_Zip, $fam_Zip, True); $sCountry = SelectWhichInfo($per_Country, $fam_Country, True); $sPhoneCountry = SelectWhichInfo($per_Country, $fam_Country, False); $sHomePhone = SelectWhichInfo(ExpandPhoneNumber($per_HomePhone, $sPhoneCountry, $dummy), ExpandPhoneNumber($fam_HomePhone, $fam_Country, $dummy), True); $sWorkPhone = SelectWhichInfo(ExpandPhoneNumber($per_WorkPhone, $sPhoneCountry, $dummy), ExpandPhoneNumber($fam_WorkPhone, $fam_Country, $dummy), True); $sCellPhone = SelectWhichInfo(ExpandPhoneNumber($per_CellPhone, $sPhoneCountry, $dummy), ExpandPhoneNumber($fam_CellPhone, $fam_Country, $dummy), True); $sEmail = SelectWhichInfo($per_Email, $fam_Email, True); $sUnformattedEmail = SelectWhichInfo($per_Email, $fam_Email, False); if ($per_Envelope > 0) { $sEnvelope = $per_Envelope; } else { $sEnvelope = gettext("Not assigned"); }
function loadperson($iPersonID) { global $bDefectiveBrowser; if ($iPersonID == 0) { return; } $sSQL = "SELECT a.*, family_fam.*, cls.lst_OptionName AS sClassName, fmr.lst_OptionName AS sFamRole, b.per_FirstName AS EnteredFirstName,\n\t\t\t\t\tb.Per_LastName AS EnteredLastName, c.per_FirstName AS EditedFirstName, c.per_LastName AS EditedLastName\n\t\t\t\tFROM person_per a\n\t\t\t\tLEFT JOIN family_fam ON a.per_fam_ID = family_fam.fam_ID\n\t\t\t\tLEFT JOIN list_lst cls ON a.per_cls_ID = cls.lst_OptionID AND cls.lst_ID = 1\n\t\t\t\tLEFT JOIN list_lst fmr ON a.per_fmr_ID = fmr.lst_OptionID AND fmr.lst_ID = 2\n\t\t\t\tLEFT JOIN person_per b ON a.per_EnteredBy = b.per_ID\n\t\t\t\tLEFT JOIN person_per c ON a.per_EditedBy = c.per_ID\n\t\t\t\tWHERE a.per_ID = " . $iPersonID; $rsPerson = RunQuery($sSQL); if (!$rsPerson || mysql_num_rows($rsPerson) == 0) { return; } extract(mysql_fetch_array($rsPerson)); // Get the lists of custom person fields $sSQL = "SELECT person_custom_master.* FROM person_custom_master\n\t\t\t\tWHERE custom_Side = 'left' ORDER BY custom_Order"; $rsLeftCustomFields = RunQuery($sSQL); $sSQL = "SELECT person_custom_master.* FROM person_custom_master\n\t\t\t\tWHERE custom_Side = 'right' ORDER BY custom_Order"; $rsRightCustomFields = RunQuery($sSQL); // Get the custom field data for this person. $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 .= "FROM note_nte "; $sSQL .= "LEFT JOIN person_per a ON nte_EnteredBy = a.per_ID "; $sSQL .= "LEFT JOIN person_per b ON nte_EditedBy = b.per_ID "; $sSQL .= "WHERE nte_per_ID = " . $iPersonID; // Admins should see all notes, private or not. Otherwise, only get notes marked non-private or private to the current user. if (!$_SESSION['bAdmin']) { $sSQL .= " AND (nte_Private = 0 OR nte_Private = " . $_SESSION['iUserID'] . ")"; } $rsNotes = RunQuery($sSQL); SelectWhichAddress($sAddress1, $sAddress2, $per_Address1, $per_Address2, $fam_Address1, $fam_Address2, false); $sAddress2 = SelectWhichInfo($per_Address2, $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); echo "<font size=\"4\"><b>"; echo FormatFullName($per_Title, $per_FirstName, $per_MiddleName, $per_LastName, $per_Suffix, 0); echo "</font></b><br>"; if ($fam_ID != "") { echo "<font size=\"2\">("; if ($sFamRole != "") { echo $sFamRole; } else { echo gettext("Member"); } echo gettext(" of the") . " <a href=\"FamilyView.php?FamilyID=" . $fam_ID . "\">" . $fam_Name . "</a>" . gettext(" family)") . "</font><br><br>"; } else { echo gettext("(No assigned family)") . "<br><br>"; } echo "<div class=\"TinyShadedBox\">"; 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>"; echo "</div>"; // Strip tags in case they were added for family inherited data $sAddress1 = strip_tags($sAddress1); $sCity = strip_tags($sCity); $sState = strip_tags($sState); $sCountry = strip_tags($sCountry); // Upload photo if (isset($_POST["UploadPhoto"]) && ($_SESSION['bAddRecords'] || $bOkToEdit)) { if ($_FILES['Photo']['name'] == "") { $PhotoError = gettext("No photo selected for uploading."); } elseif ($_FILES['Photo']['type'] != "image/pjpeg" && $_FILES['Photo']['type'] != "image/jpeg") { $PhotoError = gettext("Only jpeg photos can be uploaded."); } else { // Create the thumbnail used by PersonView chmod($_FILES['Photo']['tmp_name'], 0777); $srcImage = imagecreatefromjpeg($_FILES['Photo']['tmp_name']); $src_w = imageSX($srcImage); $src_h = imageSY($srcImage); // Calculate thumbnail's height and width (a "maxpect" algorithm) $dst_max_w = 200; $dst_max_h = 350; if ($src_w > $dst_max_w) { $thumb_w = $dst_max_w; $thumb_h = $src_h * ($dst_max_w / $src_w); if ($thumb_h > $dst_max_h) { $thumb_h = $dst_max_h; $thumb_w = $src_w * ($dst_max_h / $src_h); } } elseif ($src_h > $dst_max_h) { $thumb_h = $dst_max_h; $thumb_w = $src_w * ($dst_max_h / $src_h); if ($thumb_w > $dst_max_w) { $thumb_w = $dst_max_w; $thumb_h = $src_h * ($dst_max_w / $src_w); } } else { if ($src_w > $src_h) { $thumb_w = $dst_max_w; $thumb_h = $src_h * ($dst_max_w / $src_w); } elseif ($src_w < $src_h) { $thumb_h = $dst_max_h; $thumb_w = $src_w * ($dst_max_h / $src_h); } else { if ($dst_max_w >= $dst_max_h) { $thumb_w = $dst_max_h; $thumb_h = $dst_max_h; } else { $thumb_w = $dst_max_w; $thumb_h = $dst_max_w; } } } $dstImage = ImageCreateTrueColor($thumb_w, $thumb_h); imagecopyresampled($dstImage, $srcImage, 0, 0, 0, 0, $thumb_w, $thumb_h, $src_w, $src_h); imagejpeg($dstImage, "Images/Person/thumbnails/" . $iPersonID . ".jpg"); imagedestroy($dstImage); imagedestroy($srcImage); move_uploaded_file($_FILES['Photo']['tmp_name'], "Images/Person/" . $iPersonID . ".jpg"); } } elseif (isset($_POST["DeletePhoto"]) && $_SESSION['bDeleteRecords']) { unlink("Images/Person/" . $iPersonID . ".jpg"); unlink("Images/Person/thumbnails/" . $iPersonID . ".jpg"); } // Display photo or upload from file $photoFile = "Images/Person/thumbnails/" . $iPersonID . ".jpg"; if (file_exists($photoFile)) { echo '<a target="_blank" href="Images/Person/' . $iPersonID . '.jpg">'; echo '<img border="1" src="' . $photoFile . '"></a>'; /* if ($bOkToEdit) { echo ' <form method="post" action="PersonView.php?PersonID=' . $iPersonID . '"> <br> <input type="submit" class="icTinyButton" value="' . gettext("Delete Photo") . '" name="DeletePhoto"> </form>'; } */ } else { // Some old / M$ browsers can't handle PNG's correctly. if ($bDefectiveBrowser) { echo '<img border="0" src="Images/NoPhoto.gif"><br><br><br>'; } else { echo '<img border="0" src="Images/NoPhoto.png"><br><br><br>'; } /* if ($bOkToEdit) { if (isset($PhotoError)) echo '<span style="color: red;">' . $PhotoError . '</span><br>'; echo ' <form method="post" action="PersonView.php?PersonID=' . $iPersonID . '" enctype="multipart/form-data"> <input class="icTinyButton" type="file" name="Photo"> <input type="submit" class="icTinyButton" value="' . gettext("Upload Photo") . '" name="UploadPhoto"> </form>'; } */ } }
// Are we creating a new family if ($iFamilyID == 0) { $sFamilyName = FilterInput($_POST["FamilyName"]); $dWeddingDate = FilterInput($_POST["WeddingDate"]); if (strlen($dWeddingDate) > 0) { $dWeddingDate = "\"" . $dWeddingDate . "\""; } else { $dWeddingDate = "NULL"; } $iPersonAddress = FilterInput($_POST["PersonAddress"]); if ($iPersonAddress != 0) { $sSQL = "SELECT * FROM person_per WHERE per_ID = " . $iPersonAddress; $rsPerson = RunQuery($sSQL); extract(mysql_fetch_array($rsPerson)); } $numadd = SelectWhichAddress($sAddress1, $sAddress2, FilterInput($_POST["Address1"]), FilterInput($_POST["Address2"]), $per_Address1, $per_Address2, false); // Added for GPIB if ($numadd == 1) { $sKompleks1 = FilterInput($_POST["Kompleks1"]); $sRTRW1 = FilterInput($_POST["RTRW1"]); $sKelurahan1 = FilterInput($_POST["Kelurahan1"]); $sKompleks2 = FilterInput($_POST["Kompleks2"]); $sRTRW2 = FilterInput($_POST["RTRW2"]); $sKelurahan2 = FilterInput($_POST["Kelurahan2"]); } elseif ($numadd == 2) { $sKompleks1 = $per_Kompleks1; $sRTRW1 = $per_RTRW1; $sKelurahan1 = $per_Kelurahan1; $sKompleks2 = $per_Kompleks2; $sRTRW2 = $per_RTRW2; $sKelurahan2 = per_Kelurahan2;
function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComplete) { // $mode is "indiv" or "fam" unset($didFam); $sSQL = "SELECT cfg_name, IFNULL(cfg_value, cfg_default) AS value "; $sSQL .= "FROM config_cfg WHERE cfg_section='General'"; $rsConfig = RunQuery($sSQL); if ($rsConfig) { while (list($cfg_name, $cfg_value) = mysql_fetch_row($rsConfig)) { ${$cfg_name} = $cfg_value; } } $sAdultRole = $sDirRoleHead . "," . $sDirRoleSpouse; $sAdultRole = trim($sAdultRole, " ,\t\n\r\v"); $aAdultRole = explode(",", $sAdultRole); $aAdultRole = array_unique($aAdultRole); sort($aAdultRole); $sChildRole = trim($sDirRoleChild, " ,\t\n\r\v"); $aChildRole = explode(",", $sChildRole); $aChildRole = array_unique($aChildRole); sort($aChildRole); $sSQL = "SELECT * FROM person_per LEFT JOIN family_fam "; $sSQL .= "ON person_per.per_fam_ID = family_fam.fam_ID "; $sSQL .= "WHERE per_ID IN (" . ConvertCartToString($_SESSION['aPeopleCart']) . ") "; $sSQL .= "ORDER BY fam_Zip, per_LastName, per_FirstName"; $rsCartItems = RunQuery($sSQL); $sRowClass = "RowColorA"; $didFam = array(); while ($aRow = mysql_fetch_array($rsCartItems)) { // It's possible (but unlikely) that three labels can be generated for a // family even when they are grouped. // At most one label for all adults // At most one label for all children // At most one label for all others (for example, another church or a landscape // company) $sRowClass = AlternateRowStyle($sRowClass); if ($aRow['per_fam_ID'] == 0 && $mode == "fam") { // Skip people with no family ID continue; } // Skip if mode is fam and we have already printed labels if (array_key_exists($aRow['per_fam_ID'], $didFam) and $didFam[$aRow['per_fam_ID']] && $mode == "fam") { continue; } $didFam[$aRow['per_fam_ID']] = 1; unset($aName); if ($mode == "fam") { $aName = GroupBySalutation($aRow['per_fam_ID'], $aAdultRole, $aChildRole); } else { $sName = FormatFullName($aRow['per_Title'], $aRow['per_FirstName'], "", $aRow['per_LastName'], $aRow['per_Suffix'], 1); $bChild = FALSE; foreach ($aChildRole as $value) { if ($aRow['per_fmr_ID'] == $value) { $bChild = TRUE; } } if ($bChild) { $aName['child'] = substr($sName, 0, 33); } else { $aName['indiv'] = substr($sName, 0, 33); } } foreach ($aName as $key => $sName) { // Bail out if nothing to print if ($sName == "Nothing to return") { continue; } if ($bToParents && $key == "child") { $sName = "To the parents of:\n" . $sName; } SelectWhichAddress($sAddress1, $sAddress2, $aRow['per_Address1'], $aRow['per_Address2'], $aRow['fam_Address1'], $aRow['fam_Address2'], false); $sCity = SelectWhichInfo($aRow['per_City'], $aRow['fam_City'], False); $sState = SelectWhichInfo($aRow['per_State'], $aRow['fam_State'], False); $sZip = SelectWhichInfo($aRow['per_Zip'], $aRow['fam_Zip'], False); $sAddress = $sAddress1; if ($sAddress2 != "") { $sAddress .= "\n" . $sAddress2; } if (!$bOnlyComplete || strlen($sAddress) && strlen($sCity) && strlen($sState) && strlen($sZip)) { $sLabelList[] = array('Name' => $sName, 'Address' => $sAddress, 'City' => $sCity, 'State' => $sState, 'Zip' => $sZip); //,'fam_ID'=>$aRow['fam_ID']); } } // end of foreach loop } // end of while loop unset($zipLabels); if ($iBulkMailPresort) { // // now sort the label list by presort bundle definitions // $zipLabels = ZipBundleSort($sLabelList); if ($iBulkMailPresort == 2) { while (list($i, $sLT) = each($zipLabels)) { $pdf->Add_PDF_Label(sprintf("%s\n%s\n%s\n%s, %s %s", $sLT['Note'], $sLT['Name'], $sLT['Address'], $sLT['City'], $sLT['State'], $sLT['Zip'])); } // end while } else { while (list($i, $sLT) = each($zipLabels)) { $pdf->Add_PDF_Label(sprintf("%s\n%s\n%s, %s %s", $sLT['Name'], $sLT['Address'], $sLT['City'], $sLT['State'], $sLT['Zip'])); } // end while } // end of if ($BulkMailPresort == 2) } else { while (list($i, $sLT) = each($sLabelList)) { $pdf->Add_PDF_Label(sprintf("%s\n%s\n%s, %s %s", $sLT['Name'], $sLT['Address'], $sLT['City'], $sLT['State'], $sLT['Zip'])); } // end while } // end of if($iBulkMailPresort) if (isset($zipLabels)) { return serialize($zipLabels); } else { return serialize($sLabelList); } }