예제 #1
0
    ?>

        <?php 
    $lessons_f = array();
    foreach ($column_periods as $pd_n) {
        $lessons_f[$pd_n] = array();
    }
    $lc = 0;
    foreach (TimetablePeriodAllocation::get($where = array('attendinguser_id' => $currentuser_id)) as $p_alloc) {
        $lessons = TimetableLesson::get($where = array('id' => $p_alloc->getLessonId(), 'weekday' => $weekday, 'week_block' => $week_block));
        if (!empty($lessons)) {
            $lc += 1;
            $lesson = $lessons[0];
            $period = TimetablePeriod::get($where = array('id' => $lesson->getPeriodId()))[0];
            $activity = TimetableActivity::get($where = array('id' => $lesson->getActivityId()))[0];
            $rm = TimetableRoom::get($where = array('id' => $lesson->getRoomId()))[0];
            $lessons_f[$period->getNumber()]['subject'] = $activity->getName();
            if ($rm != '') {
                $lessons_f[$period->getNumber()]['room'] = $rm->getName();
            }
        }
    }
    ?>
        <p class="lead">You have <?php 
    echo $lc;
    ?>
 lesson(s) today.</p>
        
        
        <?php 
    if ($lc != 0) {
예제 #2
0
function print_timetable_by_week($currentuser_id, $week_block)
{
    $d_o_w = array(1 => "Monday", 2 => "Tuesday", 3 => "Wednesday", 4 => "Thursday", 5 => "Friday", 6 => "Saturday", 7 => "Sunday");
    $row_days = array();
    $column_periods = array();
    foreach (TimetablePeriod::get() as $period) {
        /*
        0 = Monday - Friday
        1 = Mon
        ...
        6 = Saturday
        7 = Sunday
        8 = Monday - Sunday
        */
        $wd = $period->getWeekday();
        if ($wd == 0) {
            $row_days = array_merge($row_days, range(1, 5));
        } else {
            if ($wd == 8) {
                $row_days = array_merge($row_days, range(1, 7));
            } else {
                array_push($row_days, $wd);
            }
        }
        $period = $period->getNumber();
        array_push($column_periods, $period);
    }
    $row_days = array_unique($row_days);
    $column_periods = array_unique($column_periods);
    sort($row_days);
    sort($column_periods);
    $timetable = array();
    foreach ($column_periods as $periodn) {
        $timetable[$periodn] = array();
        foreach ($row_days as $dayn) {
            $timetable[$periodn][$dayn] = array();
        }
    }
    $p_allocs = TimetablePeriodAllocation::get($where = array('attendinguser_id' => $currentuser_id));
    foreach ($p_allocs as $period_alloc) {
        // must exist, foreign key relationships are enforced strictly by MySQL
        $lesson = '';
        $lesson_l = TimetableLesson::get($where = array('week_block' => $week_block, 'id' => $period_alloc->getLessonId()));
        if (!empty($lesson_l)) {
            $lesson = $lesson_l[0];
        } else {
            continue;
        }
        $period = TimetablePeriod::get($where = array('id' => $lesson->getPeriodId()))[0];
        $activity = TimetableActivity::get($where = array('id' => $lesson->getActivityId()))[0];
        $rm = '';
        if ($lesson->getRoomId() != '') {
            $rm = TimetableRoom::get($where = array('id' => $lesson->getRoomId()))[0];
        }
        $timetable[$period->getNumber()][$lesson->getWeekday()]["subject"] = $activity->getName();
        //echo
        if ($rm != '') {
            $timetable[$period->getNumber()][$lesson->getWeekday()]["room"] = $rm->getName();
        }
    }
    ?>
                
        <table class="table table-bordered timetable">
			<tr>
				<th class="col-md-1"># (<?php 
    if ($week_block == 0) {
        echo 'A';
    } else {
        echo 'B';
    }
    ?>
)</th>
				
				<?php 
    foreach ($row_days as $dayn) {
        $dow_string = $d_o_w[$dayn];
        ?>
				<th class="col-md-2"><?php 
        echo $dow_string;
        ?>
</th>
				<?php 
    }
    ?>
			</tr>

			<?php 
    foreach ($column_periods as $periodn) {
        echo '<tr>';
        echo "<td>{$periodn}</td>";
        foreach ($row_days as $dayn) {
            echo '<td align="center">';
            if (array_key_exists('subject', $timetable[$periodn][$dayn])) {
                echo $timetable[$periodn][$dayn]['subject'] . '<br/>';
                if (array_key_exists('room', $timetable[$periodn][$dayn])) {
                    echo '<i class="fa fa-location-arrow"></i>&nbsp;<b>' . $timetable[$periodn][$dayn]['room'] . '</b>';
                }
            } else {
                echo '';
            }
            echo '</td>';
        }
        echo '</tr>';
    }
    ?>
		</table>
        
        
        <?php 
}