protected function renderContent()
    {
        $day = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
        if (Yii::app()->user->getState('stud_id')) {
            $date = date('Y-m-d');
            $ts = strtotime($date);
            $week_number = date('W', $ts);
            $year = date('Y');
            for ($day1 = 1; $day1 < 7; $day1++) {
                $alldate[] = date('d-m-Y', strtotime($year . "W" . $week_number . $day1));
            }
            $criteria = new CDbCriteria();
            //$criteria->select = 'academic_term_id'; // select fields which you want in output
            $criteria->condition = 'current_sem = 1 AND academic_term_organization_id = ' . Yii::app()->user->getState('org_id');
            $semname = AcademicTerm::model()->findAll($criteria);
            $data = CHtml::listData($semname, 'academic_term_id', 'academic_term_id');
            $stud_model = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id'));
            $check_sem = in_array($stud_model->student_academic_term_name_id, $data);
            //var_dump($check_sem); exit;
            $timetableid = 0;
            if (!$check_sem) {
                echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>";
            } else {
                $check_timetable = TimeTableDetail::model()->findByAttributes(array('acdm_name_id' => $stud_model->student_academic_term_name_id, 'division_id' => $stud_model->student_transaction_division_id));
                if (empty($check_timetable)) {
                    echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>";
                } else {
                    $timetableid = $check_timetable->timetable_id;
                    $model = TimeTable::model()->findByPk($timetableid);
                    $nooflec = $model->No_of_Lec;
                    $sum = $nooflec;
                    $lec_duration = LecDuration::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id ', $params = array(':table_id' => $timetableid));
                    $lec = array();
                    foreach ($lec_duration as $l) {
                        $lec[] = $l['duration'];
                    }
                    $createdate = date_create($model->creation_date);
                    $starti = 1;
                    if ($model->zero_lec == 1) {
                        $starti = 0;
                    }
                    $time = $model->clg_start_time;
                    $time = date('H:i A', strtotime($time));
                    $timestamp = strtotime($time);
                    $time = date('g:i A', $timestamp);
                    ?>

			<table id="time-table-struc" bgcolor="#CBE7ED"  border="2" style= width:auto;font-size:8px;border-collapse:collapse; height:auto;"  align="center">
			<th  align=center>
				Day/Time
			</th>

<?php 
                    $i = 0;
                    while ($i < 6) {
                        echo "<th>" . $day[$i] . "</br>(" . $alldate[$i] . ")</th>";
                        $i++;
                    }
                    $break = "";
                    $l = 0;
                    $count = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0);
                    for ($i = $starti; $i <= $nooflec; $i++) {
                        $days = count($day);
                        echo "<tr>";
                        $duration = NoOfBreakTable::model()->findByAttributes(array('timetable_id' => $timetableid, 'after_lec_break' => $i));
                        $dur = $duration['duration'];
                        if ($dur) {
                            $dur1 = date('i', strtotime($dur));
                        }
                        if ($break) {
                            echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + $dur1 * 60) . "</td><td colspan=7 align=center><font color='green'><b>Break</b></font></td></tr>";
                            $break = "";
                            $timestamp = strtotime($time) + $dur1 * 60;
                            $time = date('g:i A', $timestamp);
                            $i--;
                            continue;
                        } else {
                            echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + 60 * $lec[$l]) . "</td>";
                            $timestamp = strtotime($time) + 60 * $lec[$l];
                            $l++;
                            $time = date('g:i A', $timestamp);
                        }
                        for ($j = 1; $j <= $days; ++$j) {
                            $subname = "";
                            $room = "";
                            $faculty = "";
                            $batch = "";
                            if ($count[$j] > 0) {
                                $count[$j]--;
                                continue;
                            }
                            $result = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id AND day = :day AND lec = :lec AND division_id = :div_id AND lecture_date = :lecdate and proxy_status <> :proxy_status', $params = array(':table_id' => $timetableid, ':day' => $j, ':lec' => $i, ':div_id' => $stud_model->student_transaction_division_id, ':lecdate' => date('Y-m-d', strtotime($alldate[$j - 1])), ':proxy_status' => 2));
                            $break = NoOfBreakTable::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id  AND after_lec_break = :lec', $params = array(':table_id' => $timetableid, ':lec' => $i));
                            if ($result) {
                                foreach ($result as $list) {
                                    if ($list['lect_hour'] > 1) {
                                        $count[$j] = $list['lect_hour'] - 1;
                                    }
                                    echo "<td rowspan=" . $list['lect_hour'] . " align=center style=background:#C0CCCC; width:100px;>";
                                    break;
                                }
                                foreach ($result as $check) {
                                    if ($check->batch_id != 0) {
                                        $batch = "(" . Batch::model()->findByPk($check->batch_id)->batch_name . ")";
                                    }
                                    $subname = SubjectMaster::model()->findByPk($check->subject_id)->subject_master_alias;
                                    $room = "(" . RoomDetailsMaster::model()->findByPk($check->room_id)->room_name . ")";
                                    $faculty = "(" . EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $check->faculty_emp_id))->employee_name_alias . ")";
                                    if ($batch) {
                                        echo "</br>" . $subname . "</br>" . $batch . "</br>" . $room . "</br>" . $faculty;
                                    } else {
                                        echo "</br>" . $subname . "</br>" . $room . "</br>" . $faculty;
                                    }
                                }
                                echo "</td>";
                            } else {
                                echo "<td style=width:100px;>" . $subname . "</br>" . $batch . "</br>" . $room . "</br>" . $faculty . "</td>";
                            }
                        }
                        echo "</tr>";
                    }
                    echo "</table>";
                    ?>
