<?php

if (!bAllowAccess('adminOnly')) {
    return '';
}
echoT('<br>' . strLinkAdd_TimeSheetProject('Add time sheet project', true) . '&nbsp;' . strLinkAdd_TimeSheetProject('Add time sheet project', false) . '<br>');
if ($lNumProjects <= 0) {
    echoT('<br><i>There are no time sheet projects defined in your database.</i><br><br>');
    return;
}
openTSProjectsTable();
foreach ($projects as $proj) {
    writeProjectRow($proj);
}
closeTSProjectsTable();
function writeProjectRow($proj)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    $lProjectID = $proj->lKeyID;
    echoT('
            <tr class="makeStripe">
               <td class="enpRpt" style="width: 50pt; text-align: center;">' . strLinkEdit_TimeSheetProject($lProjectID, 'Edit project', true) . '&nbsp;' . str_pad($lProjectID, 5, '0', STR_PAD_LEFT) . '
               </td>
               <td class="enpRpt" style="width: 20pt; text-align: center;">' . strLinkRem_TimeSheetProject($lProjectID, 'Remove project', true, true) . ' 
               </td>
               <td class="enpRpt" style="width: 200pt;">' . htmlspecialchars($proj->strProjectName) . '
               </td>
               <td class="enpRpt" style="text-align: center;">' . ($proj->bInternalProject ? 'Yes' : 'No') . '
               </td>
$bSubmitted = !is_null($logRec->dteSubmitted);
echoT(ts_util\strTSTLogOverviewBlock($clsRpt, $tst, $logRec, false, false));
$b24Hr = $logRec->b24HrTime;
$clsForm = new generic_form();
$clsForm->strLabelClass = $clsForm->strLabelRowLabelClass = $clsForm->strLabelClassRequired = 'enpViewLabel';
$clsForm->strTitleClass = 'enpViewTitle';
$clsForm->strEntryClass = 'enpView';
$clsForm->bValueEscapeHTML = false;
$clsForm->strStyleExtraLabel = 'padding-top: 8px;';
$clsForm->strStyleExtraValue = 'vertical-align: middle;';
openBlock('Assign Times to Projects', '');
echoT('<table class="enpView" >');
$idx = 0;
$clsForm->strID = 'addEditEntry';
foreach ($projects as $project) {
    writeProjectRow($idx, $project);
    ++$idx;
}
echoT('</table>');
closeBlock();
echoT($clsForm->strSubmitEntry('Save', 2, 'cmdSubmit', 'text-align: center; width: 90pt;'));
echoT(form_close('<br>'));
echoT('<script type="text/javascript">frmAddEdit.addEditEntry.focus();</script>');
function writeProjectRow($idx, $project)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    if (is_numeric($project->lAssignedMin)) {
        $strValue = strDurationViaMinutes($project->lAssignedMin);
    } else {