Ejemplo n.º 1
0
 /**
  * Create Student query.
  *
  */
 protected function createQuery($array, $search)
 {
     $this->objects = StudentQuery::create()->useSchoolYearQuery()->orderByYear('desc')->endUse()->orderByIdentificationNumber();
     if (isset($array['IdentificationNumber']) && $array['IdentificationNumber'] !== "") {
         $this->objects->where("student.identification_number = ?", $array['IdentificationNumber']);
     }
     if (isset($array['SchoolYearId']) && $array['SchoolYearId'] !== "") {
         $this->objects->where("student.school_year_id = ?", $array['SchoolYearId']);
     }
     if (isset($array['CourseId']) && $array['CourseId'] !== "") {
         $this->objects->where("student.course_id = '" . $array['CourseId'] . "'");
     }
     if (isset($array['FirstName']) && $array['FirstName'] !== "") {
         $this->objects->where("student.first_name like '%" . $array['FirstName'] . "%'");
     }
     if (isset($array['LastName']) && $array['LastName'] !== "") {
         $this->objects->where("student.last_name like '%" . $array['LastName'] . "%'");
     }
     if (isset($array['BirthPlace']) && $array['BirthPlace'] !== "") {
         $this->objects->where("student.birth_place like '%" . $array['BirthPlace'] . "%'");
     }
     if (isset($array['BirthdayFrom']) && $array['BirthdayFrom'] !== "") {
         $this->objects->where("student.birthday >= ?", $array['BirthdayFrom']);
     }
     if (isset($array['BirthdayTo']) && $array['BirthdayTo'] !== "") {
         $this->objects->where("student.birthday <= ?", $array['BirthdayTo']);
     }
     if (isset($array['PhoneNumber']) && $array['PhoneNumber'] !== "") {
         $this->objects->where("student.phone_number like '%" . $array['PhoneNumber'] . "%'");
     }
     if ($search) {
         session(['student_filter' => $array]);
     }
 }
Ejemplo n.º 2
0
 private function getStudents()
 {
     $students = StudentQuery::create()->useSchoolYearQuery()->orderByYear('desc')->endUse()->orderByIdentificationNumber()->find();
     $students_arr = [];
     foreach ($students as $student) {
         $name = $student->__toString();
         $id = $student->getId();
         $students_arr[$id] = $name;
     }
     return $students_arr;
 }
Ejemplo n.º 3
0
 public function customValidation($validator)
 {
     $validator->after(function ($validator) {
         $arr = Request::all();
         $idn = $arr['IdentificationNumber'];
         $idn_orig = isset($arr['IdentificationNumberOrig']) ? $arr['IdentificationNumberOrig'] : false;
         $syid = $arr['SchoolYearId'];
         $syid_orig = isset($arr['SchoolYearIdOrig']) ? $arr['SchoolYearIdOrig'] : false;
         if ($idn !== $idn_orig || $syid !== $syid_orig) {
             $student = StudentQuery::create()->where('Student.identification_number = ?', $idn)->where('Student.school_year_id = ?', $syid)->findOne();
             if (!is_null($student)) {
                 $validator->errors()->add('IdentificationNumber', 'This combination of identification number and school year is taken.');
                 $validator->errors()->add('SchoolYearId', 'This combination of identification number and school year is taken.');
             }
         }
     });
 }
Ejemplo n.º 4
0
 private function getStudents($status)
 {
     $students = StudentQuery::create()->useSchoolYearQuery()->orderByYear('desc')->endUse()->orderByIdentificationNumber();
     if ($status === 'professor') {
         $students->join('Student.Course');
         $students->join('Course.Engagement');
         $students->where('Engagement.professor_id = ?', \Auth::user()->getProfessorId());
     }
     $students->orderByIdentificationNumber()->find();
     $students_arr = ['' => ''];
     foreach ($students as $student) {
         $name = $student->__toString();
         $id = $student->getId();
         $students_arr[$id] = $name;
     }
     return $students_arr;
 }
Ejemplo n.º 5
0
 /**
  * Get the associated ChildStudent object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildStudent The associated ChildStudent object.
  * @throws PropelException
  */
 public function getStudent(ConnectionInterface $con = null)
 {
     if ($this->aStudent === null && $this->student_id !== null) {
         $this->aStudent = ChildStudentQuery::create()->findPk($this->student_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->aStudent->addApplications($this);
            */
     }
     return $this->aStudent;
 }
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 = ChildStudentQuery::create();
     $criteria->add(StudentTableMap::COL_ID, $this->id);
     return $criteria;
 }
Ejemplo n.º 7
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 Students 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|ChildStudent[] List of ChildStudent objects
  */
 public function getStudentsJoinSchoolYear(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
 {
     $query = ChildStudentQuery::create(null, $criteria);
     $query->joinWith('SchoolYear', $joinBehavior);
     return $this->getStudents($query, $con);
 }
Ejemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $student = StudentQuery::create()->findPK($id);
     $student->delete();
     flash()->success("DELETED");
     session(['attribute' => \Lang::get('general.STUDENT')]);
     return redirect($this->main_page);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 10
0
 /**
  * Performs an INSERT on the database, given a Student or Criteria object.
  *
  * @param mixed               $criteria Criteria or Student 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(StudentTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Student object
     }
     if ($criteria->containsKey(StudentTableMap::COL_ID) && $criteria->keyContainsValue(StudentTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . StudentTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = StudentQuery::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);
     });
 }