<?php

global $genumDateFormat;
$attributes = array('name' => 'frmEditPledge', 'id' => 'frmAddEdit');
echoT(form_open('donations/pledge_add_edit/addEditPayment/' . $lPledgeID . '/' . $lGiftID . '/' . $dtePledge, $attributes));
$clsForm = new generic_form();
$clsForm->strLabelClass = $clsForm->strLabelRowLabelClass = $clsForm->strLabelClassRequired = 'enpViewLabel';
$clsForm->strEntryClass = 'enpView';
$clsForm->bValueEscapeHTML = false;
$clsForm->strStyleExtraLabel = 'width: 100pt;';
openBlock('Pledge Payment', '');
echoT('<table>');
//-------------------------------
// Pledge ID
//-------------------------------
echoT($clsForm->strLabelRow('Pledge ID', str_pad($lPledgeID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . strLinkView_Pledge($lPledgeID, 'View pledge record', true), 1));
//-------------------------------
// Gift ID
//-------------------------------
if (is_null($lGiftID)) {
    $strGiftID = 'n/a';
} else {
    $strGiftID = str_pad($lGiftID, 5, '0', STR_PAD_LEFT);
}
echoT($clsForm->strLabelRow('Gift ID', str_pad($lGiftID, 5, '0', STR_PAD_LEFT), 1));
//-------------------------------
// Commitment
//-------------------------------
echoT($clsForm->strLabelRow('Commitment', $pledge->strACOCurSymbol . ' ' . number_format($pledge->curCommitment, 2) . ' (' . $pledge->enumFreq . ') ' . $pledge->strFlagImg, 1));
//-------------------------------
// Campaign/Account
               </td>
               <td class="enpRptLabel">
                  Campaign
               </td>
               <td class="enpRptLabel">
                  # Commitments
               </td>
               <td class="enpRptLabel">
                  Total Commit.
               </td>
            </tr>');
    foreach ($pledges as $pl) {
        $lPledgeID = $pl->lKeyID;
        echoT('
            <tr>
               <td class="enpRpt">' . str_pad($lPledgeID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . strLinkView_Pledge($lPledgeID, $strTitle, true) . '
               </td>
               <td class="enpRpt" style="text-align: right;">' . $pl->strFormattedAmnt . '
               </td>
               <td class="enpRpt">' . htmlspecialchars($pl->strAccount) . '
               </td>
               <td class="enpRpt">' . htmlspecialchars($pl->strCampaign) . '
               </td>
               <td class="enpRpt" style="text-align: center;">' . number_format($pl->lNumCommit) . '
               </td>
               <td class="enpRpt" style="text-align: right;">' . $pl->strACOCurSymbol . '&nbsp;' . number_format($pl->lNumCommit * $pl->curCommitment, 2) . '&nbsp;' . $pl->strFlagImg . '
               </td>
            </tr>');
    }
    echoT('</table>');
}
function showGiftInfo(&$clsRpt, $lGID, $lFID, $bBiz, &$gifts, $people, $biz, $bSponPayment)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $genumDateFormat;
    // deposit info
    $lDepositID = $gifts->lDepositLogID;
    if (is_null($lDepositID)) {
        $strDeposit = 'n/a';
    } else {
        $strDeposit = strLinkView_DepositEntry($lDepositID, 'View deposit', true) . str_pad($lDepositID, 5, '0', STR_PAD_LEFT) . '&nbsp;&nbsp;';
        if ($gifts->strDepositBank . '' != '') {
            $strDeposit .= $gifts->strDepositBank;
        }
        if ($gifts->strDepositAccount . '' != '') {
            if ($gifts->strDepositBank . '' != '') {
                $strDeposit .= ' / ';
            }
            $strDeposit .= $gifts->strDepositAccount;
        }
        $strDeposit .= ' (created ' . date($genumDateFormat, $gifts->dteDeposit) . ')';
    }
    // pledge info
    if (is_null($gifts->lPledgeID)) {
        $strPledge = 'n/a';
    } else {
        $strPledge = 'pledgeID ' . str_pad($gifts->lPledgeID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . strLinkView_Pledge($gifts->lPledgeID, 'View pledge record', true);
    }
    openBlock(($bSponPayment ? 'Sponsorship Payment' : 'Gift') . "\n", strLinkEdit_GiftRecord($lGID, 'Edit gift record', true) . "\n" . '&nbsp;&nbsp;&nbsp;' . "\n" . strLinkAdd_Gift($lFID, 'Add new gift', true) . "\n" . '&nbsp;&nbsp;&nbsp;' . "\n" . strLinkView_GiftsHistory($lFID, 'View donor\'s gift history', true) . '&nbsp;' . strLinkView_GiftsHistory($lFID, 'Donor\'s gift history', false) . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . "\n" . strLinkRem_Gift($lGID, 'Remove this gift record', true, true) . "\n\n");
    echoT($clsRpt->openReport());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Gift ID:') . $clsRpt->writeCell(str_pad($lGID, 5, '0', STR_PAD_LEFT), '', '', 1, 1, ' id="gift_id" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Amount:') . $clsRpt->writeCell($gifts->strFormattedAmnt, '', '', 1, 1, ' id="gift_amount" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Date:') . $clsRpt->writeCell(date($genumDateFormat, $gifts->gi_dteDonation), '', '', 1, 1, ' id="gift_date" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Account:') . $clsRpt->writeCell(htmlspecialchars($gifts->ga_strAccount), '', '', 1, 1, ' id="gift_acct" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Campaign:') . $clsRpt->writeCell(htmlspecialchars($gifts->gc_strCampaign), '', '', 1, 1, ' id="gift_camp" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Check #:') . $clsRpt->writeCell(htmlspecialchars($gifts->gi_strCheckNum), '', '', 1, 1, ' id="gift_cn" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Pledge:') . $clsRpt->writeCell($strPledge, '', '', 1, 1, ' id="gift_pledge" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Payment Type:') . $clsRpt->writeCell(htmlspecialchars($gifts->strPaymentType), '', '', 1, 1, ' id="gift_pt" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Deposit:') . $clsRpt->writeCell($strDeposit, '', '', 1, 1, ' id="gift_dep" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Gift Category:') . $clsRpt->writeCell(htmlspecialchars($gifts->strMajorGiftCat), '', '', 1, 1, ' id="gift_cat" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Attributed To:') . $clsRpt->writeCell(htmlspecialchars($gifts->strAttribTo), '', '', 1, 1, ' id="gift_attrib" ') . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Notes:') . $clsRpt->writeCell(nl2br(htmlspecialchars($gifts->strNotes)), '', '', 1, 1, ' id="gift_notes" ') . $clsRpt->closeRow());
    //--------------------
    // in-kind
    //--------------------
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('In-Kind?:'));
    if ($gifts->gi_bGIK) {
        echoT($clsRpt->writeCell('Yes - ' . htmlspecialchars($gifts->strInKind), '', '', 1, 1, ' id="gift_ik" '));
    } else {
        echoT($clsRpt->writeCell('No', '', '', 1, 1, ' id="gift_ik" '));
    }
    echoT($clsRpt->closeRow());
    //--------------------
    // Acknowledged?
    //--------------------
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Acknowledged?:', '', 'padding-top: 8px;'));
    if ($gifts->bAck) {
        echoT($clsRpt->writeCell('Yes - ' . date($genumDateFormat, $gifts->dteAck) . ' ' . strLinkSpecial_GiftChangeAck($lGID, false, 'Set to unacknowledged', true), '', 'padding-top: 8px;', 1, 1, ' id="gift_ack" '));
    } else {
        echoT($clsRpt->writeCell('No ' . strLinkSpecial_GiftChangeAck($lGID, true, 'Set to acknowledged', true), '', 'padding-top: 8px;', 1, 1, ' id="gift_ack" '));
    }
    echoT($clsRpt->closeRow());
    echoT($clsRpt->closeReport(''));
    closeBlock();
}
         </td>
         <td class="enpRptLabel">
            Total<br>Commitment
         </td>
         <td class="enpRptLabel">
            Frequency
         </td>
         <td class="enpRptLabel">
            Fulfillment
         </td>
      </tr>');
