public function getLatestActivities($type = Activity::ACTIVITY_TYPE_COMMIT) { if (!in_array($type, array(Activity::ACTIVITY_TYPE_COMMIT, Activity::ACTIVITY_TYPE_RECOMMEND))) { throw new \InvalidArgumentException(); } $criteria = Criteria::create()->where(Criteria::expr()->eq('type', $type))->orderBy(array("createdAt" => "DESC"))->setFirstResult(0)->setMaxResults(30); return $this->activities->matching($criteria); }
public function saveEmployment($studentobject) { if (!$studentobject->getPkEmploymentid()) { $student = new \Application\Entity\Employment(); } else { $criteria = Criteria::create()->where(Criteria::expr()->eq("pkEmploymentid", $studentobject->getPkEmploymentid())); $student = $this->getEntity("\\Application\\Entity\\Employment", $criteria); } //Set user object values to be saved $student->setFkStudentid($studentobject->getFkStudentid()); $student->setDesignation($studentobject->getDesignation()); $student->setOrganization($studentobject->getOrganization()); $student->setEndYear($studentobject->getEndYear()); $student->setStartYear($studentobject->getStartYear()); $student->setIsCurrent($studentobject->getIsCurrent()); try { //Commit values set to the object if (!$studentobject->getPkEmploymentid()) { $this->em->persist($student); } //Save values if just updating record $this->em->flush($student); return $student; } catch (Doctrine\ORM\ORMException $e) { throw $e->getMessage(); } }
public function allocate($object) { if (!$object->getPkStaffid()) { $staff = new \Application\Entity\Staff(); } else { $criteria = Criteria::create()->where(Criteria::expr()->eq("pkStaffid", $object->getPkStaffid())); $staff = $this->getEntity("\\Application\\Entity\\Staff", $criteria); } //Set user object values to be saved $staff->setFkUserid($object->getFkUserid()); $staff->setFkDeptid($object->getFkDeptid()); $staff->setMode($object->getMode()); try { //Commit values set to the object if (!$object->getPkStaffid()) { $this->em->persist($staff); } //Save values if just updating record $this->em->flush($staff); return $staff; } catch (Exception $e) { throw $e->getMessages(); } }
/** * Get current gradebook category id * @return int Category id */ private function get_current_gradebook_category_id() { $curr_course_id = api_get_course_int_id(); $curr_session_id = api_get_session_id(); $em = Database::getManager(); $qb = $em->createQueryBuilder(); $qb->select('gc')->from('ChamiloCoreBundle:GradebookCategory')->where(Criteria::expr()->eq('course', $curr_course_id)); if (empty($curr_session_id)) { $qb->andWhere($qb->expr()->isNull('sessionId')); } else { $qb->andWhere($qb->expr()->eq('sessionId', $curr_session_id)); } $rs = $qb->getQuery()->getResult(); $category_id = 0; if (count($rs) > 0) { $row = current($rs); $category_id = $row->getId(); } return $category_id; }