<?php require_once('includes/requirecompere.inc.php'); $cs_id=0+TGET('cs_id'); $mb_id=current_mb_id(); $DBConn->connect(true); $course=db_load_course_by_id($DBConn,$cs_id); $classrooms=db_list_classroom_summaries_by_compere($DBConn,$mb_id); $assigned_ids=db_load_course_classroom_id($DBConn,$cs_id); if ($course['mb_id_owner']!=$mb_id) { redirect("./"); return; } $dataset+=$course; $dataset['ASSIGNED']=array(); $dataset['UNASSIGNED']=array(); $classroomseats=array(); $classroomdone=array(); $assigned_seat_count=0; foreach ($classrooms as $classroom) { if ($classroomdone[$classroom['clsr_id']]) continue; $classroomdone[$classroom['clsr_id']]=1; if (in_array($classroom['clsr_id'],$assigned_ids)) { array_push($dataset['ASSIGNED'],$classroom); $assigned_seat_count+=$classroom['clsr_size']; } else array_push($dataset['UNASSIGNED'],$classroom); if (!isset($classroomseats[$classroom['clsr_id']])) $classroomseats[$classroom['clsr_id']]=0; $classroomseats[$classroom['clsr_id']]+=$classroom['clsr_size']; } $dataset['CLASSROOM-SIZE']=array(); foreach ($classroomseats as $clsr_id=>$size) array_push($dataset['CLASSROOM-SIZE'],array('clsr_id'=>$clsr_id,'seat_count'=>$size)); $dataset['NO-CLASSROOM']=$classrooms?array():array(0); $dataset['HAS-ASSIGNED']=$dataset['ASSIGNED']?array(0):array(); $dataset['HAS-UNASSIGNED']=$dataset['UNASSIGNED']?array(0):array(); $dataset['HAS-ASSIGNED-SEATS']=$assigned_seat_count?array(0):array(); $dataset['NO-ASSIGNED-SEATS']=$assigned_seat_count?array():array(0); $dataset+=prepare_wizard_dataset(); ?>