<h5>Proxy details</h5>

<table id="time-table-struc" style="font-size:10px;">
<tr>
<th>Sr. No.</th>
<th>Employee Name</th>
<th>Proxy Employee Name</th>
<th>Subject</th>
<th>Lecture No.</th>
<th>Date</th>
</tr>
<?php 
                    $proxy_data = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'timetable_id = :timetable_id and division_id = :div_id and lecture_date >= :start and lecture_date< :end and proxy_status = :proxy order by lec', $params = array(':timetable_id' => $timetableid, ':div_id' => $stud_model->student_transaction_division_id, ':start' => date('Y-m-d', strtotime($alldate[0])), ':end' => date('Y-m-d', strtotime($alldate[5])), ':proxy' => 1));
                    $n = 0;
                    foreach ($proxy_data as $list) {
                        $result = TimeTableDetail::model()->findByPk($list->proxy_id);
                        ?>

<tr>
<td><?php 
                        echo ++$n;
                        ?>
</td>
<td><?php 
                        echo EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $list->faculty_emp_id))->employee_first_name;
                        ?>
</td>
<td><?php 
                        echo EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $result->faculty_emp_id))->employee_first_name;
                        ?>
</td>
<td><?php 
                        echo SubjectMaster::model()->findByPk($result->subject_id)->subject_master_alias;
                        ?>
</td>
<td><?php 
                        echo $result->lec;
                        ?>
</td>
<td><?php 
                        echo date('d-m-Y', strtotime($result->lecture_date));
                        ?>
</td>
</tr>
<?php 
                    }
                    ?>
</table>
<?php 
                }
                //ELSE END
            }
        } else {
            if (Yii::app()->user->getState('emp_id')) {
                $timetableid = 0;
                $date = date('Y-m-d');
                $ts = strtotime($date);
                $week_number = date('W', $ts);
                $alldate[0] = 'No';
                $year = date('Y');
                for ($day2 = 1; $day2 < 7; $day2++) {
                    $alldate[$day2] = date('d-m-Y', strtotime($year . "W" . $week_number . $day2));
                }
                $semname = AcademicTerm::model()->findAllByAttributes(array(), $condition = 'current_sem = :current_sem and academic_term_organization_id=:org_id', $params = array(':current_sem' => 1, ':org_id' => Yii::app()->user->getState('org_id')));
                foreach ($semname as $s) {
                    $semid = $s['academic_term_id'];
                    $check = TimeTableDetail::model()->findByAttributes(array('acdm_name_id' => $semid, 'faculty_emp_id' => Yii::app()->user->getState('emp_id')));
                    if ($check) {
                        $timetableid = $check['timetable_id'];
                        break;
                    }
                }
                if (!empty($timetableid)) {
                    $day = array(" ", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
                    $model = TimeTable::model()->findByPk($timetableid);
                    $nooflec = $model->No_of_Lec;
                    $sum = $nooflec;
                    $lec_duration = LecDuration::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id ', $params = array(':table_id' => $timetableid));
                    $lec = array();
                    foreach ($lec_duration as $l) {
                        $lec[] = $l['duration'];
                    }
                    $starti = 1;
                    if ($model->zero_lec == 1) {
                        $starti = 0;
                    }
                    $time = $model->clg_start_time;
                    $time = date('H:i A', strtotime($time));
                    $createdate = date_create($model->creation_date);
                    ?>

			<table id="time-table-struc" bgcolor="#CBE7ED" border="2" style="width:auto;font-size:9px;border-collapse:collapse; height:auto;" >
			<th>
				Day/Time
			</th>

			<?php 
                    $i = 0;
                    while ($i < 7) {
                        echo "<th style='font-size:8px'>" . $day[$i] . "</br>(" . $alldate[$i] . ")</th>";
                        $i++;
                    }
                    $l = 0;
                    $break = "";
                    $dur1 = 0;
                    $count = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0);
                    for ($i = $starti; $i <= $nooflec; $i++) {
                        $days = count($day);
                        echo "<tr>";
                        $duration = NoOfBreakTable::model()->findByAttributes(array('timetable_id' => $timetableid, 'after_lec_break' => $i));
                        if ($duration) {
                            $dur = $duration['duration'];
                            $dur1 = date('i', strtotime($dur));
                        }
                        if ($break) {
                            echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + $dur1 * 60) . "</td><td colspan=7 align=center ><font color='green'><b>Break</b></font></td></tr>";
                            $break = "";
                            $timestamp = strtotime($time) + $dur1 * 60;
                            $time = date('g:i A', $timestamp);
                            $i--;
                            continue;
                        } else {
                            echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + 60 * $lec[$l]) . "</td><td style=width:25px;><b>" . $i . "</b></td>";
                            $timestamp = strtotime($time) + 60 * $lec[$l];
                            $l++;
                            $time = date('g:i A', $timestamp);
                        }
                        for ($j = 1; $j <= $days - 1; ++$j) {
                            $subname = "";
                            $room = "";
                            $faculty = "";
                            $batch = "";
                            if ($count[$j] > 0) {
                                $count[$j]--;
                                continue;
                            }
                            $result = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'day = :day AND lec = :lec AND faculty_emp_id = :emp_id AND timetable_id=:table_id AND lecture_date =:lecdate and proxy_status <> :status', $params = array(':table_id' => $timetableid, ':day' => $j, ':lec' => $i, ':emp_id' => Yii::app()->user->getState('emp_id'), ':lecdate' => date('Y-m-d', strtotime($alldate[$j])), ':status' => 2));
                            $break = NoOfBreakTable::model()->findAllByAttributes(array(), $condition = 'after_lec_break = :lec AND timetable_id=:table_id', $params = array(':table_id' => $timetableid, ':lec' => $i));
                            if ($result) {
                                foreach ($result as $list) {
                                    if ($list['lect_hour'] > 1) {
                                        $count[$j] = $list['lect_hour'] - 1;
                                    }
                                    echo "<td rowspan=" . $list['lect_hour'] . " align=center style=background:#C0CCCC; border-color:black; width:150px;>";
                                    break;
                                }
                                foreach ($result as $check) {
                                    if ($check->batch_id != 0) {
                                        $batch = "(" . Batch::model()->findByPk($check->batch_id)->batch_name . ")";
                                    }
                                    $subname = SubjectMaster::model()->findByPk($check->subject_id)->subject_master_alias;
                                    $room = "(" . RoomDetailsMaster::model()->findByPk($check->room_id)->room_name . ")";
                                    $div = Division::model()->findByPk($check->division_id)->division_code;
                                    //$faculty="(".EmployeeInfo::model()->findByPk($check->faculty_emp_id)->employee_name_alias.")";
                                    if ($batch) {
                                        echo $subname . "</br>" . $batch . "</br>" . $room;
                                    } else {
                                        echo $subname . "</br>" . "(" . $div . ")" . "</br>" . $room;
                                    }
                                }
                                echo "</td>";
                            } else {
                                echo "<td style=width:150px;>" . $subname . "</br>" . $batch . "</br>" . $room . "</td>";
                            }
                        }
                        //for j end
                        echo "</tr>";
                    }
                    //for i end
                    echo "</table>";
                    ?>