foreach ($pledges as $pledge) {
    $lPledgeID = $pledge->lKeyID;
    echoT('
         <tr class="makeStripe">
            <td class="enpRpt" style="text-align: center; width: 40pt" nowrap>' . str_pad($lPledgeID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . strLinkView_Pledge($lPledgeID, 'View pledge', true) . '
            </td>
            <td class="enpRpt" style="text-align: center; width: 20pt" nowrap>' . strLinkEdit_Pledge($lPledgeID, 'Edit pledge', true) . '
            </td>
            <td class="enpRpt">
               Date
            </td>
            <td class="enpRpt" style="text-align: right; width: 100pt;">' . $pledge->lNumCommit . ' x ' . $pledge->strFormattedAmnt . '
            </td>
            <td class="enpRpt" style="text-align: right; width: 80pt;">' . $pledge->strACOCurSymbol . '&nbsp;' . number_format($pledge->lNumCommit * $pledge->curCommitment, 2) . '
            </td>
            <td class="enpRpt" style="text-align: center; width: 80pt;">' . $pledge->enumFreq . '
            </td>
            <td class="enpRpt" style="text-align: right; width: 80pt;">' . $pledge->strACOCurSymbol . '&nbsp;' . number_format($pledge->curTotFulfill, 2) . '&nbsp;' . $pledge->strFlagImg . '
            </td>
         </tr>');