function showPayRec($clsRpt, &$pRec, $lSponID, $lFPayerID, $lPayID)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $genumDateFormat;
    openBlock('Sponsor payment record ', strLinkEdit_SponsorPayment($lSponID, $lFPayerID, $lPayID, 'Edit payment record', true) . '  ' . strLinkAdd_SponsorPayment($lSponID, 'Add new payment', true) . '          ' . strLinkRem_SponsorPayment($lSponID, $lPayID, 'Remove payment', true, true));
    echoT($clsRpt->openReport() . $clsRpt->openRow() . $clsRpt->writeLabel('Payment ID:') . $clsRpt->writeCell(str_pad($lPayID, 5, '0', STR_PAD_LEFT), '', '', 1, 1, 'id="sponPayID"') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Amount:') . $clsRpt->writeCell($pRec->strCurSymbol . ' ' . number_format($pRec->curPaymentAmnt, 2) . ' ' . $pRec->strFlagImage) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Date of payment:') . $clsRpt->writeCell(date($genumDateFormat, $pRec->dtePayment)) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Payment type:') . $clsRpt->writeCell(htmlspecialchars($pRec->strPaymentType)) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Check #:') . $clsRpt->writeCell(htmlspecialchars($pRec->strCheckNum)) . $clsRpt->closeRow());
    if ($pRec->lSponPeopleID == $pRec->lDonorID) {
        $strPayer = $pRec->strSponSafeNameFL . ' (sponsor)';
    } else {
        if ($pRec->bDonorBiz) {
            $strPayer = strLinkView_BizRecord($pRec->lDonorID, 'View business record', true) . ' ';
        } else {
            $strPayer = strLinkView_PeopleRecord($pRec->lDonorID, 'View people record', true) . ' ';
        }
        $strPayer .= $pRec->strDonorSafeNameFL . ' <b>(THIRD PARTY PAYER)</b>';
    }
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Payer:') . $clsRpt->writeCell($strPayer) . $clsRpt->closeRow() . $clsRpt->closeReport());
}
function strSponsorFinancialSummary(&$clsRpt, &$clsSCP, $lSponID, $strWidthLabel)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    $clsACO = new madmin_aco();
    $clsRpt->strWidthLabel = $strWidthLabel;
    //---------------
    // Charges
    //---------------
    $clsSCP->chargeHistoryTotals($lSponID);
    $strCharge = strLinkAdd_SponsorCharges($lSponID, 'Add new charge', true) . ' ' . strLinkAdd_SponsorCharges($lSponID, 'Add new charge', false) . '<br>';
    if ($clsSCP->lNumChargesTotal == 0) {
        $strCharge .= '<i>No charges have been applied.</i>';
    } else {
        $strCharge .= '<table>';
        foreach ($clsSCP->chargesTotal as $clsACOCharge) {
            $strCharge .= '<tr>
                    <td>' . $clsACOCharge->strACOFlagImg . '</td>
                    <td>' . $clsACOCharge->strACOCurSym . '</td>
                    <td style="text-align:right;">' . number_format($clsACOCharge->curTotal, 2) . '</td>
                 </tr>';
        }
        $strCharge .= '</table>';
    }
    //---------------
    // Payments
    //---------------
    $clsSCP->cumulativeSponsorshipViaSponID($clsACO, $lSponID);
    $strPay = strLinkAdd_SponsorPayment($lSponID, 'Add new payment', true) . ' ' . "\n" . strLinkAdd_SponsorPayment($lSponID, 'Add new payment', false) . '<br>' . "\n";
    if ($clsSCP->lNumSponPayCumulative == 0) {
        $strPay .= '<i>No payments have been made.</i><br><br>';
    } else {
        $strPay .= '<table>';
        foreach ($clsSCP->sponPayCumulative as $clsACOPay) {
            $strPay .= '<tr>
                    <td>' . $clsACOPay->strFlagImg . '</td>
                    <td>' . $clsACOPay->strCurSymbol . '</td>
                    <td style="text-align:right;">' . number_format($clsACOPay->curCumulative, 2) . '</td>
                 </tr>';
        }
        $strPay .= '</table><br>' . "\n";
    }
    $clsSCP->balanceSummary();
    $strOut = $clsRpt->openReport() . "\n" . $clsRpt->openRow() . "\n" . $clsRpt->writeLabel('Charges:') . "\n" . $clsRpt->writeCell($strCharge) . "\n" . $clsRpt->closeRow() . "\n" . $clsRpt->openRow() . "\n" . $clsRpt->writeLabel('Payments:') . "\n" . $clsRpt->writeCell($strPay) . "\n" . $clsRpt->closeRow() . "\n" . $clsRpt->openRow() . "\n" . $clsRpt->writeLabel('Balance:') . "\n" . $clsRpt->writeCell($clsSCP->strBalanceSummaryHTMLTable()) . "\n" . $clsRpt->closeRow() . "\n" . $clsRpt->closeReport("\n");
    return $strOut;
}
function showSponsorPaymentList($lNumPayments, &$payHistory, $lSponID, $lSponFID)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    openBlock('Sponsor Payments', strLinkAdd_SponsorPayment($lSponID, 'Add new payment', true) . '&nbsp;' . strLinkAdd_SponsorPayment($lSponID, 'Add new payment', false));
    if ($lNumPayments > 0) {
        openSponPaymentList();
        writeSponPaymentList($lNumPayments, $payHistory, $lSponFID);
        closeSponPaymentList();
    } else {
        echoT('<i>There are no payments associated with this sponsorship.</i><br><br>');
    }
    closeBlock();
}