<h5>Proxy Lectures</h5>

<table id="time-table-struc" border="1" style="font-size:10px;">
<tr>
<th>Sr. No.</th>
<th>Employee Name</th>
<th>Division</th>
<th>Subject</th>
<th>Room</th>
<th>Lecture No.</th>
<th>Date</th>
</tr>
<?php 
                    $proxy_data = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'timetable_id = :timetable_id and proxy_employee_id = :emp_id and lecture_date >= :start and lecture_date< :end and proxy_status = :proxy order by lec', $params = array(':timetable_id' => $timetableid, ':emp_id' => Yii::app()->user->getState('emp_id'), ':start' => date('Y-m-d', strtotime($alldate[0])), ':end' => date('Y-m-d', strtotime($alldate[5])), ':proxy' => 1));
                    $n = 0;
                    foreach ($proxy_data as $list) {
                        $result = TimeTableDetail::model()->findByPk($list->proxy_id);
                        ?>

<tr>
<td><?php 
                        echo ++$n;
                        ?>
</td>
<td><?php 
                        echo EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $list->faculty_emp_id))->employee_first_name;
                        ?>
</td>
<td><?php 
                        echo Division::model()->findByPk($result->division_id)->division_code;
                        ?>
</td>
<td><?php 
                        echo SubjectMaster::model()->findByPk($result->subject_id)->subject_master_alias;
                        ?>
</td>
<td><?php 
                        echo RoomDetailsMaster::model()->findByPk($result->room_id)->room_name;
                        ?>
</td>
<td><?php 
                        echo $result->lec;
                        ?>
</td>
<td><?php 
                        echo date('d-m-Y', strtotime($result->lecture_date));
                        ?>
</td>
</tr>
<?php 
                    }
                    ?>
</table>		

<?php 
                } else {
                    echo "<h3 align=center style=color:red>Sorry, No timetable available.</h3>";
                }
            }
        }
    }
