private function getProfessorName($subject_id, $course_id, $school_year_id)
 {
     $engagement = EngagementQuery::create()->findPk([$subject_id, $course_id, $school_year_id]);
     if ($engagement) {
         return $engagement->getProfessor()->toString();
     }
     return "Not in schedule";
 }
Ejemplo n.º 2
0
 public function customValidation($validator)
 {
     $validator->after(function ($validator) {
         $arr = Request::all();
         $sid = $arr['SubjectId'];
         $sid_orig = isset($arr['SubjectIdOrig']) ? $arr['SubjectIdOrig'] : false;
         $cid = $arr['CourseId'];
         $cid_orig = isset($arr['CourseIdOrig']) ? $arr['CourseIdOrig'] : false;
         $syid = $arr['SchoolYearId'];
         $syid_orig = isset($arr['SchoolYearIdOrig']) ? $arr['SchoolYearIdOrig'] : false;
         if ($sid !== $sid_orig || $cid !== $cid_orig || $syid !== $syid_orig) {
             $engagement = EngagementQuery::create()->findPk([$sid, $cid, $syid]);
             if (!is_null($engagement)) {
                 //$validator->errors()->add('ProfessorId', 'This combination of professor, subject, course and school year is taken.');
                 $validator->errors()->add('SubjectId', 'This combination of subject, course and school year is taken.');
                 $validator->errors()->add('CourseId', 'This combination of subject, course and school year is taken.');
                 $validator->errors()->add('SchoolYearId', 'This combination of subject, course and school year is taken.');
             }
         }
     });
 }
Ejemplo n.º 3
0
 /**
  * Create Engagement query.
  *
  */
 protected function createQuery($array, $search)
 {
     $this->objects = EngagementQuery::create()->useSchoolYearQuery()->orderByYear('desc')->endUse()->useCourseQuery()->orderByName()->endUse()->useSubjectQuery()->orderByName()->endUse();
     if (\Auth::user()->getStatus() == 'professor') {
         $professor_id = \Auth::user()->getProfessorId();
         $this->objects->where("engagement.professor_id = ?", $professor_id);
     } else {
         if (isset($array['ProfessorId']) && $array['ProfessorId'] !== "") {
             $this->objects->where("engagement.professor_id = ?", $array['ProfessorId']);
         }
     }
     if (isset($array['SubjectId']) && $array['SubjectId'] !== "") {
         $this->objects->where("engagement.subject_id = ?", $array['SubjectId']);
     }
     if (isset($array['CourseId']) && $array['CourseId'] !== "") {
         $this->objects->where("engagement.course_id = ?", $array['CourseId']);
     }
     if (isset($array['SchoolYearId']) && $array['SchoolYearId'] !== "") {
         $this->objects->where("engagement.school_year_id = ?", $array['SchoolYearId']);
     }
     if ($search) {
         session(['engagement_filter' => $array]);
     }
 }
Ejemplo n.º 4
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Course is new, it will return
  * an empty collection; or if this Course has previously
  * been saved, it will retrieve related Engagements from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Course.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      ConnectionInterface $con optional connection object
  * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return ObjectCollection|ChildEngagement[] List of ChildEngagement objects
  */
 public function getEngagementsJoinSchoolYear(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
 {
     $query = ChildEngagementQuery::create(null, $criteria);
     $query->joinWith('SchoolYear', $joinBehavior);
     return $this->getEngagements($query, $con);
 }
Ejemplo n.º 5
0
 /**
  * Returns a new ChildEngagementQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildEngagementQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildEngagementQuery) {
         return $criteria;
     }
     $query = new ChildEngagementQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Ejemplo n.º 6
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildEngagementQuery::create();
     $criteria->add(EngagementTableMap::COL_SUBJECT_ID, $this->subject_id);
     $criteria->add(EngagementTableMap::COL_COURSE_ID, $this->course_id);
     $criteria->add(EngagementTableMap::COL_SCHOOL_YEAR_ID, $this->school_year_id);
     return $criteria;
 }
Ejemplo n.º 7
0
 /**
  * Performs an INSERT on the database, given a Engagement or Criteria object.
  *
  * @param mixed               $criteria Criteria or Engagement object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(EngagementTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Engagement object
     }
     // Set the correct dbName
     $query = EngagementQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($sid, $cid, $syid)
 {
     $engagement = EngagementQuery::create()->findPK([$sid, $cid, $syid]);
     $engagement->delete();
     flash()->success("DELETED");
     session(['attribute' => \Lang::get('general.ENGAGEMENT')]);
     return redirect($this->main_page);
 }