/** * Create Period query. * */ protected function createQuery($array, $search) { $this->objects = PeriodSchoolYearQuery::create()->useSchoolYearQuery()->orderByYear('desc')->endUse()->usePeriodQuery()->orderBySequence()->endUse(); if (isset($array['PeriodId']) && $array['PeriodId'] !== "") { $this->objects->where("PeriodSchoolYear.period_id = ?", $array['PeriodId']); } if (isset($array['SchoolYearId']) && $array['SchoolYearId'] !== "") { $this->objects->where("PeriodSchoolYear.school_year_id = ?", $array['SchoolYearId']); } if ($search) { session(['period_filter' => $array]); } }
public function customValidation($validator) { $validator->after(function ($validator) { $arr = Request::all(); $pid = $arr['PeriodId']; $pid_orig = isset($arr['PeriodIdOrig']) ? $arr['PeriodIdOrig'] : false; $syid = $arr['SchoolYearId']; $syid_orig = isset($arr['SchoolYearIdOrig']) ? $arr['SchoolYearIdOrig'] : false; if ($pid !== $pid_orig || $syid !== $syid_orig) { $periodSchoolYear = PeriodSchoolYearQuery::create()->findPk([$pid, $syid]); if (!is_null($periodSchoolYear)) { $validator->errors()->add('PeriodId', 'This combination of period and school year is taken.'); $validator->errors()->add('SchoolYearId', 'This combination of period and school year is taken.'); } } }); }
/** * Returns a new ChildPeriodSchoolYearQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildPeriodSchoolYearQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildPeriodSchoolYearQuery) { return $criteria; } $query = new ChildPeriodSchoolYearQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * 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 = ChildPeriodSchoolYearQuery::create(); $criteria->add(PeriodSchoolYearTableMap::COL_PERIOD_ID, $this->period_id); $criteria->add(PeriodSchoolYearTableMap::COL_SCHOOL_YEAR_ID, $this->school_year_id); return $criteria; }
/** * 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; }
private function getNewPeriodSchoolYears() { $periodSchoolYears = PeriodSchoolYearQuery::create()->where('PeriodSchoolYear.date_end >= ?', date('Y-m-d'))->find(); $periods = []; if (count($periodSchoolYears) == 0) { return $periods; } foreach ($periodSchoolYears as $key => $periodSchoolYear) { $periods[$key]['period_id'] = $periodSchoolYear->getPeriodId(); $periods[$key]['school_year_id'] = $periodSchoolYear->getSchoolYearId(); } //echo "<pre>";print_r($periods);die; return $periods; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Period is new, it will return * an empty collection; or if this Period has previously * been saved, it will retrieve related PeriodSchoolYears 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 Period. * * @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|ChildPeriodSchoolYear[] List of ChildPeriodSchoolYear objects */ public function getPeriodSchoolYearsJoinSchoolYear(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildPeriodSchoolYearQuery::create(null, $criteria); $query->joinWith('SchoolYear', $joinBehavior); return $this->getPeriodSchoolYears($query, $con); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($period_id, $school_year_id) { $period = PeriodSchoolYearQuery::create()->findPK([$period_id, $school_year_id]); $period->delete(); flash()->success("DELETED"); session(['attribute' => \Lang::get('general.PERIOD')]); return redirect($this->main_page); }
/** * Performs an INSERT on the database, given a PeriodSchoolYear or Criteria object. * * @param mixed $criteria Criteria or PeriodSchoolYear 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(PeriodSchoolYearTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from PeriodSchoolYear object } // Set the correct dbName $query = PeriodSchoolYearQuery::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); }); }