コード例 #2
0
ファイル: view2b.php プロジェクト: aswamy/CURegistrationApp
function pickCourse($course, $leftToTake, $coursesPicked, $lab, $solutions)
{
    global $courses_array;
    $coursesArr = $courses_array;
    //end conditions
    if ($course == "" && empty($leftToTake) && !empty($coursesPicked)) {
        $timeTable = new TimeTable($coursesPicked);
        $timeTable->generateTimeTable();
        //make sure there isn't a conflict in the timetable, then add solution to list
        if ($timeTable->hasConflict() === FALSE) {
            if (is_null($solutions)) {
                $solutions = array();
            }
            array_push($solutions, $timeTable->courseList);
        }
        return $solutions;
    } else {
        //build array of options for the current course/lab
        $newArr = array();
        foreach ($coursesArr as $precise) {
            $courseName = $precise['course_name'];
            $courseSection = $precise['course_section'];
            if ($course == $courseName) {
                preg_match('/\\d/', $courseSection, $match);
                $checkIsLab = $match;
                if (!$checkIsLab && $lab == "") {
                    array_push($newArr, $precise);
                } else {
                    if ($checkIsLab && $lab !== "") {
                        array_push($newArr, $precise);
                    }
                }
            }
        }
        //if the class section has a lab section with the same Letter, than that lab letter needs to be selected
        //figure out if lab section with the same letter as course section exists
        $hasLetterSection = FALSE;
        if ($lab != "") {
            $courseSect = $lab;
            foreach ($newArr as $checkLabSect) {
                if (substr($checkLabSect['course_section'], 0, 1) == $lab) {
                    $hasLetterSection = TRUE;
                    break;
                }
            }
        }
        $courseReached = FALSE;
        if ($course != "" && sizeof($newArr) == 0) {
            $picked = $coursesPicked;
            $left = $leftToTake;
            $key = array_search($course, $left);
            array_splice($left, $key, 1);
            $empty = empty($left);
            if ($empty && !empty($picked)) {
                //last course, so finish
                $solutions = pickCourse("", array(), $picked, "", $solutions);
                if (sizeof($solutions) > 1) {
                    return $solutions;
                    //break;
                }
            } else {
                if (!$empty) {
                    //not last course, keep looking for solutions
                    $solutions = pickCourse($left[0], $left, $picked, "", $solutions);
                    if (sizeof($solutions) > 1) {
                        return $solutions;
                        //break;
                    }
                }
            }
        }
        //iterate over list, selecting a course, then doing it again for the next
        foreach ($newArr as $courses) {
            $courseName = $courses['course_name'];
            $section = $courses['course_section'];
            //shouldn't need anymore
            preg_match('/\\d/', $section, $match);
            $isLab = $match;
            if ($lab && !$isLab) {
                continue;
            }
            //shouldn't need this if statment anymore
            if ($courseName == $course) {
                $courseReached = TRUE;
                $picked = $coursesPicked;
                $left = $leftToTake;
                array_push($picked, $courseName . "-" . $section);
                if (!$lab) {
                    //next course chosen should be the lab for the current course selected
                    $solutions = pickCourse($course, $leftToTake, $picked, substr($section, 0, 1), $solutions);
                    if (sizeof($solutions) > 1) {
                        return $solutions;
                        //break;
                    }
                    continue;
                } else {
                    if ($isLab) {
                        if (!($hasLetterSection && $lab == substr($section, 0, 1) || !$hasLetterSection)) {
                            //ex: SYSC 4504 A is selected, SYSC 4504 B1 should not be a lab selected (wrong section)
                            //therefore continue if this is the case
                            continue;
                        }
                    }
                    //remove the current course from the list of courses to take (don't want to select it again)
                    $key = array_search($course, $left);
                    array_splice($left, $key, 1);
                    if (empty($left)) {
                        //this was the last course, therefore see if the solution works
                        $solutions = pickCourse("", array(), $picked, "", $solutions);
                        if (sizeof($solutions) > 1) {
                            return $solutions;
                            //break;
                        }
                        continue;
                    } else {
                        //try next course
                        $solutions = pickCourse($left[0], $left, $picked, "", $solutions);
                        if (sizeof($solutions) > 1) {
                            return $solutions;
                            //break;
                        }
                        continue;
                    }
                }
                //might not need anymore
            } else {
                if ($courseReached || $course == "") {
                    break;
                }
            }
        }
        // nothing left to do... end
        return $solutions;
    }
}
コード例 #3
0
ファイル: course.php プロジェクト: abhinay100/forma_app
function updateUserOccupation($course_id, $edition_id, $start_date, $end_date)
{
    require_once $GLOBALS["where_framework"] . "/lib/resources/lib.timetable.php";
    $tt = new TimeTable();
    $consumer = "user";
    $course_id = (int) $course_id;
    if ($edition_id > 0) {
        $resource = "course_edition";
        $resource_id = (int) $edition_id;
    } else {
        $resource = "course";
        $resource_id = $course_id;
    }
    $tt->updateEventDateByResource($resource, $resource_id, $start_date, $end_date);
}
コード例 #4
0
ファイル: std2DayTT.php プロジェクト: rinodung/EduSec3.0.0
	     'acdm_name_id' => $stud_model->student_academic_term_name_id,
	     'division_id' => $stud_model->student_transaction_division_id,
	     'lecture_date'=>$current_date,
   ),'proxy_status <> :status', array(':status'=>1));

