public function addDisciplines($syllabusId, $courseId) { $discipline = new Discipline(); $allDisciplines = $discipline->getAllDisciplines(); $data = array('allDisciplines' => $allDisciplines, 'syllabusId' => $syllabusId, 'courseId' => $courseId); loadTemplateSafelyByGroup("secretario", 'syllabus/add_syllabus_disciplines', $data); }
public function save() { if (UserSession::getInstance()->getAccessLevel() < 5) { die("<h1>Forbidden resource for you.</h1>"); } $model = new Discipline(); $model->setFields($this->params); $model->set('dsc_usr_id', UserSession::getInstance()->getUser()->get("usr_id")); $modelId = $model->get("dsc_id"); if (!isset($modelId)) { $status = $this->saveNew($model); return $status; } else { $status = $this->update($model); return $status; } }
public function get_disciplines_with_counts() { $sql = 'SELECT ' . Discipline::all_fields_str() . ', COUNT(entry.id) AS entry_count FROM discipline LEFT JOIN entry ON (discipline.id = entry.discipline_id) WHERE discipline.tournament_id = :tournament_id GROUP BY discipline.id '; $rows = static::_fetch_all_rows($sql, [':tournament_id' => $this->id]); return $rows; }
public function removeDisciplineFromSyllabus($syllabusId, $disciplineId) { $discipline = new Discipline(); $disciplineExists = $discipline->checkIfDisciplineExists($disciplineId); $syllabusExists = $this->checkIfSyllabusExists($syllabusId); $dataIsOk = $disciplineExists && $syllabusExists; if ($dataIsOk) { $syllabusDiscipline = array('id_syllabus' => $syllabusId, 'id_discipline' => $disciplineId); $this->db->delete('syllabus_discipline', $syllabusDiscipline); $foundSyllabusDiscipline = $this->getSyllabusDiscipline($syllabusId, $disciplineId); if ($foundSyllabusDiscipline !== FALSE) { $wasDeleted = FALSE; } else { $wasDeleted = TRUE; } } else { $wasDeleted = FALSE; } return $wasDeleted; }
public function confirmEnrollmentRequest($userId, $courseId, $semesterId) { $userRequest = $this->getUserTempRequest($userId, $courseId, $semesterId); if ($userRequest !== FALSE) { $this->load->model('temporaryrequest_model'); $request = new Request(); $result = $request->receiveStudentRequest($userRequest); if ($result !== FALSE) { $wasConfirmed = $this->cleanUserTempRequest($userId, $courseId, $semesterId); } else { $wasConfirmed = FALSE; } } else { $wasConfirmed = FALSE; } if ($wasConfirmed) { $status = "success"; $message = "Solicitação de matrícula enviada com sucesso."; // If different of FALSE, $result is the disciplines of request which have problem to be saved if ($result !== FALSE) { if (sizeof($result) > 0) { $status = "danger"; $message = "Algumas solitações não foram atendidas.<br><br> Ocorreu um erro ao processar as matrículas das disciplinas abaixo:<br>"; $discipline = new Discipline(); foreach ($result as $offerDiscipline) { $foundDiscipline = $discipline->getDisciplineByCode($offerDiscipline['id_discipline']); $message = $message . "<br>"; $message = $message . "{$foundDiscipline['discipline_name']}" . " - Turma {$offerDiscipline['class']}"; } $message = $message . "<br><br>Contate o coordenador."; } } } else { $message = "Não foi possível confirmar sua matrícula, tente novamente."; $status = "danger"; } $this->session->set_flashdata($status, $message); redirect("request/studentEnrollment/{$courseId}/{$userId}"); }
<h2 class="principal">Disciplinas</h2> <?php echo anchor("discipline/formToRegisterNewDiscipline", "Cadastrar Disciplina", array("class" => "btn btn-primary", "type" => "submit", "content" => "newDiscipline")); define("ADMINID", 1); $session = $this->session->userdata("current_user"); $userId = $session['user']['id']; $disciplines = new Discipline(); if ($userId == ADMINID) { $registered = $disciplines->getAllDisciplines(); } else { $registered = $disciplines->getDisciplinesBySecretary($userId); } ?> <br> <table class="table table-bordered"> <tr> <h3>Disciplinas Cadastradas</h3> </tr> <tr> <th class="text-center"> Nome da Disciplina </th> <th class="text-center"> Código da Disciplina </th> <th class="text-center"> Carga Horária Semestral </th> <th class="text-center">
protected function find_conflicting($player_id) { $vals = [':dtype' => $this->dtype, ':tournament_id' => $this->tournament_id, ':player_id' => $player_id]; $all_conflicting = Discipline::get_all('WHERE entry.discipline_id = discipline.id AND discipline.dtype = :dtype AND discipline.tournament_id = :tournament_id AND (entry.player_id = :player_id OR entry.partner_id = :player_id) ', $vals, ['entry']); if (\count($all_conflicting) > 0) { return $all_conflicting[0]; } return null; }
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; $u = user\check_current(); $u->require_perm('admin'); utils\require_get_params(['id']); $discipline = Discipline::by_id($_GET['id']); $tournament = $discipline->get_tournament(); $season = $tournament->get_season(); $disciplines = $tournament->get_disciplines(); // Calculate conflicts $discipline_by_id = []; foreach ($disciplines as $d) { $discipline_by_id[$d->id] = $d; } $all_entries = $tournament->get_entries(); $disciplines_by_player_id = []; foreach ($all_entries as $e) { if ($e->discipline_id == $discipline->id) { continue; } if (!\array_key_exists($e->player_id, $disciplines_by_player_id)) { $disciplines_by_player_id[$e->player_id] = []; } \array_push($disciplines_by_player_id[$e->player_id], $discipline_by_id[$e->discipline_id]); if ($e->partner_id) { if (!\array_key_exists($e->partner_id, $disciplines_by_player_id)) { $disciplines_by_player_id[$e->partner_id] = []; }
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; $u = user\check_current(); $u->require_perm('admin'); utils\require_get_params(['discipline_id', 'gender', 'term']); $player_rows = Discipline::suggest_player_rows_with_clubs_by_id($_GET['discipline_id'], $_GET['term'], $_GET['gender']); render_json(['players' => $player_rows]);
public function actionChangediscip($id = null) { $specialty = new Specialty(); $groups = array(); $disciplins = array(); if ($id == null) { $model = new DisciplineToTeacher(); $this->pageTitle = 'Назначить дисциплину преподавателю'; } else { $this->pageTitle = 'Изменить дисциплину'; $model = DisciplineToTeacher::model()->findByPk($id); $specialty->id_specialty = $model->discipline->metBlock->id_speciality; $criteria = new CDbCriteria(); $criteria->condition = 'id_speciality=:id_specialty'; $criteria->params = array(':id_specialty' => $specialty->id_specialty); $groups = Group::getAll($criteria); $criteria = new CDbCriteria(); $criteria->with = array('metBlock'); $criteria->condition = 'metBlock.id_speciality=:id_specialty'; $criteria->params = array(':id_specialty' => $specialty->id_specialty); $disciplins = Discipline::getAll($criteria); } if (isset($_POST['id_specialty'])) { $criteria = new CDbCriteria(); $criteria->condition = 'id_speciality=:id_specialty'; $criteria->params = array(':id_specialty' => $_POST['id_specialty']); $groups = Group::getAll($criteria); $criteria = new CDbCriteria(); $criteria->with = array('metBlock'); $criteria->condition = 'metBlock.id_speciality=:id_specialty'; $criteria->params = array(':id_specialty' => $_POST['id_specialty']); $disciplins = Discipline::getAll($criteria); $this->renderPartial('_forSpecialty', array('model' => $model, 'groups' => $groups, 'disciplins' => $disciplins)); Yii::app()->end(); } if (isset($_POST['DisciplineToTeacher'])) { $model->attributes = $_POST['DisciplineToTeacher']; if ($model->save()) { $this->redirect('listdiscip'); } } $this->render('changeDisipline', array('model' => $model, 'specialty' => $specialty, 'groups' => $groups, 'disciplins' => $disciplins)); }
public function get_discipline() { return Discipline::by_id($this->discipline_id); }
/** * Declares an association between this object and a Discipline object. * * @param Discipline $v * @return CourseDisciplineAssociation The current object (for fluent API support) * @throws PropelException */ public function setDiscipline(Discipline $v = null) { if ($v === null) { $this->setDisciplineId(NULL); } else { $this->setDisciplineId($v->getId()); } $this->aDiscipline = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Discipline object, it will not be re-added. if ($v !== null) { $v->addCourseDisciplineAssociation($this); } return $this; }
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; utils\csrf_protect(); $u = user\check_current(); $u->require_perm('admin'); utils\require_get_params(['tournament_id']); utils\require_post_params(['name', 'dtype']); $tournament = Tournament::by_id($_GET['tournament_id']); if ($_POST['dtype'] == 'all') { $specs = [['name' => 'HE' . $_POST['name'], 'dtype' => 'MS'], ['name' => 'DE' . $_POST['name'], 'dtype' => 'WS'], ['name' => 'HD' . $_POST['name'], 'dtype' => 'MD'], ['name' => 'DD' . $_POST['name'], 'dtype' => 'WD'], ['name' => 'MX' . $_POST['name'], 'dtype' => 'MX']]; } else { $specs = [['name' => $_POST['name'], 'dtype' => $_POST['dtype']]]; } Model::beginTransaction(); foreach ($specs as $spec) { try { $discipline = Discipline::create($tournament, $spec['name'], $spec['dtype']); $discipline->save(); } catch (utils\DuplicateEntryException $e) { render_ajax_error(sprintf('Disziplin "%s" existiert bereits!', $spec['name'])); exit; } } Model::commit(); render_ajax('d/' . $discipline->id . '/', ['tournament' => $tournament, 'disciplines' => $disciplines]);
/** * Save the course_discipline_assocs * @param $discipline * @param $request * @return true if ready for saving, false otherwise */ protected function parseDisAssoc(Discipline $discipline, sfWebRequest $request) { $conn = Propel::getConnection(); // retrieve existing assoc objects $criteria = new Criteria(); $criteria->addAscendingOrderByColumn(CourseDisciplineAssociationPeer::YEAR_OF_STUDY); $criteria->addAscendingOrderByColumn(CourseDisciplineAssociationPeer::COURSE_ID); $extObjs = $discipline->getCourseDisciplineAssociations($criteria, $conn); $delList = $extObjs; for ($year = 1; $year <= 4; $year++) { // first get an array of items $itemArr = array(); $token = strtok($request->getParameter("assoc[" . $year . "]"), $this->separator); while ($token !== false) { if (trim($token) != "") { $itemArr[] = $token; } $token = strtok($this->separator); } // check which ones exist, which ones are new and which ones need deletion foreach ($itemArr as $item) { $cCode = substr($item, 0, 8); $existed = false; foreach ($extObjs as $obj) { if ($obj->getCourseId() == $cCode && $obj->getYearOfStudy() == $year) { $existed = true; $key = array_search($obj, $delList); if ($key !== false) { unset($delList[$key]); } break; } } if (!$existed) { // save the new assoc $assoc = new CourseDisciplineAssociation(); $assoc->setCourseId($cCode); $assoc->setDisciplineId($discipline->getId()); $assoc->setYearOfStudy($year); $assoc->save($conn); } } } // delete old assocs that no longer exist foreach ($delList as $obj) { $obj->delete($conn); } return true; }
function displayDisciplinesToRequest($request, $courseId, $userId, $semesterId) { $offer = new Offer(); $offer->loadModel(); $discipline = new Discipline(); echo "<div class=\"box-body table-responsive no-padding\">"; echo "<table class=\"table table-bordered table-hover\">"; echo "<tbody>"; echo "<tr>"; echo "<th class=\"text-center\">Código</th>"; echo "<th class=\"text-center\">Disciplina</th>"; echo "<th class=\"text-center\">Turma</th>"; echo "<th class=\"text-center\">Horário</th>"; echo "<th class=\"text-center\">Ações</th>"; echo "</tr>"; if ($request != FALSE) { foreach ($request as $request) { $foundClass = $offer->getOfferDisciplineById($request['discipline_class']); if ($foundClass !== FALSE) { $foundDiscipline = $discipline->getDisciplineByCode($foundClass['id_discipline']); echo "<tr>"; echo "<td>"; echo $foundClass['id_offer_discipline']; echo "</td>"; echo "<td>"; echo "Cod.: " . $foundDiscipline['discipline_code'] . " - " . $foundDiscipline['discipline_name'] . " (" . $foundDiscipline['name_abbreviation'] . ")"; echo "</td>"; echo "<td>"; echo $foundClass['class']; echo "</td>"; echo "<td>"; displayDisciplineHours($foundClass['id_offer_discipline']); echo "</td>"; echo "<td>"; echo anchor("temporaryrequest/removeDisciplineFromTempRequest/{$userId}/{$courseId}/{$semesterId}/{$foundDiscipline['discipline_code']}/{$foundClass['class']}", "Remover Disciplina", "class='btn btn-danger btn-flat'"); echo "<td>"; echo "</tr>"; } else { echo "<tr>"; echo "<td>"; echo $foundClass['id_offer_discipline']; echo "</td>"; echo "<td colspan='3'>"; echo "<div class=\"callout callout-info\">"; echo "<h4>Não foi encontrada a turma informada.</h4>"; echo "</div>"; echo "</td>"; echo "</tr>"; } } } else { echo "<tr>"; echo "<td colspan=4>"; echo "<div class=\"callout callout-info\">"; echo "<h4>Nenhuma disciplina adicionada para solicitação de matrícula.</h4>"; echo "</div>"; echo "</td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "</div>"; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Discipline $value A Discipline object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Discipline $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }