public static function retrieveOrCreateByDayAndBlockAndCourseSubjectId($day, $block, $course_subject_id) { $course_subject_day = self::retrieveByDayAndBlockAndCourseSubjectId($day, $block, $course_subject_id); if (is_null($course_subject_day)) { $course_subject_day = new CourseSubjectDay(); $course_subject_day->setDay($day); $course_subject_day->setBlock($block); $course_subject_day->setCourseSubjectId($course_subject_id); } return $course_subject_day; }
function WeekCalendar($name, $json_events) { _WeekCalendar_common(); $first_day = SchoolBehaviourFactory::getInstance()->getFirstCourseSubjectWeekday(); $days_to_show = SchoolBehaviourFactory::getInstance()->getLastCourseSubjectWeekday() - SchoolBehaviourFactory::getInstance()->getFirstCourseSubjectWeekday() + 1; $day_names_to_sort = CourseSubjectDay::geti18Names(); $order = array(7, 1, 2, 3, 4, 5, 6, 7); foreach ($order as $index) { $day_names[] = $day_names_to_sort[$index]; } $day_names = json_encode($day_names); $hours = SchoolBehaviourFactory::getInstance()->getHoursArrayForSubjectWeekday(); ksort($hours, SORT_NUMERIC); $start_hour = array_shift($hours); $end_hour = count($hours) > 0 ? array_pop($hours) : $start_hour; if (++$end_hour > 24) { $end_hour--; } return '<div id="' . $name . '"></div>' . javascript_tag("\n jQuery(document).ready(function() {\n jQuery('#{$name}').weekCalendar({\n readonly: true,\n overlapEventsSeparate: true,\n timeSeparator: ' - ',\n timeslotsPerHour: 4,\n buttons: false,\n firstDayOfWeek: {$first_day},\n daysToShow: {$days_to_show},\n height: function(\$calendar){\n return jQuery(window).height() - jQuery(\"h1\").outerHeight();\n },\n longDays: {$day_names} ,\n headerShowDay: false,\n highlightToday: false,\n use24Hour: true,\n businessHours: {start: {$start_hour}, end: {$end_hour}, limitDisplay: true},\n data: { events: {$json_events} },\n\n });\n });\n "); }