if($check_timetable) {?>
<div class="wob wob-in-top-threshold wob-0-degrees read-only" style="height: 444px; width: 525px; z-index: 1;">
<div class="timeline textstream widget news-stream google-news vertical">
<div class="widget-header">
  <i class="header-icon"></i>
  <div class="title">Time Table</div>
</div>
<div class="timeline-items-wrapper">
<?php
			
			$timetable = TimeTable::model()->findByPk($check_timetable[0]->timetable_id);

		  	$time1 = date('H:i A',strtotime($timetable['clg_start_time']));
		   
		   	if($timetable->zero_lec==1)
		   		$time[] = $time1;
		   	else
		   		$time[1] = $time1;
		   
			$lec_dur =  LecDuration::model()->findAll(array('condition'=>'timetable_id='.$timetable['timetable_id']));

			   foreach($lec_dur as $list)
			   {
				$break = NoOfBreakTable::model()->findByAttributes(array('after_lec_break'=>$list['lecture'],'timetable_id'=>$timetable['timetable_id']));
				if($break)
				{
コード例 #5
0
$data_arr = implode(',',$data);
}
$timetable_criteria = new CDbCriteria;
$timetable_criteria->condition = 'acdm_name_id in ('.$data_arr.') AND faculty_emp_id = '.Yii::app()->user->getState('emp_id').' AND lecture_date = "'.date('Y-m-d').'" order by lec';
$time_table_details = TimeTableDetail::model()->findAll($timetable_criteria);

if($time_table_details) {
?>
<div class="box">

<div class="box-header">
<h1>Your Timetable</h1>
</div>
<div class="box-content">
	<?php
		$timetable = TimeTable::model()->findByPk($time_table_details[0]->timetable_id);

		$time1 = date('H:i A',strtotime($timetable['clg_start_time']));

	   	if($timetable->zero_lec==1)
	   		$time[] = $time1;
	   	else
	   		$time[1] = $time1;
	   	$lec_dur =  LecDuration::model()->findAll(array('condition'=>'timetable_id='.$timetable['timetable_id']));

	   	   foreach($lec_dur as $list)
		   {
			$break = NoOfBreakTable::model()->findByAttributes(array('after_lec_break'=>$list['lecture'],'timetable_id'=>$timetable['timetable_id']));
			if($break)
			{
				$dur1=date('i',strtotime($break['duration']));
コード例 #6
0
ファイル: show.php プロジェクト: olehpitsun/duplom.comv2.2.1
    ?>
</td>
            <td> <?php 
    $obj = new TimeTable($teachers[$i]['id'], 6, 6);
    print $obj->content();
    print $obj->getComm($teachers[$i]['id'], 6, 6);
    ?>
 <a href="?c=Roz&f=create_subject&p=<?php 
    print $teachers[$i]['id'];
    ?>
&count=6&day=6" rel="#overlay" /><img src="public/img/w128h1281338911594add.png" class="image" /></a><?php 
    print $obj->getSubWeekStatus();
    ?>
</td>
            <td> <?php 
    $obj = new TimeTable($teachers[$i]['id'], 6, 7);
    print $obj->content();
    print $obj->getComm($teachers[$i]['id'], 6, 7);
    ?>
 <a href="?c=Roz&f=create_subject&p=<?php 
    print $teachers[$i]['id'];
    ?>
&count=7&day=6" rel="#overlay" /><img src="public/img/w128h1281338911594add.png" class="image" /></a><?php 
    print $obj->getSubWeekStatus();
    ?>
</td>
            <td>  </td>
        </tr>

        <?php 
}
コード例 #7
0
function getATimeTable($courseArray, $maxNumOfCourse = '')
{
    if ($maxNumOfCourse == '' && sizeof($courseArray) <= 5) {
        $maxNumOfCourse = 5;
    }
    $timeTable = new TimeTable($maxNumOfCourse);
    for ($i = 0; $i < sizeof($courseArray); $i++) {
        $timeTable->addCourse($courseArray[$i]);
        if ($timeTable->isFull()) {
            break;
        }
    }
    return $timeTable;
}
コード例 #8
0
 function getEvents($year = 0, $month = 0, $day = 0, $start_date = "", $end_date = "", $classroom = "")
 {
     $where = "";
     if (!$month and !$year and empty($start_date) and empty($end_date)) {
         $today = getdate();
         $month = $today['mon'];
         $year = $today['year'];
     }
     if ($classroom) {
         if ($where) {
             $where .= " AND ";
         }
         $where .= "classroom_id='" . $classroom . "'";
     }
     /*
     		if ($day and empty($start_date) and empty($end_date)) {
     			if ($where) $where.=" AND ";
     			$where.="_day='".$day."'";
     
     		}
     
     		if ($month and empty($start_date) and empty($end_date)) {
     			if ($where) $where.=" AND ";
     			$where.="_month='".$month."'";
     
     		}
     
     		if ($year and empty($start_date) and empty($end_date)) {
     			if ($where) $where.=" AND ";
     			$where.="_year='".$year."'";
     
     		} */
     if (!empty($start_date) and !empty($end_date)) {
         if (!empty($where)) {
             $where .= " AND ";
         }
         $where .= "start_date>='" . $start_date . "' AND start_date<='" . $end_date . "'";
     }
     $tt = new TimeTable();
     $consumer_filter = array("course", "course_edition");
     $entries = $tt->getResourceEntries("classroom", FALSE, $start_date, $end_date, $consumer_filter);
     //return mysql_num_rows($result);
     $calevents = array();
     $i = 0;
     $parts = array();
     $loaded = array();
     foreach ($entries as $row) {
         $loaded[$row["consumer"]][$i] = $row["resource_id"];
         /* you should call the constructor of the proper type of event class*/
         $calevents[$i] = new DoceboCalEvent_lms();
         $calevents[$i]->calEventClass = $this->calClass;
         /* the following should be set according to the type of event class*/
         $calevents[$i]->id = $row["id"];
         ereg("^(.+)-(.+)-(.+) (.+):(.+):(.+)\$", $row["start_date"], $parts);
         $calevents[$i]->start_year = $parts[1];
         $calevents[$i]->start_month = $parts[2];
         $calevents[$i]->start_day = $parts[3];
         $calevents[$i]->start_hour = $parts[4];
         $calevents[$i]->start_min = $parts[5];
         $calevents[$i]->start_sec = $parts[6];
         ereg("^(.+)-(.+)-(.+) (.+):(.+):(.+)\$", $row["end_date"], $parts);
         $calevents[$i]->end_year = $parts[1];
         $calevents[$i]->end_month = $parts[2];
         $calevents[$i]->end_day = $parts[3];
         $calevents[$i]->end_hour = $parts[4];
         $calevents[$i]->end_min = $parts[5];
         $calevents[$i]->end_sec = $parts[6];
         /*			$calevents[$i]->_year=$row["_year"];
         			$calevents[$i]->_month=$row["_month"];
         			$calevents[$i]->_day=$row["_day"]; */
         $calevents[$i]->owner = $row["owner"];
         $calevents[$i]->editable = 0;
         /*----------------------------------------------------------*/
         $i++;
     }
     // --- Loading additional information ---------------------------------
     // ------------------------- - -  -   -
     // We first grab edition information so we also find the course id of the
     // editions to later load the related course information too.
     // ------------------------- - -  -   -
     $qtxt = "SELECT * FROM " . $GLOBALS["prefix_lms"] . "_course_edition ";
     $qtxt .= "WHERE idCourseEdition IN (" . implode(",", $loaded["course_edition"]) . ") ";
     $q = sql_query($qtxt);
     $edition_info = array();
     $calevents_keys = array_flip($loaded["course_edition"]);
     if ($q && mysql_num_rows($q) > 0) {
         while ($row = mysql_fetch_assoc($q)) {
             $id = $row["idCourseEdition"];
             $course_id = $row["idCourse"];
             $edition_info[$id] = $row;
             if (!in_array($course_id, $loaded["course"])) {
                 $key = $calevents_keys[$id];
                 $loaded["course"][$key] = $course_id;
             }
         }
     }
     // ------------------------- - -  -   -
     // Then we grab the course information too
     // ------------------------- - -  -   -
     $qtxt = "SELECT * FROM " . $GLOBALS["prefix_lms"] . "_course ";
     $qtxt .= "WHERE idCourse IN (" . implode(",", $loaded["course"]) . ") ";
     $q = sql_query($qtxt);
     $course_info = array();
     if ($q && mysql_num_rows($q) > 0) {
         while ($row = mysql_fetch_assoc($q)) {
             $id = $row["idCourse"];
             $course_info[$id] = $row;
         }
     }
     // ------------------------- - -  -   -
     // And once we have them we setup the calendar information using the
     // key value of the $info array that guess what.. is the same of the
     // calevents array! :D
     // ------------------------- - -  -   -
     foreach ($loaded as $consumer => $info) {
         foreach ($info as $calevents_key => $id) {
             switch ($consumer) {
                 case "course":
                     $title = $course_info[$id]["name"];
                     $description = "";
                     break;
                 case "course_edition":
                     $course_id = $edition_info[$id]["idCourse"];
                     $title = $course_info[$course_id]["name"];
                     $description = $edition_info[$id]["name"];
                     break;
             }
             $calevents[$calevents_key]->title = $title;
             $calevents[$calevents_key]->description = $description;
         }
     }
     // --------------------------------------------------------------------
     $qtxt = "SELECT * FROM " . $GLOBALS['prefix_lms'] . "_classroom_calendar";
     $qtxt .= !empty($where) ? " WHERE " . $where : "";
     $q = sql_query($qtxt);
     if ($q && mysql_num_rows($q) > 0) {
         while ($row = mysql_fetch_assoc($q)) {
             /* you should call the constructor of the proper type of event class*/
             $calevents[$i] = new DoceboCalEvent_lms();
             $calevents[$i]->calEventClass = $this->calClass;
             /* the following should be set according to the type of event class*/
             $calevents[$i]->id = $row["id"];
             ereg("^(.+)-(.+)-(.+) (.+):(.+):(.+)\$", $row["start_date"], $parts);
             $calevents[$i]->start_year = $parts[1];
             $calevents[$i]->start_month = $parts[2];
             $calevents[$i]->start_day = $parts[3];
             $calevents[$i]->start_hour = $parts[4];
             $calevents[$i]->start_min = $parts[5];
             $calevents[$i]->start_sec = $parts[6];
             ereg("^(.+)-(.+)-(.+) (.+):(.+):(.+)\$", $row["end_date"], $parts);
             $calevents[$i]->end_year = $parts[1];
             $calevents[$i]->end_month = $parts[2];
             $calevents[$i]->end_day = $parts[3];
             $calevents[$i]->end_hour = $parts[4];
             $calevents[$i]->end_min = $parts[5];
             $calevents[$i]->end_sec = $parts[6];
             $calevents[$i]->classroom = $row["classroom_id"];
             $calevents[$i]->title = $row["title"];
             $calevents[$i]->description = $row["description"];
             $calevents[$i]->owner = $row["owner"];
             $calevents[$i]->editable = 1;
             /*----------------------------------------------------------*/
             $i++;
         }
     }
     return $calevents;
 }
コード例 #9
0
ファイル: subscribe.php プロジェクト: abhinay100/forma_app
function addUserToTimeTable($user_id, $course_id, $edition_id = 0)
{
    // -- timetable setup ------------------------------------------------
    require_once $GLOBALS["where_framework"] . "/lib/resources/lib.timetable.php";
    $tt = new TimeTable();
    $resource = "user";
    $resource_id = $user_id;
    if ($edition_id > 0) {
        $consumer = "course_edition";
        $consumer_id = $edition_id;
        $table = $GLOBALS["prefix_lms"] . "_course_edition";
        $id_name = "idCourseEdition";
    } else {
        $consumer = "course";
        $consumer_id = $course_id;
        $table = $GLOBALS["prefix_lms"] . "_course";
        $id_name = "idCourse";
    }
    // -------------------------------------------------------------------
    $qtxt = "SELECT date_begin, date_end FROM " . $table . " ";
    $qtxt .= "WHERE " . $id_name . "='" . (int) $consumer_id . "'";
    $q = sql_query($qtxt);
    if ($q && mysql_num_rows($q) > 0) {
        $row = mysql_fetch_assoc($q);
        $start_date = $row["date_begin"];
        $end_date = $row["date_end"];
    } else {
        return FALSE;
    }
    $res = $tt->saveEvent(FALSE, $start_date, $end_date, $start_date, $end_date, $resource, $resource_id, $consumer, $consumer_id);
    return $res;
}
コード例 #10
0
 protected function renderContent()
 {
     $current_date = date('Y-m-d');
     if (Yii::app()->user->getState('stud_id')) {
         $criteria = new CDbCriteria();
         //$criteria->select = 'academic_term_id'; // select fields which you want in output
         $criteria->condition = 'current_sem = 1 AND academic_term_organization_id = ' . Yii::app()->user->getState('org_id');
         $semname = AcademicTerm::model()->findAll($criteria);
         $data = CHtml::listData($semname, 'academic_term_id', 'academic_term_id');
         $stud_model = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id'));
         $check_sem = in_array($stud_model->student_academic_term_name_id, $data);
         $timetableid = 0;
         if (!$check_sem) {
             echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>";
         } else {
             $check_timetable = TimeTableDetail::model()->findAllByAttributes(array('acdm_name_id' => $stud_model->student_academic_term_name_id, 'division_id' => $stud_model->student_transaction_division_id, 'lecture_date' => $current_date), 'proxy_status <> :status', array(':status' => 1));
             if (empty($check_timetable)) {
                 echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>";
             } else {
                 $timetable = TimeTable::model()->findByPk($check_timetable[0]->timetable_id);
                 $time1 = date('H:i A', strtotime($timetable['clg_start_time']));
                 if ($timetable->zero_lec == 1) {
                     $time[] = $time1;
                 } else {
                     $time[1] = $time1;
                 }
                 $lec_dur = LecDuration::model()->findAll(array('condition' => 'timetable_id=' . $timetable['timetable_id']));
                 foreach ($lec_dur as $list) {
                     $break = NoOfBreakTable::model()->findByAttributes(array('after_lec_break' => $list['lecture'], 'timetable_id' => $timetable['timetable_id']));
                     if ($break) {
                         $dur1 = date('i', strtotime($break['duration']));
                         $timestamp = strtotime($time1) + 60 * $dur1;
                         $time1 = date('g:i A', $timestamp);
                         $timestamp = strtotime($time1) + 60 * $list['duration'];
                         $time1 = date('g:i A', $timestamp);
                         $time[] = $time1;
                     } else {
                         $timestamp = strtotime($time1) + 60 * $list['duration'];
                         $time1 = date('g:i A', $timestamp);
                         $time[] = $time1;
                     }
                 }
                 print '<table id="time-table-struc" style="font-size:10px;">';
                 print '<tr>';
                 print '<th>Lecture No.</th>';
                 print '<th>Subject</th>';
                 print '<th>Faculty Name</th>';
                 print '<th>Room No.</th>';
                 print '<th>Time</th>';
                 foreach ($check_timetable as $list) {
                     if ($list->subject_type != 1 && $list->batch_id != $stud_model->student_transaction_batch_id) {
                         continue;
                     }
                     print '<tr>';
                     print '<td>' . $list->lec . '</td>';
                     print '<td>' . SubjectMaster::model()->findByPk($list->subject_id)->subject_master_alias . '</td>';
                     print '<td>' . EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $list->faculty_emp_id))->employee_first_name . '</td>';
                     print '<td>' . RoomDetailsMaster::model()->findByPk($list->room_id)->room_name . '</td>';
                     print '<td>' . $time[$list->lec] . '</td></tr>';
                 }
                 print '</table>';
             }
         }
     } else {
         if (Yii::app()->user->getState('emp_id')) {
             $criteria = new CDbCriteria();
             //$criteria->select = 'academic_term_id';
             $criteria->condition = 'current_sem = 1 AND academic_term_organization_id = ' . Yii::app()->user->getState('org_id');
             $semname = AcademicTerm::model()->findAll($criteria);
             $data = CHtml::listData($semname, 'academic_term_id', 'academic_term_id');
             $data_arr = implode(',', $data);
             $timetable_criteria = new CDbCriteria();
             $timetable_criteria->condition = 'acdm_name_id in (' . $data_arr . ') AND faculty_emp_id = ' . Yii::app()->user->getState('emp_id') . ' AND lecture_date = "' . date('Y-m-d') . '"';
             $time_table_details = TimeTableDetail::model()->findAll($timetable_criteria);
             if ($time_table_details) {
                 $timetable = TimeTable::model()->findByPk($time_table_details[0]->timetable_id);
                 $time1 = date('H:i A', strtotime($timetable['clg_start_time']));
                 if ($timetable->zero_lec == 1) {
                     $time[] = $time1;
                 } else {
                     $time[1] = $time1;
                 }
                 $lec_dur = LecDuration::model()->findAll(array('condition' => 'timetable_id=' . $timetable['timetable_id']));
                 foreach ($lec_dur as $list) {
                     $break = NoOfBreakTable::model()->findByAttributes(array('after_lec_break' => $list['lecture'], 'timetable_id' => $timetable['timetable_id']));
                     if ($break) {
                         $dur1 = date('i', strtotime($break['duration']));
                         $timestamp = strtotime($time1) + 60 * $dur1;
                         $time1 = date('g:i A', $timestamp);
                         $timestamp = strtotime($time1) + 60 * $list['duration'];
                         $time1 = date('g:i A', $timestamp);
                         $time[] = $time1;
                     } else {
                         $timestamp = strtotime($time1) + 60 * $list['duration'];
                         $time1 = date('g:i A', $timestamp);
                         $time[] = $time1;
                     }
                 }
                 print '<table id="time-table-struc" style="font-size:10px;">';
                 print '<tr>';
                 print '<th>Lecture No.</th>';
                 print '<th>Branch</th>';
                 print '<th>Sem</th>';
                 print '<th>Division</th>';
                 print '<th>Subject</th>';
                 print '<th>Room No.</th>';
                 print '<th>Time</th>';
                 foreach ($time_table_details as $list) {
                     print '<tr>';
                     print '<td>' . $list->lec . '</td>';
                     print '<td>' . Branch::model()->findByPk($list->branch_id)->branch_name . '</td>';
                     print '<td>' . AcademicTerm::model()->findByPk($list->acdm_name_id)->academic_term_name . '</td>';
                     print '<td>' . Division::model()->findByPk($list->division_id)->division_code . '</td>';
                     print '<td>' . SubjectMaster::model()->findByPk($list->subject_id)->subject_master_alias . '</td>';
                     print '<td>' . RoomDetailsMaster::model()->findByPk($list->room_id)->room_name . '</td>';
                     print '<td>' . $time[$list->lec] . '</td></tr>';
                 }
                 print '</table>';
             } else {
                 echo "<h3 align=center style=color:red>Sorry, No timetable available.</h3>";
             }
         }
     }
 }
コード例 #11
0
<?php

require_once 'classes/TimeTable.php';
session_start();
$selected = array();
foreach ($_GET as $key => $val) {
    array_push($selected, $key);
}
$t1 = new TimeTable($selected);
$t1->generateTimeTable();
echo $t1->displayHtml();
echo "</br>";
$selectedString = "(";
foreach ($selected as $a) {
    $selectedString = $selectedString . $a . ",";
}
$selectedString = rtrim($selectedString, ",") . ")";
echo "<input type='hidden' name='courses' value='{$selectedString}'/>";
コード例 #12
0
	
			echo "<h3 align=center style=color:red>Sorry, No timetable available.</h3>";
		}
		else{
			 $check_timetable=TimeTableDetail::model()->findByAttributes(
			array(
			     'acdm_name_id' => $stud_model->student_academic_term_name_id,
			     'division_id' => $stud_model->student_transaction_division_id,
		   ));
		if(empty($check_timetable)) {
			echo "<h3 align=center style=color:red>Sorry, No timetable available.</h3>";
		}
		else {
			$division_id = $stud_model->student_transaction_division_id;
			$timetableid = $check_timetable->timetable_id;
			$model=TimeTable::model()->findByPk($timetableid);
			$nooflec = $model->No_of_Lec;
			$sum = $nooflec;


		$lec_duration=LecDuration::model()->findAllByAttributes(array(),
							$condition  = 'timetable_id = :table_id ', 
							$params     = array(
								':table_id' => $timetableid,
								));
		$lec=array();
		foreach($lec_duration as $l)
			$lec[]=$l['duration'];

		$createdate = date_create($model->creation_date);
コード例 #13
0
 function del()
 {
     if ($this->getPerm()) {
         $start_date = $this->start_year . "-" . $this->start_month . "-" . $this->start_day . " " . $this->start_hour . ":" . $this->start_min . ":" . $this->start_sec;
         $end_date = $this->end_year . "-" . $this->end_month . "-" . $this->end_day . " " . $this->end_hour . ":" . $this->end_min . ":" . $this->end_sec;
         // -- timetable setup ------------------------------------------------
         require_once $GLOBALS["where_framework"] . "/lib/resources/lib.timetable.php";
         $tt = new TimeTable();
         $resource = "classroom";
         $resource_id = (int) $this->classroom;
         $consumer = "classroom_event";
         $consumer_id = $this->id;
         // -------------------------------------------------------------------
         $delete_ok = $tt->deleteEvent(FALSE, $resource, $resource_id, $consumer, $consumer_id, $start_date, $end_date);
         if ($delete_ok) {
             $query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_classroom_calendar WHERE id='" . $this->id . "'";
             $q = sql_query($query);
             $this->id = 0;
         }
     }
 }