function showSponsorChargeList($lNumCharges, &$charges, $lSponID)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    //   $clsSCP->cumulativeChargeHistory($lSponID);
    openBlock('Sponsor Charges', strLinkAdd_SponsorCharges($lSponID, 'Add new charge', true) . ' ' . strLinkAdd_SponsorCharges($lSponID, 'Add new charge', false));
    if ($lNumCharges > 0) {
        openSponChargeList();
        writeSponChargeList($lNumCharges, $charges);
        closeSponChargeList();
    } else {
        echoT('<i>There are no charges associated with this sponsorship.</i><br><br>');
    }
    closeBlock();
}
function showChargeRec($clsRpt, $cRec, $lSponID, $lChargeID)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $genumDateFormat;
    openBlock('Charge Record', strLinkEdit_SponChargeRec($lSponID, $lChargeID, 'Edit Charge Record', true) . '&nbsp;&nbsp;&nbsp;' . strLinkAdd_SponsorCharges($lSponID, 'Add new charge', true) . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . strLinkRem_SponsorCharge($lSponID, $lChargeID, 'Remove charge', true, true));
    echoT($clsRpt->openReport() . $clsRpt->openRow() . $clsRpt->writeLabel('Charge ID:') . $clsRpt->writeCell(str_pad($lChargeID, 5, '0', STR_PAD_LEFT)) . $clsRpt->closeRow());
    $lAutoChargeID = $cRec->lAutoGenID;
    if (is_null($lAutoChargeID)) {
        $strAutoCell = 'n/a';
    } else {
        $strAutoCell = strLinkView_SponsorAutoCharge($lAutoChargeID, 'View auto-charge entry', true) . '&nbsp;' . str_pad($lAutoChargeID, 5, '0', STR_PAD_LEFT);
    }
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('AutoGen ID:') . $clsRpt->writeCell($strAutoCell) . $clsRpt->closeRow() . $clsRpt->openRow() . $clsRpt->writeLabel('Amount:') . $clsRpt->writeCell($cRec->strCurSymbol . ' ' . number_format($cRec->curChargeAmnt, 2) . ' ' . $cRec->strFlagImage) . $clsRpt->closeRow() . $clsRpt->openRow() . $clsRpt->writeLabel('Date of charge:') . $clsRpt->writeCell(date($genumDateFormat, $cRec->dteCharge)) . $clsRpt->closeRow() . $clsRpt->closeReport());
    closeBlock();
}
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;
}