Beispiel #1
0
	
	<div class="modal" id="newTTLessonDlg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="taskEditDlgTitle">Are you sure?</h4>
				</div>
				<form method="POST" action="del_lesson.php">
				<?php 
$periods_st = TimetablePeriod::get($where = array('number' => $_POST['period'], 'weekday' => $_POST['weekday']));
$pds_nd = TimetablePeriod::get($where = array('number' => $_POST['period'], 'weekday' => '0'));
$periods = array_merge($periods_st, $pds_nd);
$allocs = TimetablePeriodAllocation::get($where = array('attendinguser_id' => Authentication::get_user()));
$actual_lesson = 0;
foreach (TimetableLesson::get($where = array('weekday' => $_POST['weekday'], 'week_block' => $_POST['week_block'])) as $lesson) {
    foreach ($periods as $period) {
        if ($period->getId() == $lesson->getPeriodId()) {
            foreach ($allocs as $alloc) {
                if ($alloc->getLessonId() == $lesson->getId()) {
                    echo '<input type="hidden" name="alloc_id" value="' . $alloc->getId() . '" />';
                    $actual_lesson = $lesson;
                    break;
                }
            }
        }
        if ($actual_lesson != 0) {
            break;
        }
    }
    if ($actual_lesson != 0) {
Beispiel #2
0
}
?>
</h3>
        
        <?php 
if ($viewing_by_day) {
    ?>

        <?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;
Beispiel #3
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 
}