function showCProgARecFields(&$clsRpt, &$cprog, &$arec)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $genumDateFormat;
    echoT($clsRpt->openRow() . $clsRpt->writeLabel($cprog->strSafeEnrollLabel . ' Record:') . $clsRpt->writeCell(str_pad($arec->lEnrollID, 5, '0', STR_PAD_LEFT) . ' ' . strLinkView_CProgEnrollRec($cprog->lEnrollmentTableID, $arec->lClientID, $arec->lEnrollID, 'View enrollment record', true)) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Attendance Log:') . $clsRpt->writeCell(strLinkView_CProgAttendanceViaCID($cprog->lAttendanceTableID, $arec->lEnrollID, $arec->lClientID, 'View attendance records', true) . ' ' . strLinkView_CProgAttendanceViaCID($cprog->lAttendanceTableID, $arec->lEnrollID, $arec->lClientID, 'View attendance records', false)) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Attendance Date:') . $clsRpt->writeCell(date($genumDateFormat, $arec->dteAttendance)) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Duration:') . $clsRpt->writeCell(number_format($arec->dDuration, 2)) . $clsRpt->closeRow());
    echoT($clsRpt->openRow() . $clsRpt->writeLabel('Case Notes:') . $clsRpt->writeCell(nl2br(htmlspecialchars($arec->strCaseNotes))) . $clsRpt->closeRow());
}
function strProgramTable($lClientID, $programs)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $genumDateFormat;
    $strOut = '<table class="enpRpt" width="100%">';
    $strOut .= '<tr>
             <td class="enpRptLabel" style="font-size: 8pt;">
                Program
             </td>
             <td class="enpRptLabel" style="font-size: 8pt;">
                Enrollment ID
             </td>
             <td class="enpRptLabel" style="font-size: 8pt;">
                Dates
             </td>
          </tr>';
    foreach ($programs as $prog) {
        $lCProgID = $prog->lCProgID;
        $lERecID = $prog->lERecID;
        $dteEnd = $prog->dteEnd;
        if (is_null($dteEnd)) {
            $strDateEnd = '<i>ongoing</i>';
        } else {
            $strDateEnd = date($genumDateFormat, $dteEnd);
        }
        $strOut .= '<tr>
                <td class="enpRpt" style="font-size: 8pt; width: 140pt;">' . htmlspecialchars($prog->strProgName) . '
                </td>
                <td class="enpRpt" style="font-size: 8pt; width: 60pt; text-align: center;">' . strLinkView_CProgEnrollRec($prog->lETableID, $lClientID, $lERecID, 'View enrollment record', true) . str_pad($lERecID, 5, '0', STR_PAD_LEFT) . '                   
                </td>
                <td class="enpRpt" style="font-size: 8pt;">' . date($genumDateFormat, $prog->dteStart) . ' - ' . $strDateEnd . '
                </td>
             </tr>';
    }
    $strOut .= '</table>';
    return $strOut;
}
<?php

