diff --git a/src/Include/Header.php b/src/Include/Header.php index b6e408b018..03a5335484 100644 --- a/src/Include/Header.php +++ b/src/Include/Header.php @@ -10,7 +10,6 @@ $taskService = new TaskService(); -// // Turn ON output buffering ob_start(); diff --git a/src/Reports/ClassAttendance.php b/src/Reports/ClassAttendance.php index 4a5578abca..6a4b3346f0 100644 --- a/src/Reports/ClassAttendance.php +++ b/src/Reports/ClassAttendance.php @@ -1,14 +1,5 @@ debug("Group ID = {$iGroupID}"); $iFYID = InputUtils::legacyFilterInput($_GET['FYID'], 'int'); @@ -33,7 +25,7 @@ $tAllRoles = InputUtils::legacyFilterInput($_GET['AllRoles'], 'int'); $withPictures = InputUtils::legacyFilterInput($_GET['withPictures'], 'int'); -//echo "all roles ={$tAllRoles}"; +LoggerUtils::getAppLogger()->debug("All roles = {$tAllRoles}"); $tNoSchool1 = InputUtils::legacyFilterInputArr($_GET, 'NoSchool1'); $tNoSchool2 = InputUtils::legacyFilterInputArr($_GET, 'NoSchool2'); @@ -82,7 +74,7 @@ for ($i = 0; $i < $nGrps; $i++) { $iGroupID = $aGrp[$i]; - // uset($aStudents); + if ($i > 0) { $pdf->addPage(); } @@ -93,7 +85,7 @@ $reportHeader = str_pad($group->getName(), 95) . $FYString; - // Build the teacher string- first teachers, then the liaison + // Build the teacher string -- first teachers, then the liaison $teacherString = gettext('Teachers') . ': '; $bFirstTeacher = true; $iTeacherCnt = 0; @@ -103,7 +95,7 @@ $groupRoleMemberships = Person2group2roleP2g2rQuery::create() ->joinWithPerson() ->orderBy(PersonTableMap::COL_PER_LASTNAME) - ->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) // I've try to reproduce per_LastName, per_FirstName + ->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) ->findByGroupId($iGroupID); if ($tAllRoles != 1) { @@ -131,7 +123,8 @@ $lst_OptionName = $groupRole->getOptionName(); if ($lst_OptionName === 'Teacher') { - $aTeachers[$iTeacherCnt] = $person; // Make an array of teachers while we're here + // Make an array of teachers while we're here + $aTeachers[$iTeacherCnt] = $person; if (!$bFirstTeacher) { $teacherString .= ', '; } @@ -186,7 +179,7 @@ $withPictures ); - // we start a new page + // We start a new page if ($y > $yTeachers + 10) { $pdf->addPage(); } @@ -213,9 +206,7 @@ $withPictures ); } else { - // - // print all roles on the attendance sheet - // + // Print all roles on the attendance sheet $iStudentCnt = 0; unset($aStudents); @@ -253,9 +244,9 @@ ); } } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if ($iPDFOutputType == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('ClassAttendance' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/ClassList.php b/src/Reports/ClassList.php index 4cca12543e..bc33ab2511 100644 --- a/src/Reports/ClassList.php +++ b/src/Reports/ClassList.php @@ -1,13 +1,5 @@ joinWithPerson() ->orderBy(PersonTableMap::COL_PER_LASTNAME) - ->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) // I've try to reproduce ORDER BY per_LastName, per_FirstName + ->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) ->findByGroupId($iGroupID); $students = []; @@ -190,8 +182,7 @@ public function __construct() $pdf->Line($nameX - $imageHeight, $y, $nameX - $imageHeight, $y + $imageHeight); $pdf->Line($nameX, $y, $nameX, $y + $imageHeight); - // we build the cross in the case of there's no photo - //$this->SetLineWidth(0.25); + // We build the cross in the case of there's no photo $pdf->Line($nameX - $imageHeight, $y + $imageHeight, $nameX, $y); $pdf->Line($nameX - $imageHeight, $y, $nameX, $y + $imageHeight); @@ -270,7 +261,7 @@ public function __construct() } header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if ($iPDFOutputType == 1) { +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('ClassList' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/ConfirmLabels.php b/src/Reports/ConfirmLabels.php index e9a7cc0217..70665bf754 100644 --- a/src/Reports/ConfirmLabels.php +++ b/src/Reports/ConfirmLabels.php @@ -1,13 +1,5 @@ addPdfLabel($labelText); } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if ($iPDFOutputType == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('ConfirmDataLabels' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/DirectoryReport.php b/src/Reports/DirectoryReport.php index 35bcd3b948..ba0a6a5ad1 100644 --- a/src/Reports/DirectoryReport.php +++ b/src/Reports/DirectoryReport.php @@ -1,16 +1,5 @@ isCreateDirectoryEnabled()); @@ -88,10 +77,10 @@ $sPageSize = 'legal'; } -//echo "ncols={$bNumberofColumns} page size={$sPageSize}"; +LoggerUtils::getAppLogger()->debug("ncols = {$bNumberofColumns} page size = {$sPageSize}"); -// Instantiate the directory class and build the report. -//echo "font sz = {$bFontSz} and line sp={$bLineSp}"; +// Instantiate the directory class and build the report +LoggerUtils::getAppLogger()->debug("font sz = {$bFontSz} and line sp = {$bLineSp}"); $pdf = new PdfDirectory($bNumberofColumns, $sPageSize, $bFontSz, $bLineSp); // Get the list of custom person fields @@ -193,7 +182,8 @@ $isFamily = false; - if ($memberCount > 1) { // Here we have a family record. + if ($memberCount > 1) { + // Here we have a family record $iFamilyID = $per_fam_ID; $isFamily = true; @@ -267,8 +257,6 @@ $sEmail = SelectWhichInfo($per_Email, $fam_Email, false); if ($bDirAddress) { - // if (strlen($sAddress1)) { $OutStr .= $sAddress1 . "\n"; } - // if (strlen($sAddress2)) { $OutStr .= $sAddress2 . "\n"; } if (strlen($sAddress1)) { $OutStr .= $sAddress1; } @@ -317,7 +305,7 @@ $pdf->addHeader($sLastLetter); } - // if photo include pass the id, otherwise 0 equates to no family/pers + // If photo include pass the ID, otherwise 0 equates to no family/person $fid = 0; $pid = 0; if ($bDirPhoto) { @@ -327,7 +315,7 @@ $pid = $per_ID; } } - $pdf->addRecord($pdf->sRecordName, $OutStr, $numlines, $fid, $pid); // another hack: added +1 + $pdf->addRecord($pdf->sRecordName, $OutStr, $numlines, $fid, $pid); } } @@ -335,9 +323,9 @@ $sSQL = 'DROP TABLE IF EXISTS tmp;'; mysqli_query($cnInfoCentral, $sSQL); } -header('Pragma: public'); // Needed for IE when using a shared SSL certificate - -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('Directory-' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/EnvelopeReport.php b/src/Reports/EnvelopeReport.php index 43df5b5e83..40769e1a34 100644 --- a/src/Reports/EnvelopeReport.php +++ b/src/Reports/EnvelopeReport.php @@ -1,12 +1,5 @@ isAdmin() && SystemConfig::getValue('bCSVAdminOnly')) { RedirectUtils::redirect('v2/dashboard'); } @@ -24,9 +19,9 @@ class PdfEnvelopeReport extends ChurchInfoReport { // Private properties - public $_Margin_Left = 12; // Left Margin - public $_Margin_Top = 12; // Top margin - public $_Char_Size = 12; // Character size + public $_Margin_Left = 12; + public $_Margin_Top = 12; + public $_Char_Size = 12; public $_CurLine = 2; public $_Column = 0; public $_Font = 'Times'; @@ -59,11 +54,12 @@ public function __construct() $this->setCharSize(12); } - public function checkLines($numlines): void + public function checkLines(int $numlines): void { - $CurY = $this->GetY(); // Temporarily store off the position + // Temporarily store off the position + $CurY = $this->GetY(); - // Need to determine if we will extend beyoned 17mm from the bottom of + // Need to determine if we will extend beyond 17mm from the bottom of // the page. $this->SetY(-17); if ($this->_Margin_Top + (($this->_CurLine + $numlines) * 5) > $this->GetY()) { @@ -77,27 +73,28 @@ public function checkLines($numlines): void $this->_CurLine = 2; } } - $this->SetY($CurY); // Put the position back + // Put the position back + $this->SetY($CurY); } // This function formats the string for a family - public function sGetFamilyString($aRow): string + public function sGetFamilyString(Family $family): string { - extract($aRow); // Get a row from family_fam - - return $fam_Envelope . ' ' . $this->makeSalutation($fam_ID); + return $family->getEnvelope() . ' ' . $this->makeSalutation($family->getId()); } // Number of lines is only for the $text parameter public function addRecord($text, $numlines): void { - $numlines++; // add an extra blank line after record + // Add an extra blank line after record + $numlines++; $this->checkLines($numlines); $_PosX = $this->_Margin_Left + ($this->_Column * 108); $_PosY = $this->_Margin_Top + ($this->_CurLine * 5); $this->SetXY($_PosX, $_PosY); - $this->MultiCell(0, 5, $text); // set width to 0 prints to right margin + // Set width to 0 prints to right margin + $this->MultiCell(0, 5, $text); $this->_CurLine += $numlines; } } @@ -105,14 +102,11 @@ public function addRecord($text, $numlines): void // Instantiate the directory class and build the report. $pdf = new PdfEnvelopeReport(); -$sSQL = 'SELECT fam_ID, fam_Envelope FROM family_fam WHERE fam_Envelope>0 ORDER BY fam_Envelope'; -$rsRecords = RunQuery($sSQL); +$families = FamilyQuery::Create()->orderByEnvelope()->filterByEnvelope(0, 'Criteria::GREATER_THAN')->find(); -while ($aRow = mysqli_fetch_array($rsRecords)) { +foreach ($families as $family) { $OutStr = ''; - extract($aRow); - - $OutStr = $pdf->sGetFamilyString($aRow); + $OutStr = $pdf->sGetFamilyString($family); // Count the number of lines in the output string if (strlen($OutStr)) { @@ -123,9 +117,9 @@ public function addRecord($text, $numlines): void $pdf->addRecord($OutStr, $numlines); } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('EnvelopeAssignments-' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/FRBidSheets.php b/src/Reports/FRBidSheets.php index 366aa46e84..f8abd97180 100644 --- a/src/Reports/FRBidSheets.php +++ b/src/Reports/FRBidSheets.php @@ -1,13 +1,5 @@ Cell($widBid, $lineHeight, '', 1, 1); } } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('FRBidSheets' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/FamilyPledgeSummary.php b/src/Reports/FamilyPledgeSummary.php index 4c103e0cb5..8d7e34ab75 100644 --- a/src/Reports/FamilyPledgeSummary.php +++ b/src/Reports/FamilyPledgeSummary.php @@ -1,14 +1,5 @@ Output('FamilyPledgeSummary' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/GroupReport.php b/src/Reports/GroupReport.php index abcc223eef..927587e448 100644 --- a/src/Reports/GroupReport.php +++ b/src/Reports/GroupReport.php @@ -1,16 +1,5 @@ 1) - //{ - /* if (strtoupper($sLastLetter) != strtoupper(mb_substr($pdf->sFamily,0,1))) - { - $pdf->checkLines($numlines+2); - $sLastLetter = strtoupper(mb_substr($pdf->sFamily,0,1)); - $pdf->addHeader($sLastLetter); - } */ $pdf->addRecord($pdf->sFamily, $OutStr, $numlines); - // } } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('GroupDirectory-' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/NameTags.php b/src/Reports/NameTags.php index 45d27db0e1..8c3326752f 100644 --- a/src/Reports/NameTags.php +++ b/src/Reports/NameTags.php @@ -1,13 +1,5 @@ setCharSize($sFontSize); } -//if($sFontSize != "default") -// $pdf->SetFontSize($sFontSize); $sSQL = 'SELECT * FROM person_per WHERE per_ID IN (' . convertCartToString($_SESSION['aPeopleCart']) . ') ORDER BY per_LastName'; $rsPersons = RunQuery($sSQL); @@ -81,9 +71,9 @@ $pdf->setCharSize($sFontSize); } } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('NameTags' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/NewsLetterLabels.php b/src/Reports/NewsLetterLabels.php index c0818161bb..06453fe088 100644 --- a/src/Reports/NewsLetterLabels.php +++ b/src/Reports/NewsLetterLabels.php @@ -1,13 +1,5 @@ addPdfLabel($labelText); } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('NewsLetterLabels' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/PDFLabel.php b/src/Reports/PDFLabel.php index 28df0bd616..ee0fd1c087 100644 --- a/src/Reports/PDFLabel.php +++ b/src/Reports/PDFLabel.php @@ -1,30 +1,12 @@ 2) { $sNameAdult = $fam_Name; - } // end if ($numAdult ...) + } - $bSameLastNames = true; // Assume all last names are the same + // Assume all last names are the same + $bSameLastNames = true; - if ($numChild > 0) { // Salutation for children grouped together + // Salutation for children grouped together + if ($numChild > 0) { $firstMember = mysqli_fetch_array($rsMembers); extract($aChild[0]); $firstFirstName = $per_FirstName; @@ -204,13 +189,13 @@ function MakeADCArray($sADClist) // The end of each row is marked with the pipe | symbol // keep fetching rows until gone while (mb_substr_count($sADClist, '|')) { - // find end of current row + // Find end of current row $endOfRow = strpos($sADClist, '|'); if ($endOfRow) { $currentRow = mb_substr($sADClist, 0, $endOfRow); $sADClist = mb_substr($sADClist, $endOfRow + 1); - // find the current adc (hint, last item listed) + // Find the current adc (hint, last item listed) $currentRow = trim($currentRow); $adc = mb_substr($currentRow, strrpos($currentRow, ' ')); $adc = trim($adc, " ,\t\n\r\0\x0B"); @@ -224,13 +209,15 @@ function MakeADCArray($sADClist) if (strpos($currentRow, ',')) { $nugget = trim(mb_substr($currentRow, 0, strpos($currentRow, ','))); $currentRow = trim(mb_substr($currentRow, strpos($currentRow, ',') + 1)); - } else { // parsing last element + } else { + // Parsing last element $nugget = trim($currentRow, " ,\t\n\r\0\x0B"); $currentRow = ''; } $dash = strpos($nugget, '-'); - if ($dash) { // range of + // Range of + if ($dash) { $start = intval(mb_substr($nugget, 0, $dash)); $end = intval(mb_substr($nugget, $dash + 1)); if ($end >= $start) { @@ -251,7 +238,6 @@ function MakeADCArray($sADClist) function ZipBundleSort(array $inLabels) { - // // Description: // sorts an input array $inLabels() for presort bundles // @@ -403,18 +389,16 @@ function ZipBundleSort(array $inLabels) $adc = MakeADCArray($sADClist); - //foreach ($adc as $key => $value) - // echo "key = $key, value = $value
"; + if (SystemConfig::debugEnabled()) { + foreach ($adc as $key => $value) { + LoggerUtils::getAppLogger()->debug("key = $key, value = $value"); + } + } - // // Step 1 - create an array of only the zipcodes of length 5 - // - // 80 - - // $iMinBundleSize = 15; // Minimum number of labels allowed in a bundle - $iZip5MinBundleSize = 15; // Minimum number of labels allowed in a 5 digit zip code bundle - $iZip3MinBundleSize = 10; // Minimum number of labels allowed in a 3 digit zip code bundle - $iAdcMinBundleSize = 10; // Minimum number of labels allowed in an ADC bundle + $iZip5MinBundleSize = 15; // Minimum number of labels allowed in a 5 digit zip code bundle + $iZip3MinBundleSize = 10; // Minimum number of labels allowed in a 3 digit zip code bundle + $iAdcMinBundleSize = 10; // Minimum number of labels allowed in an ADC bundle $n = count($inLabels); $nTotalLabels = $n; @@ -423,18 +407,11 @@ function ZipBundleSort(array $inLabels) $Zips[$i] = intval(mb_substr($inLabels[$i]['Zip'], 0, 5)); } - // - // perform a count of the array values - // - $ZipCounts = array_count_values($Zips); - // - // walk through the input array and pull all matching records where count >= $iZip5MinBundleSize - // - $nz5 = 0; + // Walk through the input array and pull all matching records where count >= $iZip5MinBundleSize foreach ($ZipCounts as $z => $zc) { if ($zc >= $iZip5MinBundleSize) { $NoteText = ['Note' => '******* Presort ZIP-5 ' . $z]; @@ -445,17 +422,14 @@ function ZipBundleSort(array $inLabels) for ($i = 0; $i < $n; $i++) { if (intval(mb_substr($inLabels[$i]['Zip'], 0, 5)) == $z) { $outList[] = array_merge($inLabels[$i], $NoteText); - $inLabels[$i]['Zip'] = -1; // done + $inLabels[$i]['Zip'] = -1; $nz5++; } } } } - // - // remove processed labels for inLabels array - // - + // Remove processed labels for inLabels array for ($i = 0; $i < $n; $i++) { if ($inLabels[$i]['Zip'] != -1) { $inLabels2[] = $inLabels[$i]; @@ -464,30 +438,21 @@ function ZipBundleSort(array $inLabels) unset($inLabels); $inLabels = $inLabels2; - // // Pass 2 looking for ZIP3 bundles - // - unset($Zips); $n = count($inLabels); - //print_r($inLabels); + LoggerUtils::getAppLogger()->debug(print_r($inLabels)); for ($i = 0; $i < $n; $i++) { $Zips[$i] = intval(mb_substr($inLabels[$i]['Zip'], 0, 3)); } - // - // perform a count of the array values - // - $ZipCounts = array_count_values($Zips); - // - // walk through the input array and pull all matching records where count >= $iZip3MinBundleSize - // - $nz3 = 0; + + // Walk through the input array and pull all matching records where count >= $iZip3MinBundleSize foreach ($ZipCounts as $z => $zc) { if ($zc >= $iZip3MinBundleSize) { $NoteText = ['Note' => '******* Presort ZIP-3 ' . $z]; @@ -514,10 +479,7 @@ function ZipBundleSort(array $inLabels) unset($inLabels); $inLabels = $inLabels2; - // // Pass 3 looking for ADC bundles - // - unset($Zips); $n = count($inLabels); @@ -526,24 +488,19 @@ function ZipBundleSort(array $inLabels) $Zips[$i] = $adc[intval(mb_substr($inLabels[$i]['Zip'], 0, 3))]; } } - // - // perform a count of the array values - // + unset($ZipCounts); if (isset($Zips)) { $ZipCounts = array_count_values($Zips); } - // - // walk through the input array and pull all matching records where count >= $iAdcMinBundleSize - // - $ncounts = 0; if (isset($ZipCounts)) { $ncounts = count($ZipCounts); } $nadc = 0; if ($ncounts) { + // Walk through the input array and pull all matching records where count >= $iAdcMinBundleSize foreach ($ZipCounts as $z => $zc) { if ($zc >= $iAdcMinBundleSize) { $NoteText = ['Note' => '******* Presort ADC ' . $z]; @@ -554,7 +511,7 @@ function ZipBundleSort(array $inLabels) for ($i = 0; $i < $n; $i++) { if ($adc[intval(mb_substr($inLabels[$i]['Zip'], 0, 3))] == $z) { $outList[] = array_merge($inLabels[$i], $NoteText); - $inLabels[$i]['Zip'] = -1; // done + $inLabels[$i]['Zip'] = -1; $nadc++; } } @@ -571,9 +528,7 @@ function ZipBundleSort(array $inLabels) unset($inLabels); $inLabels = $inLabels2; - // // Pass 4 looking for remaining Mixed ADC bundles - // $nmadc = 0; unset($Zips); $n = count($inLabels); @@ -590,10 +545,6 @@ function ZipBundleSort(array $inLabels) } } - // - // return the results - // - if (count($outList) > 0) { return $outList; } else { @@ -698,13 +649,11 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp if (!$bOnlyComplete || (strlen($sAddress) && strlen($sCity) && strlen($sState) && strlen($sZip))) { $sLabelList[] = ['Name' => $sName, 'Address' => $sAddress, 'City' => $sCity, 'State' => $sState, 'Zip' => $sZip]; //,'fam_ID'=>$aRow['fam_ID']); } - } // end of foreach loop - } // end of while loop + } + } if ($iBulkMailPresort) { - // - // now sort the label list by presort bundle definitions - // + // Now sort the label list by presort bundle definitions $zipLabels = ZipBundleSort($sLabelList); if ($iBulkMailPresort == 2) { foreach ($zipLabels as $i => $sLT) { @@ -717,7 +666,7 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp $sLT['State'], $sLT['Zip'] )); - } // end while + } } else { foreach ($zipLabels as $i => $sLT) { $pdf->addPdfLabel(sprintf( @@ -728,8 +677,8 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp $sLT['State'], $sLT['Zip'] )); - } // end while - } // end of if ($BulkMailPresort == 2) + } + } } else { foreach ($sLabelList as $i => $sLT) { $pdf->addPdfLabel(sprintf( @@ -740,8 +689,8 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp $sLT['State'], $sLT['Zip'] )); - } // end while - } // end of if($iBulkMailPresort) + } + } if (isset($zipLabels)) { return serialize($zipLabels); @@ -750,10 +699,7 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp } } -// Main body of PHP file begins here - // Standard format - $startcol = InputUtils::legacyFilterInput($_GET['startcol'], 'int'); if ($startcol < 1) { $startcol = 1; @@ -825,14 +771,16 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp ); if ($sFileType === 'PDF') { - header('Pragma: public'); // Needed for IE when using a shared SSL certificate + // Needed for IE when using a shared SSL certificate + header('Pragma: public'); - if (SystemConfig::getValue('iPDFOutputType') == 1) { + if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('Labels-' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); } -} else { // File Type must be CSV +} else { + // File Type must be CSV $delimiter = SystemConfig::getValue('sCSVExportDelimiter'); $sCSVOutput = ''; @@ -875,7 +823,7 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); - //add BOM to fix UTF-8 in Excel 2016 but not under, so the problem is solved with the sCSVExportCharset variable + // Add BOM to fix UTF-8 in Excel 2016 but not under, so the problem is solved with the sCSVExportCharset variable if (SystemConfig::getValue('sCSVExportCharset') == 'UTF-8') { echo "\xEF\xBB\xBF"; } diff --git a/src/Reports/PhotoBook.php b/src/Reports/PhotoBook.php index 82da370100..fa7c7c176d 100644 --- a/src/Reports/PhotoBook.php +++ b/src/Reports/PhotoBook.php @@ -1,13 +1,5 @@ group = GroupQuery::Create()->findOneById($iGroupID); - $this->SetMargins(0, 0); // use our own margin logic. + // Use our own margin logic. + $this->SetMargins(0, 0); $this->SetFont('Times', '', 14); $this->SetAutoPageBreak(false); $this->addPage(); @@ -91,7 +84,7 @@ private function drawPersonBlock($name, $thumbnailURI): void $this->Line($this->currentX + $this->personImageWidth, $this->currentY, $this->currentX, $this->currentY + $this->personImageHeight); } - // move the cursor, and draw the teacher name + // Move the cursor, and draw the teacher name $this->currentX -= $offset; $this->currentY += $this->personImageHeight + 2; $this->writeAt($this->currentX, $this->currentY, $name); @@ -138,9 +131,9 @@ private function drawGroupMebersByRole(string $roleName, string $roleDisplayName foreach ($aGrp as $groupID) { $pdf->drawGroup($groupID); } - -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if ($iPDFOutputType == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('ClassList' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/PledgeSummary.php b/src/Reports/PledgeSummary.php index b4db466db8..a458558251 100644 --- a/src/Reports/PledgeSummary.php +++ b/src/Reports/PledgeSummary.php @@ -1,13 +1,5 @@ isAdmin() && SystemConfig::getValue('bCSVAdminOnly') && $output != 'pdf') { @@ -80,16 +73,13 @@ $sSQL .= ') '; } } -// Order by Fund Active, Fund Name -//$sSQL .= " ORDER BY fundActive, fundName"; + // Order by Family so the related pledges and payments will be together $sSQL .= ' ORDER BY plg_famID'; -// Run Query $rsPledges = RunQuery($sSQL); // Create PDF Report -// ***************** if ($output === 'pdf') { class PdfPledgeSummaryReport extends ChurchInfoReport { @@ -124,7 +114,8 @@ public function __construct() $fundName = ''; $plg_famID = 0; - for ($thisRow = 0; $thisRow <= $totRows; $thisRow += 1) { // go through the loop one extra time + // Go through the loop one extra time + for ($thisRow = 0; $thisRow <= $totRows; $thisRow += 1) { if ($thisRow < $totRows) { $aRow = mysqli_fetch_array($rsPledges); extract($aRow); @@ -136,7 +127,6 @@ public function __construct() if ($plg_famID != $curFam || $thisRow == $totRows) { // Switching families. Post the results for the previous family and initialize for the new family - mysqli_data_seek($rsFunds, 0); while ($row = mysqli_fetch_array($rsFunds)) { $fun_name = $row['fun_Name']; @@ -229,7 +219,8 @@ public function __construct() $pdf->SetFont('Times', '', 10); $curY += SystemConfig::getValue('incrementY'); - mysqli_data_seek($rsFunds, 0); // Change this to print out funds in active / alpha order. + // Change this to print out funds in active / alpha order + mysqli_data_seek($rsFunds, 0); while ($row = mysqli_fetch_array($rsFunds)) { $fun_name = $row['fun_Name']; if ($pledgeFundTotal[$fun_name] > 0 || $paymentFundTotal[$fun_name] > 0) { @@ -264,16 +255,15 @@ public function __construct() $pdf->printRightJustified($paymentCountX, $curY, $paymentCnt['Unassigned']); $curY += SystemConfig::getValue('incrementY'); } - - header('Pragma: public'); // Needed for IE when using a shared SSL certificate - if (SystemConfig::getValue('iPDFOutputType') == 1) { + // Needed for IE when using a shared SSL certificate + header('Pragma: public'); + if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('PledgeSummaryReport' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); } // Output a text file -// ################## } elseif ($output === 'csv') { // Settings $delimiter = ','; @@ -289,10 +279,10 @@ public function __construct() // Remove trailing delimiter and add eol $buffer = mb_substr($buffer, 0, -1) . $eol; - // Add data while ($row = mysqli_fetch_row($rsPledges)) { foreach ($row as $field) { - $field = str_replace($delimiter, ' ', $field); // Remove any delimiters from data + // Remove any delimiters from data + $field = str_replace($delimiter, ' ', $field); $buffer .= $field . $delimiter; } // Remove trailing delimiter and add eol diff --git a/src/Reports/ReminderReport.php b/src/Reports/ReminderReport.php index 6a3b170cd0..42250d6da6 100644 --- a/src/Reports/ReminderReport.php +++ b/src/Reports/ReminderReport.php @@ -1,13 +1,5 @@ isFinanceEnabled()); -//Get the Fiscal Year ID out of the querystring +// Get the Fiscal Year ID out of the query string $iFYID = InputUtils::legacyFilterInput($_POST['FYID'], 'int'); if (!$iFYID) { $iFYID = CurrentFY(); } -$_SESSION['idefaultFY'] = $iFYID; // Remember the chosen FYID +// Remember the chosen Fiscal Year ID +$_SESSION['idefaultFY'] = $iFYID; $output = InputUtils::legacyFilterInput($_POST['output']); $pledge_filter = InputUtils::legacyFilterInput($_POST['pledge_filter']); $only_owe = InputUtils::legacyFilterInput($_POST['only_owe']); @@ -66,7 +59,7 @@ $notInClassList .= ')'; } - // all classes were selected. this should behave as if no filter classes were specified + // All classes were selected -- this should behave as if no filter classes were specified if ($notInClassList === '()') { unset($classList); } @@ -125,7 +118,6 @@ } $sSQL .= $criteria; -//var_dump($sSQL); $rsFamilies = RunQuery($sSQL); $sSQLFundCriteria = ''; @@ -176,7 +168,6 @@ $rsFunds = RunQuery($sSQL); // Create PDF Report -// ***************** class PdfReminderReport extends ChurchInfoReport { // Constructor @@ -473,7 +464,7 @@ public function finishPage($curY): void $pdf->finishPage($curY); } -if (SystemConfig::getValue('iPDFOutputType') == 1) { +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('ReminderReport' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/TaxReport.php b/src/Reports/TaxReport.php index 324ca40f3c..9b9bf0ed84 100644 --- a/src/Reports/TaxReport.php +++ b/src/Reports/TaxReport.php @@ -1,13 +1,5 @@ Cell(40, $summaryIntervalY, 'Fund'); $pdf->Cell(40, $summaryIntervalY, 'Memo'); $pdf->Cell(25, $summaryIntervalY, 'Amount', 0, 1, 'R'); - //$curY = $pdf->GetY(); $totalAmount = 0; $totalNonDeductible = 0; $currentFamilyID = $fam_ID; @@ -471,15 +458,15 @@ public function finishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres ); } - header('Pragma: public'); // Needed for IE when using a shared SSL certificate - if (SystemConfig::getValue('iPDFOutputType') == 1) { + // Needed for IE when using a shared SSL certificate + header('Pragma: public'); + if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('TaxReport' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); } // Output a text file -// ################## } elseif ($output === 'csv') { // Settings $delimiter = ','; @@ -495,10 +482,10 @@ public function finishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres // Remove trailing delimiter and add eol $buffer = mb_substr($buffer, 0, -1) . $eol; - // Add data while ($row = mysqli_fetch_row($rsReport)) { foreach ($row as $field) { - $field = str_replace($delimiter, ' ', $field); // Remove any delimiters from data + // Remove any delimiters from data + $field = str_replace($delimiter, ' ', $field); $buffer .= $field . $delimiter; } // Remove trailing delimiter and add eol diff --git a/src/Reports/VotingMembers.php b/src/Reports/VotingMembers.php index d2ccf827fa..b9e8a4d141 100644 --- a/src/Reports/VotingMembers.php +++ b/src/Reports/VotingMembers.php @@ -1,13 +1,5 @@ writeAt(SystemConfig::getValue('leftX'), $curY, 'Number of Voting Members: ' . $votingMemberCount); -header('Pragma: public'); // Needed for IE when using a shared SSL certificate -if (SystemConfig::getValue('iPDFOutputType') == 1) { +// Needed for IE when using a shared SSL certificate +header('Pragma: public'); +if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('VotingMembers' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); diff --git a/src/Reports/ZeroGivers.php b/src/Reports/ZeroGivers.php index 91254b02cb..de1b56ec50 100644 --- a/src/Reports/ZeroGivers.php +++ b/src/Reports/ZeroGivers.php @@ -1,14 +1,5 @@ finishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Address2, $fam_City, $fam_State, $fam_Zip, $fam_Country); } - if (SystemConfig::getValue('iPDFOutputType') == 1) { + if ((int) SystemConfig::getValue('iPDFOutputType') === 1) { $pdf->Output('ZeroGivers' . date(SystemConfig::getValue('sDateFilenameFormat')) . '.pdf', 'D'); } else { $pdf->Output(); } // Output a text file -// ################## } elseif ($output === 'csv') { // Settings $delimiter = ','; @@ -159,7 +144,8 @@ public function finishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres // Add data while ($row = mysqli_fetch_row($rsReport)) { foreach ($row as $field) { - $field = str_replace($delimiter, ' ', $field); // Remove any delimiters from data + // Remove any delimiters from data + $field = str_replace($delimiter, ' ', $field); $buffer .= $field . $delimiter; } // Remove trailing delimiter and add eol diff --git a/src/sundayschool/SundaySchoolClassListExport.php b/src/sundayschool/SundaySchoolClassListExport.php index ece0f2cb78..8a34269552 100644 --- a/src/sundayschool/SundaySchoolClassListExport.php +++ b/src/sundayschool/SundaySchoolClassListExport.php @@ -1,13 +1,5 @@ orderByName(Criteria::ASC) ->filterByType(4) @@ -66,7 +58,7 @@ $groupRoleMemberships = Person2group2roleP2g2rQuery::create() ->joinWithPerson() ->orderBy(PersonTableMap::COL_PER_LASTNAME) - ->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) // I've try to reproduce per_LastName, per_FirstName + ->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) ->findByGroupId($iGroupID); foreach ($groupRoleMemberships as $groupRoleMembership) { @@ -100,10 +92,10 @@ $zip = $family->getZip(); if ($lst_OptionName === 'Student') { - // only for a student + // Only for a student $FAmembers = FamilyQuery::create()->findOneByID($famID)->getAdults(); - // il faut encore chercher les membres de la famille + // We still have to look for family members foreach ($FAmembers as $maf) { if ($maf->getGender() == 1) { // Dad