?>
">
	</td>
</tr>
<?php 
$tabControl->EndCustomField("SORT");
$tabControl->AddSection("LEARNING_ACTIVATION_SCHEDULE", GetMessage('LEARNING_ACTIVATION_SCHEDULE'));
$tabControl->BeginCustomField("PROPERTY_2", GetMessage('LEARNING_ACTIVATION_SCHEDULE_TITLE'), false);
$html = '<table cellpadding="0" cellspacing="0" border="0" class="nopadding" width="100%" id="tb' . md5($name) . '">';
$arLessons = $arDelays = array();
if ($ID && $str_COURSE_LESSON_ID) {
    $rs = CLearnLesson::GetListOfImmediateChilds($str_COURSE_LESSON_ID, array('SORT' => 'ASC'));
    while ($ar = $rs->getNext()) {
        $arLessons[$ar['LESSON_ID']] = $ar['NAME'];
    }
    $arDelays = CLearningGroupLesson::getDelays($ID, array_keys($arLessons));
    foreach ($arLessons as $lessonId => $lessonName) {
        $period = $arDelays[$lessonId];
        $html .= '<tr><td>';
        $html .= $lessonName;
        $html .= '</td><td>';
        $html .= '<input type="text" name="PERIOD_L[' . $lessonId . ']" size="4" maxlength="5" value="' . htmlspecialcharsbx($period) . '">';
        $html .= '</td></tr>';
    }
} else {
    $html .= GetMessage('LEARNING_AVAILABLE_AFTER_ELEMENT_CREATION');
}
$html .= '</table>';
?>
<tr id="tr_PROPERTY_2">
	<td class="adm-detail-valign-top" width="40%"><?php 
 public static function getActiveLearningChaptersPeriod($courseLessonId, $userId)
 {
     $arGroupsPeriods = self::getActiveLearningGroupsPeriod($courseLessonId, $userId);
     if (!$arGroupsPeriods['IS_EXISTS']) {
         return false;
     }
     $arChaptersActiveFrom = array();
     $arGroupsActiveFrom = $arGroupsPeriods['GROUPS_ACTIVE_FROM'];
     $arLessons = array();
     $rs = CLearnLesson::GetListOfImmediateChilds($courseLessonId, array(), array('CHECK_PERMISSIONS' => 'N'), array('LESSON_ID'));
     $arMinChaptersActiveFromTimestamp = array();
     while ($ar = $rs->fetch()) {
         $arLessons[$ar['LESSON_ID']] = $ar['NAME'];
         $arChaptersActiveFrom[$ar['LESSON_ID']] = null;
         $arMinChaptersActiveFromTimestamp[$ar['LESSON_ID']] = PHP_INT_MAX;
     }
     // Get the nearest dates, when lesson can be opened
     foreach ($arGroupsActiveFrom as $groupId => $groupActiveFrom) {
         if ($groupActiveFrom === null) {
             continue;
         }
         $arDelays = CLearningGroupLesson::getDelays($groupId, array_keys($arLessons));
         $groupActiveFromTs = MakeTimeStamp($groupActiveFrom);
         foreach ($arDelays as $lessonId => $delay) {
             $fromTs = $groupActiveFromTs + 86400 * $delay;
             // 24h is 86400 seconds
             // search for nearest dates
             if ($fromTs < $arMinChaptersActiveFromTimestamp[$lessonId]) {
                 $arChaptersActiveFrom[$lessonId] = ConvertTimeStamp($fromTs, 'FULL');
                 $arMinChaptersActiveFromTimestamp[$lessonId] = $fromTs;
             }
         }
     }
     return $arChaptersActiveFrom;
 }