echoT('
    You have successfully enrolled <b>' . $client->strSafeName . '</b> in <b>' . htmlspecialchars($cprog->strProgramName) . '</b>.<br><br>');
echoT(strLinkAdd_CProgAttendance(false, $lClientID, $lCProgID, $lEnrollRecID, 'Add ' . $cprog->strSafeAttendLabel . ' Record', true) . '&nbsp;' . strLinkAdd_CProgAttendance(false, $lClientID, $lCProgID, $lEnrollRecID, 'Add ' . $cprog->strSafeAttendLabel . ' Record', false) . '<br><br>');
echoT(strLinkView_CProgEnrollRec($lTableID, $lClientID, $lEnrollRecID, 'View ' . $cprog->strSafeEnrollLabel . ' record', true) . '&nbsp;' . strLinkView_CProgEnrollRec($lTableID, $lClientID, $lEnrollRecID, 'View ' . $cprog->strSafeEnrollLabel . ' record', false) . '<br><br>');
echoT(strLinkView_ClientRecord($lClientID, 'View client record', true) . '&nbsp;' . strLinkView_ClientRecord($lClientID, 'View client record', false) . '<br><br>');
/*
*/
function strAttendanceTable(&$cprog, $attrib)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    $lMaxDays = lDaysInMonth($attrib->lMonth, $attrib->lYear);
    $lNumERecs = $cprog->lNumERecs;
    if ($lNumERecs > 0) {
        $lATableID = $cprog->lAttendanceTableID;
        $strATable = $cprog->strAttendanceTable;
        $strAFNPrefix = $cprog->strATableFNPrefix;
        $lETableID = $cprog->lEnrollmentTableID;
        $attend = array();
        $idx = 0;
        foreach ($cprog->erecs as $erec) {
            $lERecID = $erec->lKeyID;
            $lClientID = $erec->lClientID;
            // load the enrollees
            $attend[$idx] = array();
            $attend[$idx][0] = strLinkView_ClientRecord($lClientID, 'View client record', true) . '&nbsp;' . str_pad($lClientID, 5, '0', STR_PAD_LEFT) . '&nbsp;&nbsp;' . '<b>' . htmlspecialchars($erec->strClientLName) . '</b>, ' . htmlspecialchars($erec->strClientFName);
            // enrollment link
            $attend[$idx][1] = strLinkView_CProgEnrollRec($lETableID, $lClientID, $lERecID, 'View Enrollment', true) . '&nbsp;' . str_pad($lERecID, 5, '0', STR_PAD_LEFT);
            // populate the attendance cells
            $strCheckImg = '<div style="display:inline-block; width: 100%; text-align: center;"><img src="' . DL_IMAGEPATH . '/misc/check06.gif"></div>';
            for ($jidx = 2; $jidx <= $lMaxDays + 1; ++$jidx) {
                if (bEnrolleeInAttendance($erec, $attrib->lMonth, $jidx - 1, $attrib->lYear)) {
                    $attend[$idx][$jidx] = $strCheckImg;
                    $strEntry = '';
                    arecIDXsViaERecDate($erec, $attrib->lMonth, $jidx - 1, $attrib->lYear, $lNumARecs, $arecIDX);
                    $lCnt = 1;
                    foreach ($arecIDX as $aIDX) {
                        $arecCurrent = $erec->arecs[$aIDX];
                        $lARecID = $arecCurrent->lKeyID;
                        if ($lNumARecs > 1) {
                            $strEntry .= '(' . $lCnt . ')<br>';
                            ++$lCnt;
                        }
                        if ($attrib->bALink) {
                            $strEntry .= strLinkView_CProgAttendRec($lATableID, $lClientID, $lARecID, 'View attendance record', true) . str_pad($lARecID, 5, '0', STR_PAD_LEFT) . '<br>';
                        }
                        if ($attrib->bDuration) {
                            $strEntry .= '<b>duration:</b> ' . number_format($arecCurrent->dDuration, 2) . 'hr<br>';
                        }
                        if ($attrib->bActivity) {
                            $strEntry .= '<b>activity:</b> ' . strShortenString($arecCurrent->strActivity, 25, true) . '<br>';
                        }
                        if ($attrib->bCNotes) {
                            $strEntry .= '<b>case notes:</b> ' . strShortenString($arecCurrent->strCaseNotes, 25, true) . '<br>';
                        }
                    }
                    if ($strEntry != '') {
                        $attend[$idx][$jidx] .= '<br>' . $strEntry;
                    }
                } else {
                    $attend[$idx][$jidx] = '&nbsp;';
                }
            }
            ++$idx;
        }
    }
    // build the html table
    $strOut = '
          <div id="attendTable" style="width: 100%; overflow: auto; ">
          <table class="enpRpt">
             <tr>
                <td class="enpRptTitle" colspan="' . ($lMaxDays + 2) . '">' . htmlspecialchars($cprog->strSafeAttendLabel) . ': ' . htmlspecialchars($cprog->strProgramName) . '
                </td>
             </tr>
             <tr>
                <td class="enpRptLabel" rowspan="2" style="vertical-align: bottom;">Enrollee</td>
                <td class="enpRptLabel" rowspan="2" style="vertical-align: bottom;">Enrollment<br>Record</td>
                <td class="enpRptLabel" colspan="' . $lMaxDays . '" style="text-align: center; vertical-align: middle; font-size: 12pt;">' . $attrib->strLinkPrev . strXlateMonth($attrib->lMonth) . ' ' . $attrib->lYear . $attrib->strLinkNext . '</td></tr><tr>' . "\n";
    for ($jidx = 1; $jidx <= $lMaxDays; ++$jidx) {
        $strOut .= '<td class="enpRptLabel" style="text-align: center;">&nbsp;' . $jidx . '&nbsp;</td>' . "\n";
    }
    $strOut .= '</tr>' . "\n";
    for ($idx = 0; $idx < $lNumERecs; ++$idx) {
        $strOut .= '<tr class="makeStripe">' . "\n";
        $strOut .= '<td class="enpRpt" style="width: 170pt;" nowrap>' . $attend[$idx][0] . '</td>' . "\n";
        for ($jidx = 1; $jidx <= $lMaxDays + 1; ++$jidx) {
            $strOut .= '<td class="enpRpt" style="font-size: 8pt;" nowrap>' . $attend[$idx][$jidx] . '</td>' . "\n";
        }
        $strOut .= '</tr">' . "\n";
    }
    $strOut .= '</table></div>';
    return $strOut;
}
function strEnrollmentTable(&$cprog, $lCID, $lNumEnrollments, $erecs)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $genumDateFormat;
    $lATableID = $cprog->lAttendanceTableID;
    if ($lNumEnrollments == 0) {
        return '<i>No enrollments</i>';
    }
    $strOut = '<table class="enpRpt" width="100%">
            <tr>
               <td class="enpRptLabel" style="background-color: #e6e6e6; 
                        vertical-align: middle; text-align: center; width: 120pt;" rowspan="2">
                  ' . $cprog->strSafeEnrollLabel . ' Dates
               </td>
               <td class="enpRptLabel" style="background-color: #e6e6e6; 
                         vertical-align: middle; text-align: center; width: 40pt;" rowspan="2">
                  Active?
               </td>
               <td class="enpRptLabel" style="background-color: #e6e6e6; text-align: center;" colspan="2">
                  ' . $cprog->strSafeAttendLabel . '
               </td>
            </tr>
            <tr>
               <td class="enpRptLabel" style="background-color: #e6e6e6; text-align: center;"">
                  # Days
               </td>
               <td class="enpRptLabel" style="background-color: #e6e6e6; text-align: center;"">
                  # Hours
               </td>
            </tr>';
    foreach ($erecs as $erec) {
        $eRecID = $erec->lKeyID;
        $strLinkERec = strLinkView_CProgEnrollRec($cprog->lEnrollmentTableID, $lCID, $eRecID, 'View enrollment record', true);
        if (is_null($erec->dteEnd) || $erec->dteEnd == 0) {
            $strDateEnd = 'ongoing';
        } else {
            $strDateEnd = date($genumDateFormat, $erec->dteEnd);
        }
        if (isset($erec->strFlagsTable)) {
            $strCFlags = '&nbsp;' . $erec->strFlagsTable;
        } else {
            $strCFlags = '';
        }
        $strOut .= '
               <tr>
                  <td class="enpRpt">' . $strLinkERec . '&nbsp;' . date($genumDateFormat, $erec->dteStart) . ' - ' . $strDateEnd . $strCFlags . '
                  </td>
                  <td class="enpRpt" style="text-align: center;">' . ($erec->bCurrentlyEnrolled ? 'Yes' : 'No') . '
                  </td>
                  <td class="enpRpt" style="text-align: center;">' . $erec->lNumDaysAttended . '
                  </td>
                  <td class="enpRpt" style="text-align: center;">' . number_format($erec->sngNumHours, 2) . '&nbsp;' . strLinkView_CProgAttendanceViaCID($lATableID, $eRecID, $lCID, 'View attendance', true) . '
                  </td>
               </tr>';
    }
    $strOut .= '</table>';
    return $strOut;
}