/** * 計算課表 */ public static function caculate($param) { // 設定執行時間 set_time_limit(60); // 產生教室使用時間,提供排課使用 $classroom = Classroom::all(); foreach ($classroom as $classroomItem) { $GLOBALS['classroomCourseTime'][$classroomItem->classroom_id] = str_replace('1', $classroomItem->count, $classroomItem->course_time); } // 取得教師排課需求,計算適應值用 $teacher = Teacher::where('course_time', '<>', str_repeat(0, 35))->get(); foreach ($teacher as $teacherItem) { $GLOBALS['teacherRequire'][$teacherItem->teacher_id]['require'] = $teacherItem->course_time; $GLOBALS['teacherRequire'][$teacherItem->teacher_id]['classes_id'] = $teacherItem->classes_id; if ($teacherItem->classes_id != 0) { $GLOBALS['teacherRequire'][$teacherItem->teacher_id]['courseTime'] = $teacherItem->classes->year->course_time; } } // 產生課表,速度、計算適應值 $seed = self::_generateSeed($param['seedCount']); // 發生錯誤,回傳錯誤結果 if ($seed[0] == 'error') { return $seed; } // 進行粒子最佳化計算 $seedProgressHistory = array(); $extinctionTimes = 1; while ($param['extinctionCount'] > 0) { $withoutProgressCount = 0; $bestSeed = self::_getBestSeed($seed); $seedProgressHistory[] = number_format($bestSeed['fitness'], 2, '.', ''); while ($withoutProgressCount < $param['executeCount']) { // 更新種子速度 self::_updateSeedV($seed, $bestSeed); // 依照速度更新課表排課、計算適應值 $seed = self::_updateSeed($seed); // 取得新的全域最佳值 $newBestSeed = self::_getBestSeed($seed); // 判斷是否改進 if ($bestSeed['fitness'] < $newBestSeed['fitness']) { $bestSeed = $newBestSeed; $withoutProgressCount = 0; $seedProgressHistory[] = number_format($bestSeed['fitness'], 2, '.', '') . '<sup class="progross"> 改進</sup>'; } else { $withoutProgressCount++; $seedProgressHistory[] = number_format($bestSeed['fitness'], 2, '.', ''); } } // 進行判斷是否改進毀滅結果 if (!isset($historyBestSeed) || $historyBestSeed['fitness'] < $bestSeed['fitness']) { $historyBestSeed = $bestSeed; } $seedProgressHistory[] = '<strong>' . number_format($historyBestSeed['fitness'], 2, '.', '') . '<sup> 全域最佳</sup></strong>'; $seedProgressHistory[] = 'Extinction ' . $extinctionTimes; $param['extinctionCount']--; $extinctionTimes++; } file_put_contents(storage_path() . '\\result.json', json_encode($historyBestSeed['timetable'])); return $seedProgressHistory; }
public static function printULTree_noAnchors() { $categories = Classroom::model()->findAll(array('order' => 'lft')); $level = 0; foreach ($categories as $n => $category) { if ($category->level == $level) { echo CHtml::closeTag('li') . "\n"; } else { if ($category->level > $level) { echo CHtml::openTag('ul') . "\n"; } else { echo CHtml::closeTag('li') . "\n"; for ($i = $level - $category->level; $i; $i--) { echo CHtml::closeTag('ul') . "\n"; echo CHtml::closeTag('li') . "\n"; } } } echo CHtml::openTag('li'); echo CHtml::encode($category->name); $level = $category->level; } for ($i = $level; $i; $i--) { echo CHtml::closeTag('li') . "\n"; echo CHtml::closeTag('ul') . "\n"; } }
private function getEventsForRoom($roomNumber) { $roomInfo = CeasRooms::where('name', '=', $roomNumber)->first(); if ($roomInfo !== null) { switch ($roomInfo->type) { case 1: $events = Classroom::where('RoomId', '=', $roomInfo->id)->get(); break; case 2: $events = ComputerClassroom::where('RoomId', '=', $roomInfo->id)->get(); break; case 3: $events = BreakoutRoom::where('RoomId', '=', $roomInfo->id)->get(); break; case 4: $events = SpecialRoom::where('RoomId', '=', $roomInfo->id)->get(); break; default: $events = array(); break; } return $events; } else { return array(); } }
public function deleteDestroy() { $modelArray = array(); $deleteModels = Input::json('models'); foreach ($deleteModels as $model) { $deleteClassroom = Classroom::find($model['id']); $deleteClassroom->delete(); array_push($modelArray, $deleteClassroom); $returnModels = BaseCollection::make($modelArray); } echo $returnModels->toJson(); }
/** * @before _secure, _teacher */ public function manage($course_id = null) { $this->setSEO(array("title" => "Manage Your assignments | Teacher")); $view = $this->getActionView(); $where = array("user_id = ?" => $this->user->id); $fields = array("title", "created", "course_id", "classroom_id", "deadline", "live", "id"); $course_id = RequestMethods::post("course", $course_id); if ($course_id) { $assignments = \Assignment::all(array_merge($where, array("course_id = ?" => $course_id)), $fields); } else { $assignments = \Assignment::all($where, $fields); } $results = array(); $grades = Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title")); $storedGrades = array(); foreach ($grades as $g) { $storedGrades[$g->id] = $g->title; } $courses = TeacherService::$_courses; $classrooms = array(); $message = Registry::get("session")->get('$redirectMessage'); if ($message) { $view->set("message", $message); Registry::get("session")->erase('$redirectMessage'); } $notification = Registry::get("MongoDB")->notifications; foreach ($assignments as $a) { $course = $courses[$a->course_id]; $grade = $storedGrades[$course->grade_id]; if (!isset($classrooms[$a->classroom_id])) { $classroom = $classrooms[$a->classroom_id] = \Classroom::first(array("id = ?" => $a->classroom_id), array("section")); } else { $classroom = $classrooms[$a->classroom_id]; } $record = $notification->findOne(array('sender' => 'user', 'sender_id' => (int) $this->user->id, 'type' => 'assignment', 'type_id' => (int) $a->id)); if (isset($record)) { $notify = false; } else { $notify = true; } $data = array("id" => $a->id, "course" => $course->title, "title" => $a->title, "class" => $grade, "notified" => !$notify, "live" => $a->live, "section" => $classroom->section, "deadline" => $a->deadline, "created" => $a->created, "course_id" => $a->course_id, "classroom_id" => $a->classroom_id); $data = ArrayMethods::toObject($data); $results[] = $data; } $view->set("assignments", $results)->set("courses", $courses)->set("course_id", $course_id); }
public function deleteEvents() { $input = Input::all(); $semester = Semester::find($input['semester']); switch ($input['roomType']) { case 'Classroom': $events = Classroom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get(); break; case 'Breakout': $events = BreakoutRoom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get(); break; case 'Computer': $events = ComputerClassroom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get(); break; case 'Special': $events = SpecialRoom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get(); break; } foreach ($events as $event) { $event->delete(); } }
class="client-val-form button"> </div> <!--The tree will be rendered in this div--> <div id="<?php echo Classroom::ADMIN_TREE_CONTAINER_ID; ?> " class="admintree" > </div> <div id='category_info'> <div id='pic'></div> <div id='title'> <h3><?php echo Classroom::model()->findByPK($category_id)->name; ?> </h3> </div> </div> <div id="listview-wrapper" class="left"> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $prod_dataProvider, 'itemView' => 'application.views.student._frontend_view', 'id' => 'student-listview', 'afterAjaxUpdate' => 'js:function(id,data){$.bind_crud()}', 'pagerCssClass' => 'pager_wrapper clearfix')); ?> </div> </div> <!-- Content-->
if ($validator->fails()) { return Redirect::to('/classroom')->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查'); } else { $data = Input::all(); $classroom = Classroom::find($id); if ($classroom->update($data)) { $message = '更新教室《' . $data['classroom_name'] . '》完成'; } else { $message = '資料寫入錯誤'; } return Redirect::to('/classroom')->with('message', $message); } }); // 執行刪除教室 Route::get('/delete/{id}', function ($id) { $classroom = Classroom::find($id); $message = '刪除《' . $classroom->classroom_name . '》完成'; $classroom->delete(); return Redirect::to('/classroom')->with('message', $message); }); }); /** * 排課設定 */ Route::group(array('prefix' => 'timetable', 'before' => 'auth'), function () { // 顯示全部教師列表 Route::get('/', function () { return Redirect::to('timetable/view_title/all'); }); // 依職稱顯示教師列表 Route::get('view_title/{titleId}', function ($titleId) {
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Classroom the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Classroom::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * @before _secure, _teacher */ public function manageAttendance() { $this->setSEO(array("title" => "Manage Your Courses | Teacher")); $view = $this->getActionView(); $classroom = Classroom::first(array("educator_id = ?" => $this->educator->id), array("id", "section", "grade_id")); $grade = Grade::first(array("id = ?" => $classroom->grade_id), array("title")); $service = new Shared\Services\Classroom(); $response = $service->saveAttendance($classroom); if (isset($response["success"])) { $view->set("message", "Attendance Saved successfully!!"); } elseif (isset($response["saved"])) { $view->set("message", "Attendance Already saved for today"); } $students = $service->enrollments($classroom, array('table' => 'attendance')); $view->set("class", $grade->title . " - " . $classroom->section); $view->set("students", $students); }
/** * @before _secure, _school */ public function addToClass($user_id) { $usr = \User::first(array("id = ?" => $user_id), array("id")); if (!$usr) { self::redirect("/school"); } $this->setSEO(array("title" => "Parent Info | Student | School")); $view = $this->getActionView(); $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title")); $enrollment = Enrollment::first(array("user_id = ?" => $user_id)); if ($enrollment) { $view->set("success", "Student has already been added! Response will be updated"); } if (RequestMethods::post("action") == "addToClass") { $classroom = Markup::checkValue(RequestMethods::post("classroom")); if (!$enrollment) { $enrollment = new Enrollment(array()); } $enrollment->user_id = $usr->id; $enrollment->classroom_id = $classroom; $enrollment->organization_id = $this->organization->id; if ($enrollment->validate()) { $enrollment->save(); $view->set("success", "Student successfully added to classroom"); } } if ($enrollment) { $class = Classroom::first(array("id = ?" => $enrollment->classroom_id), array("id", "grade_id", "section")); foreach ($grades as $g) { if ($g->id == $class->grade_id) { $grade = $g->id; break; } } $view->set("class", $class); } if (!isset($grade)) { $grade = null; } $view->set("grade", $grade); $view->set("enrollment", $enrollment); $view->set("grades", $grades); }
/** * 驗證排課單元 */ public static function courseUnit($data) { // 衝突檢查 Validator::extend('conflict', function ($attribute, $data, $parameters) { /* Array參考 [0][_token] => Yvw1pYLjZIm1BaiPJ1yTYKbs3Nl8T9zfkLesI0Bh [1][classes_id] => 4 [2][course_id] => 9 [3][count] => 1 [4][classroom_id] => 0 [5][combination] => 1 [6][repeat] => 0 [7][limit_course_time] => 1 [8][course_time] => 10000001000000110000011000001100000 [9][teacher_id] => 19 */ // 處理變數 list(, $classes_id, $course_id, $count, $classroom_id, $combination, $repeat) = $parameters; $mode = end($parameters); $teacher_id = prev($parameters); if (substr($mode, 0, 4) == 'edit') { $courseUnitId = intval(substr($mode, 4)); $mode = substr($mode, 0, 4); } if ($parameters[7] == 1) { $course_time = $parameters[8]; } else { $course_time = 0; } // 限制排課時間少於設定節數 if (substr_count($course_time, '1') < $count && substr_count($course_time, '1') != 0) { Session::flash('conflictError', '限制排課時間(共' . substr_count($course_time, '1') . '節)少於設定節數(' . $count . ')'); return false; } // 組合節數大於設定節數 if ($combination > $count) { Session::flash('conflictError', '組合節數(' . $combination . ')大於設定節數(' . $count . ')'); return false; } // 同天不排課,但是(排課節數 / 組合節數)超過5 if ($repeat == 0 && $count / $combination > 5) { Session::flash('conflictError', '同天同班不重複排課,但是(排課節數 / 組合節數)超過5'); return false; } // 教室可排課時間不足 if ($classroom_id != 0) { $courseCount = 0; $courseUnitUseClassroom = array(); foreach (Courseunit::where('classroom_id', '=', $classroom_id)->get() as $courseunit) { $courseCount += $courseunit->count; $courseUnitUseClassroom[] = $courseunit->teacher->teacher_name; } $classroom = Classroom::find($classroom_id); // 檢查是否為編輯模式 if ($mode == 'edit') { $courseUnit = Courseunit::find($courseUnitId); if ($courseUnit->classroom_id == $classroom_id) { $courseCount -= $courseUnit->count; } } if (substr_count($classroom->course_time, '1') * $classroom->count - $courseCount - $count < 0) { $teacherList = implode($courseUnitUseClassroom, ','); Session::flash('conflictError', '教室《' . $classroom->classroom_name . '》可排課時間不足,目前有使用的老師:' . $teacherList); return false; } } // 班級可排節數已滿 $classesCourseCount = 0; foreach (Courseunit::where('classes_id', '=', $classes_id)->get() as $courseunit) { $classesCourseCount += $courseunit->count; } // 編輯模式 if ($mode == 'edit') { $courseUnit = Courseunit::find($courseUnitId); if ($courseUnit->classes_id == $classes_id) { $classesCourseCount -= $courseUnit->count; } } $classes = Classes::find($classes_id); if (substr_count($classes->year->course_time, '1') - $classesCourseCount - $count < 0) { Session::flash('conflictError', '班級《' . $classes->classes_name . '》可排課時間不足'); return false; } return true; }); $rules = array('teacher_id' => 'required|integer', 'course_id' => 'required|integer', 'classroom_id' => 'required|integer', 'count' => 'required|integer', 'combination' => 'required|integer|conflict:' . implode(',', $data), 'repeat' => 'required|integer', 'course_time' => 'numeric'); $messages = array('required' => '此欄位必填', 'integer' => '必需為數字', 'conflict' => '排課衝突'); return Validator::make($data, $rules, $messages); }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); // create connection to import database $this->logSection('connection', 'creating connection to import source'); $source = Propel::getConnection($options['source'] ? $options['source'] : null); // create static counties and offices $this->logSection('static', 'creating static counties and offices'); $connection->beginTransaction(); try { OfficePeer::doDeleteAll($connection); $o1 = new Office(); $o1->setName('Plattsburgh'); $o1->save($connection); $o1 = new Office(); $o1->setName('Rouses Point'); $o1->save($connection); CountyPeer::doDeleteAll($connection); $c1 = new County(); $c1->setName('Clinton'); $c1->save($connection); $c1 = new County(); $c1->setName('Essex'); $c1->save($connection); $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // read in and create objects for district, frequency, icd9, job, services tables // DISTRICT $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_district'); $statement = $source->prepare($query); $statement->execute(); $districts = $statement->fetchAll(); $connection->beginTransaction(); try { DistrictPeer::doDeleteAll($connection); foreach ($districts as $district) { $this->logSection('district', 'creating district ' . $district['district_name']); $d1 = new District(); $d1->setName($district['district_name']); $d1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // FREQUENCY $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_frequency'); $statement = $source->prepare($query); $statement->execute(); $frequencies = $statement->fetchAll(); $connection->beginTransaction(); try { FrequencyPeer::doDeleteAll($connection); foreach ($frequencies as $freq) { $this->logSection('freq', 'reading frequency ' . $freq['freq_title']); $f1 = new Frequency(); $f1->setName($freq['freq_title']); $f1->setDescription($freq['freq_description']); $f1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // ICD9 $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_icd9'); $statement = $source->prepare($query); $statement->execute(); $icd9s = $statement->fetchAll(); $connection->beginTransaction(); try { Icd9Peer::doDeleteAll($connection); foreach ($icd9s as $icd9) { $this->logSection('icd9', 'reading icd9 ' . $icd9['icd9_value']); $i1 = new Icd9(); $i1->setName($icd9['icd9_value']); $i1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // JOB $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_job'); $statement = $source->prepare($query); $statement->execute(); $jobs = $statement->fetchAll(); $connection->beginTransaction(); try { JobPeer::doDeleteAll($connection); foreach ($jobs as $job) { $this->logSection('job', 'reading job ' . $job['job_title']); $j1 = new Job(); $j1->setName($job['job_title']); $j1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // SERVICES $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_services'); $statement = $source->prepare($query); $statement->execute(); $services = $statement->fetchAll(); $connection->beginTransaction(); try { ServicePeer::doDeleteAll($connection); foreach ($services as $service) { $this->logSection('service', 'reading service ' . $service['service_title']); $s1 = new Service(); $s1->setName($service['service_title']); $s1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // EMPLOYEES $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.emp_job_title = %s.job_id)'; $query = sprintf($query, 'tbl_employee', 'tbl_job', 'tbl_employee', 'tbl_job'); $statement = $source->prepare($query); $statement->execute(); $employees = $statement->fetchAll(); $connection->beginTransaction(); try { EmployeePeer::doDeleteAll($connection); foreach ($employees as $employee) { $this->logSection('employee', 'reading employee ' . $employee['emp_id']); $emp = new Employee(); $emp_fields = array('clearance' => $employee['emp_scr_clearance'], 'first_name' => $employee['emp_fn'], 'middle' => $employee['emp_mi'], 'last_name' => $employee['emp_ln'], 'address' => $employee['emp_address'], 'address_2' => $employee['emp_address2'], 'city' => $employee['emp_city'], 'state' => $employee['emp_state'], 'zip' => $employee['emp_zip'], 'home_phone' => $employee['emp_phone'], 'cell_phone' => $employee['emp_cell'], 'company_email' => $employee['emp_email'], 'personal_email' => $employee['emp_p_email'], 'license_number' => $employee['emp_license_number'], 'license_expiration' => $employee['emp_license_exp'], 'dob' => $employee['emp_dob'], 'doh' => $employee['emp_hire_date'], 'dof' => $employee['emp_end_date'], 'ssn' => $employee['emp_ssn'], 'health_insurance' => $employee['emp_health'], 'retirement_plan' => $employee['emp_401k'], 'suplimental_health' => $employee['emp_health_sup'], 'health_type' => $employee['emp_health_type'], 'tb_date' => $employee['emp_tb'], 'osha_date' => $employee['emp_osha'], 'cpr_date' => $employee['emp_cpr'], 'finger_prints' => $employee['emp_fp'], 'finger_print_notes' => $employee['emp_fp_n'], 'notes' => $employee['emp_notes']); $emp->fromArray($emp_fields, BasePeer::TYPE_FIELDNAME); // find the job - check for errors $emp->setJob(JobPeer::getByName($employee['job_title'])); // if physical has a date then create a new physical object for employee if ($employee['emp_physical']) { $this->logSection('physical', 'employee ' . $employee['emp_fn'] . ' had a physical on ' . $employee['emp_physical']); $ph1 = new Physical(); $ph1->setEmployee($emp); $ph1->setDateGiven($employee['emp_physical']); $ph1->save($connection); } $emp->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // read in and create client objects - linking to employee // CLIENTS $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.client_district = %s.district_id)'; $query = sprintf($query, 'tbl_client', 'tbl_district', 'tbl_client', 'tbl_district'); $statement = $source->prepare($query); $statement->execute(); $clients = $statement->fetchAll(); $connection->beginTransaction(); try { ClientPeer::doDeleteAll($connection); foreach ($clients as $client) { $this->logSection('client', 'reading client ' . $client['client_ln']); $cl = new Client(); $client_fields = array('first_name' => $client['client_fn'], 'last_name' => $client['client_ln'], 'dob' => $client['client_dob'], 'parent_first' => $client['client_parent_fn'], 'parent_last' => $client['client_parent_ln'], 'address' => $client['client_address'], 'address_2' => $client['client_address2'], 'city' => $client['client_city'], 'state' => $client['client_state'], 'zip' => $client['client_zip'], 'home_phone' => $client['home_phone'], 'work_phone' => $client['work_phone'], 'cell_phone' => $client['cell_phone'], 'blue_card' => $client['blue_card'], 'physical_exp' => $client['physical_exp_date'], 'immunizations' => $client['immunizations'], 'waiting_list' => $client['waiting_list']); // county $cl->setCounty(CountyPeer::getByName($client['client_county'])); // district $cl->setDistrict(DistrictPeer::getByName($client['district_name'])); $cl->fromArray($client_fields, BasePeer::TYPE_FIELDNAME); $cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // CLIENT SERVICES // CLASSROOM $query = 'SELECT * FROM tbl_classroom LEFT JOIN (tbl_client) ON (tbl_classroom.class_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_classroom.class_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_classroom.class_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_classroom.class_freq_id = tbl_frequency.freq_id)'; $statement = $source->prepare($query); $statement->execute(); $classrooms = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_CLASSROOM); try { ClientServicePeer::doDelete($c, $connection); foreach ($classrooms as $classroom) { $this->logSection('classroom', 'reading service ' . $classroom['class_id']); $cr_cl = new Classroom(); $cr_cl->setStartDate($classroom['class_start_date']); $cr_cl->setEndDate($classroom['class_exp_date']); $cr_cl->setChangeDate($classroom['class_chng_date']); $cr_cl->setNotes($classroom['class_notes']); // client $cr_cl->setClient(ClientPeer::getByFullName($classroom['client_fn'], $classroom['client_ln'])); // employee $cr_cl->setEmployee(EmployeePeer::getByFullName($classroom['emp_fn'], $classroom['emp_ln'])); // service $cr_cl->setService(ServicePeer::getByName($classroom['service_title'])); // frequency $cr_cl->setFrequency(FrequencyPeer::getByName($classroom['freq_title'])); // office $cr_cl->setOffice(OfficePeer::getByName($classroom['class_location'])); $cr_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // EI $query = 'SELECT * FROM tbl_ei LEFT JOIN (tbl_client) ON (tbl_ei.ei_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_ei.ei_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_ei.ei_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_ei.ei_freq_id = tbl_frequency.freq_id) LEFT JOIN (tbl_icd9) ON (tbl_ei.ei_icd9_id = tbl_icd9.icd9_id)'; $statement = $source->prepare($query); $statement->execute(); $eis = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_EI); try { ClientServicePeer::doDelete($c, $connection); foreach ($eis as $ei) { $this->logSection('ei', 'reading service ' . $ei['ei_id']); $ei_cl = new Ei(); $ei_cl->setStartDate($ei['ei_start_date']); $ei_cl->setEndDate($ei['ei_exp_date']); $ei_cl->setChangeDate($ei['ei_chng_date']); $ei_cl->setNotes($ei['ei_serv_notes']); $ei_cl->setAuthorization($ei['ei_auth']); $ei_cl->setPhysiciansOrder($ei['ei_p_order']); // client $ei_cl->setClient(ClientPeer::getByFullName($ei['client_fn'], $ei['client_ln'])); // employee $ei_cl->setEmployee(EmployeePeer::getByFullName($ei['emp_fn'], $ei['emp_ln'])); // service $ei_cl->setService(ServicePeer::getByName($ei['service_title'])); // frequency $ei_cl->setFrequency(FrequencyPeer::getByName($ei['freq_title'])); // office $ei_cl->setIcd9(Icd9Peer::getByName($ei['icd9_value'])); $ei_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // PRESCHOOL $query = 'SELECT * FROM tbl_preschool LEFT JOIN (tbl_client) ON (tbl_preschool.pre_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_preschool.pre_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_preschool.pre_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_preschool.pre_freq_id = tbl_frequency.freq_id)'; $statement = $source->prepare($query); $statement->execute(); $preschools = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_PRESCHOOL); try { ClientServicePeer::doDelete($c, $connection); foreach ($preschools as $preschool) { $this->logSection('preschool', 'reading service ' . $preschool['pre_id']); $pr_cl = new Preschool(); $pr_cl->setStartDate($preschool['pre_start_date']); $pr_cl->setEndDate($preschool['pre_exp_date']); $pr_cl->setChangeDate($preschool['pre_chng_date']); // client $pr_cl->setClient(ClientPeer::getByFullName($preschool['client_fn'], $preschool['client_ln'])); // employee $pr_cl->setEmployee(EmployeePeer::getByFullName($preschool['emp_fn'], $preschool['emp_ln'])); // service $pr_cl->setService(ServicePeer::getByName($preschool['service_title'])); // frequency $pr_cl->setFrequency(FrequencyPeer::getByName($preschool['freq_title'])); $pr_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // SEIT $query = 'SELECT * FROM tbl_seit LEFT JOIN (tbl_client) ON (tbl_seit.seit_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_seit.seit_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_seit.seit_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_seit.seit_freq_id = tbl_frequency.freq_id)'; $statement = $source->prepare($query); $statement->execute(); $seits = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_SEIT); try { ClientServicePeer::doDelete($c, $connection); foreach ($seits as $seit) { $this->logSection('seit', 'reading service ' . $seit['seit_id']); $seit_cl = new Seit(); $seit_cl->setStartDate($seit['seit_start_date']); $seit_cl->setEndDate($seit['seit_exp_date']); $seit_cl->setChangeDate($seit['seit_chng_date']); $seit_cl->setNotes($seit['seit_notes']); // client $seit_cl->setClient(ClientPeer::getByFullName($seit['client_fn'], $seit['client_ln'])); // employee $seit_cl->setEmployee(EmployeePeer::getByFullName($seit['emp_fn'], $seit['emp_ln'])); // service $seit_cl->setService(ServicePeer::getByName($seit['service_title'])); // frequency $seit_cl->setFrequency(FrequencyPeer::getByName($seit['freq_title'])); $seit_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } }
private function checkDuplicates($modelToBeAdded, $table) { switch ($table) { case "Classrooms": $existingModel = Classroom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get(); break; case "Breakout Rooms": $existingModel = BreakoutRoom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get(); break; case "Computer Classrooms": $existingModel = ComputerClassroom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get(); break; case "Special Rooms": $existingModel = SpecialRoom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get(); break; } if ($existingModel != '[]') { return $existingModel; } else { return false; } }
public function executeNewClassroom(sfWebRequest $request) { $this->title = 'Classroom'; $client = ClientPeer::retrieveByPK($request->getParameter('client_id')); if (!($last_cs = $client->getLastService())) { $last_cs = new Classroom(); } $client_service = new Classroom(); $client_service->setEmployee($last_cs->getEmployee()); $client_service->setStartDate($last_cs->getStartDate()); $client_service->setEndDate($last_cs->getEndDate()); $client_service->setClientId($request->getParameter('client_id')); $this->form = new ClassroomForm($client_service); $this->setTemplate('new'); }
<?php Yii::app()->clientScript->registerCss('class1', "\n .align_center{text-align:center;}\n .link{text-decoration:none;}\n"); ?> <h1 class = 'align_center'>角色基本信息</h1> <?php $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('position_name', 'position_info', 'start_time', array('type' => 'raw', 'name' => 'winner_id', 'value' => $model->winner_id ? '<a class ="link" href=' . $this->createUrl('index/classmate/student_id/' . $model->winner_id) . '>' . Student::model()->findByPk($model->winner_id)->student_name . '</a>' : '暂时为空'), array('name' => 'class_id', 'value' => Classroom::model()->findByPk($model->class_id)->class_name)))); ?> <?php if ($model->winner_id == 0) { ?> <a data-role='button' data-inline = 'true' data-mini='true' href="<?php echo Yii::app()->createUrl('index/compete/position_id/' . $model->position_id); ?> " data-ajax="false" > <!-- <img src="/jq/mobile/images/demo/index/web.png" /> --> <h3>竞选</h3> </a> <a data-role='button' data-inline = 'true' data-mini='true' href="<?php echo Yii::app()->createUrl('index/vote/position_id/' . $model->position_id); ?> " data-ajax="false" > <!-- <img src="/jq/mobile/images/demo/index/web.png" /> --> <h3>投票</h3> </a> <?php }
public function actionMoveCopy() { $moved_node_id = $_POST['moved_node']; $new_parent_id = $_POST['new_parent']; $new_parent_root_id = $_POST['new_parent_root']; $previous_node_id = $_POST['previous_node']; $next_node_id = $_POST['next_node']; $copy = $_POST['copy']; //the following is additional info about the operation provided by // the jstree.It's there if you need it.See documentation for jstree. // $old_parent_id=$_POST['old_parent']; //$pos=$_POST['pos']; // $copied_node_id=$_POST['copied_node']; // $replaced_node_id=$_POST['replaced_node']; //the moved,copied node $moved_node = $this->loadModel($moved_node_id); //if we are not moving as a new root... if ($new_parent_root_id != 'root') { //the new parent node $new_parent = $this->loadModel($new_parent_id); //the previous sibling node (after the move). if ($previous_node_id != 'false') { $previous_node = $this->loadModel($previous_node_id); } //if we move if ($copy == 'false') { if ($moved_node->moveAsFirst($new_parent)) { echo json_encode(array('success' => true)); exit; } //if the moved node is only child of new parent node if ($previous_node_id == 'false' && $next_node_id == 'false') { if ($moved_node->moveAsFirst($new_parent)) { echo json_encode(array('success' => true)); exit; } } else { if ($previous_node_id == 'false' && $next_node_id != 'false') { if ($moved_node->moveAsFirst($new_parent)) { echo json_encode(array('success' => true)); exit; } } else { if ($previous_node_id != 'false' && $next_node_id == 'false') { if ($moved_node->moveAsLast($new_parent)) { echo json_encode(array('success' => true)); exit; } } else { if ($previous_node_id != 'false' && $next_node_id != 'false') { if ($moved_node->moveAfter($previous_node)) { echo json_encode(array('success' => true)); exit; } } } } } } else { //create the copied Classroom model $copied_node = new Classroom(); //copy the attributes (only safe attributes will be copied). $copied_node->attributes = $moved_node->attributes; //remove the primary key $copied_node->id = null; if ($copied_node->appendTo($new_parent)) { echo json_encode(array('success' => true, 'id' => $copied_node->primaryKey)); exit; } } } else { //if moved/copied node is not Root if (!$moved_node->isRoot()) { if ($moved_node->moveAsRoot()) { echo json_encode(array('success' => true)); } else { echo json_encode(array('success' => false)); } } else { echo json_encode(array('success' => false, 'message' => 'Node is already a Root.Roots are ordered by id.')); } } }
/** * @before _secure, _school */ public function edit($classroom_id, $grade_id) { $classroom = \Classroom::first(array("id = ?" => $classroom_id)); $grade = \Grade::first(array("id = ?" => $grade_id), array("id", "title", "organization_id")); if (!$classroom || $classroom->organization_id != $this->organization->id) { self::redirect("/school"); } if (!$grade || $classroom->grade_id != $grade->id || $grade->organization_id != $this->organization->id) { self::redirect("/school"); } $this->setSEO(array("title" => "Edit Section | School")); $view = $this->getActionView(); if (RequestMethods::post("action") == "editClassroom") { $classroom->year = RequestMethods::post("year"); $classroom->section = RequestMethods::post("section"); $classroom->remarks = RequestMethods::post("remarks"); $classroom->educator_id = RequestMethods::post("educator"); $classroom->save(); $view->set("success", "Grade section edited successfully!!"); } $teachers = \Educator::all(array("organization_id = ?" => $this->organization->id), array("user_id", "organization_id", "id")); $view->set("teachers", $teachers); $view->set("grade", $grade); $view->set("classroom", $classroom); }