コード例 #1
0
 private function getSubjects()
 {
     $subjects = SubjectQuery::create()->orderByName()->find();
     $subjects_arr = ['' => ''];
     foreach ($subjects as $subject) {
         $name = $subject->__toString();
         $id = $subject->getId();
         $subjects_arr[$id] = $name;
     }
     return $subjects_arr;
 }
コード例 #2
0
 /**
  * Create Subject query.
  *
  */
 protected function createQuery($array, $search)
 {
     $this->subjects = SubjectQuery::create()->orderByCode();
     if (isset($array['Name']) && $array['Name'] !== "") {
         $this->subjects->where("subject.name like '%" . $array['Name'] . "%'");
     }
     if (isset($array['Code']) && $array['Code'] !== "") {
         $this->subjects->where("subject.code like '%" . $array['Code'] . "%'");
     }
     if ($search) {
         session(['subject_filter' => $array]);
     }
 }
コード例 #3
0
 private function getSubjects($status)
 {
     $subjects = SubjectQuery::create()->orderByName();
     if ($status === 'professor') {
         $subjects->joinEngagement();
         $subjects->where('Engagement.professor_id = ?', \Auth::user()->getProfessorId());
     } else {
         if ($status === 'student') {
             $subjects->joinStudyProgram();
             $subjects->where('StudyProgram.course_id = ?', \Auth::user()->getStudent()->getCourseId());
         }
     }
     $subjects->find();
     $subjects_arr = ['' => ''];
     foreach ($subjects as $subject) {
         $name = $subject->__toString();
         $id = $subject->getId();
         $subjects_arr[$id] = $name;
     }
     return $subjects_arr;
 }
コード例 #4
0
 public function getApplications($subject_id, $school_year_id, $course_id)
 {
     $subject = SubjectQuery::create()->findPk($subject_id);
     $course = CourseQuery::create()->findPk($course_id);
     $schoolYear = SchoolYearQuery::create()->findPk($school_year_id);
     $applications = ApplicationQuery::create()->where('Application.subject_id = ?', $subject_id)->where('Application.school_year_id = ?', $school_year_id)->join('Application.Student')->join('Application.Period')->where('Student.course_id = ?', $course_id)->select(['Student.FirstName', 'Student.LastName', 'Student.CourseId', 'Period.Name', 'ApplicationDate', 'ExamDate', 'ExamTime', 'ExamScore'])->find();
     //dd($applications);
     $applications_arr = [];
     $cnt = 0;
     foreach ($applications as $key => $application) {
         $professor = $this->getProfessorName($subject_id, $application['Student.CourseId'], $school_year_id);
         $applications_arr[$professor][$cnt]['student'] = $application['Student.FirstName'] . ' ' . $application['Student.LastName'];
         $applications_arr[$professor][$cnt]['period'] = $application['Period.Name'];
         $applications_arr[$professor][$cnt]['application_date'] = $application['ApplicationDate'];
         $applications_arr[$professor][$cnt]['exam_datetime'] = $application['ExamDate'] . " " . $application['ExamTime'];
         $applications_arr[$professor][$cnt]['exam_score'] = isset($application['ExamScore']) && $application['ExamScore'] != 0 ? $application['ExamScore'] : '';
         $cnt++;
     }
     $result['data'] = $applications_arr;
     $result['course'] = $course->__toString();
     $result['subject'] = $subject->__toString();
     $result['school_year'] = $schoolYear->__toString();
     return $result;
 }
コード例 #5
0
 /**
  * Get the associated ChildSubject object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildSubject The associated ChildSubject object.
  * @throws PropelException
  */
 public function getSubject(ConnectionInterface $con = null)
 {
     if ($this->aSubject === null && $this->subject_id !== null) {
         $this->aSubject = ChildSubjectQuery::create()->findPk($this->subject_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aSubject->addApplications($this);
            */
     }
     return $this->aSubject;
 }
コード例 #6
0
 /**
  * Performs an INSERT on the database, given a Subject or Criteria object.
  *
  * @param mixed               $criteria Criteria or Subject 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(SubjectTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Subject object
     }
     if ($criteria->containsKey(SubjectTableMap::COL_ID) && $criteria->keyContainsValue(SubjectTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . SubjectTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = SubjectQuery::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);
     });
 }
コード例 #7
0
 /**
  * Returns a new ChildSubjectQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildSubjectQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildSubjectQuery) {
         return $criteria;
     }
     $query = new ChildSubjectQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
コード例 #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $subject = SubjectQuery::create()->findPK($id);
     $subject->delete();
     flash()->success("DELETED");
     session(['attribute' => \Lang::get('general.SUBJECT')]);
     return redirect($this->main_page);
 }
コード例 #9
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $storage_path = storage_path();
     $sms_request = $request->all();
     $phone_number = $sms_request['sender'];
     $description = json_encode($sms_request);
     $student = StudentQuery::retrieveByPhoneNumber($phone_number);
     if (is_null($student)) {
         $msg_text = 'Niste registrovani. Kontaktirajte administratora PMF-a.';
         //$this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     if ($sms_request['sms_prefix'] !== 'PRIJAVA_ISPITA') {
         $msg_text = "Nepostojeca komanda! Za prijavu ispita poslati: ‘PRIJAVA_ISPITA <šifra_predmeta> <ispitni_rok>'";
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $fullsms = explode(" ", $sms_request['fullsms']);
     $subject_code = isset($fullsms[1]) ? $fullsms[1] : null;
     $period_name = isset($fullsms[2]) ? $fullsms[2] : null;
     if (!isset($subject_code) && !isset($period_name)) {
         $msg_text = 'Doslo je do greske, proverite unete podatke.';
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $subject = SubjectQuery::retrieveByCode($subject_code);
     if (is_null($subject)) {
         $msg_text = 'Nepostojeca šifra predmeta.';
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $period = $this->getPeriodIdByName($period_name);
     if (is_null($period)) {
         $msg_text = 'Ispitni rok ne postoji';
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $school_year_id = $this->getSchoolYearIdByDate();
     $periodSchoolYear = PeriodSchoolYearQuery::create()->findPk([$period->getId(), $school_year_id]);
     if (is_null($periodSchoolYear)) {
         $msg_text = 'Ispitni rok ne postoji';
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $studyProgram = StudyProgramQuery::create()->findPk([$subject->getId(), $student->getCourseId()]);
     if (is_null($studyProgram)) {
         $msg_text = 'Ovaj predmet nije u vašem studijskom programu.';
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $msg_text = $this->allowedToApply($student->getId(), $subject, $period->getId(), $school_year_id);
     if ($msg_text !== null) {
         $this->sendSms($phone_number, $msg_text, $description);
         exit;
     }
     $application = new Application();
     $application->setStudentId($student->getId());
     $application->setSubjectId($subject->getId());
     $application->setPeriodId(8);
     $application->setSchoolYearId(8);
     $application->setApplicationDate(date('Y-m-d'));
     $application->save();
     $msg_text = 'Uspesno ste prijavili ispit.';
     $this->sendSms($phone_number, $msg_text, $description, $application->getId());
     exit;
 }
コード例 #10
0
ファイル: Subject.php プロジェクト: nstojanovickg/diplomski
 /**
  * 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 = ChildSubjectQuery::create();
     $criteria->add(SubjectTableMap::COL_ID, $this->id);
     return $criteria;
 }