public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(NgTestSchedulePeer::ID, $pks, Criteria::IN); $objs = NgTestSchedulePeer::doSelect($criteria, $con); } return $objs; }
public function executeSavePayment() { #$user_id = $this->getContext()->getUser()->getAttribute('user_id', null, 'bo'); $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_type = $this->getRequestParameter('action_type'); /** $year = $this->getRequestParameter('year'); $month = $this->getRequestParameter('month'); $department = DepartmentPeer::retrieveByPK($this->getRequestParameter('department_id')); $dept_code = $department->getNumCode().'-'; $code_appl = 'REG'; $stu_code = ParamsPeer::retrieveByCode('applicant_code'); $sc = $stu_code->getValue(); $sc = explode('$', $sc); array_shift($sc); $code_len = 0; $code = ''; foreach ($sc as $k => $v) { $v = explode('#', $v); if ($v[0] == 'app') { $code_len += $v[1]; $code .= str_pad($code_appl, $v[1], '0', STR_PAD_LEFT); } elseif ($v[0] == 'dept') { $code .= str_pad($dept_code, $v[1], '0', STR_PAD_LEFT); $code_len += $v[1]; } elseif ($v[0] == 'year') { if (strlen($year) <= $v[1]) { $code .= str_pad($year, $v[1], '0', STR_PAD_LEFT); } else { $code .= substr($year, strlen($year) - $v[1]); } $code_len += $v[1]; } elseif ($v[0] == 'month') { if (strlen($month) <= $v[1]) { $code .= str_pad($month, $v[1], '0', STR_PAD_LEFT); } else { $code .= substr($month, strlen($month) - $v[1]); } $code_len += $v[1]; } elseif ($v[0] == 'seq') { $c = new Criteria(); $c->add(NgTestApplicantPeer::CODE, $code . '%', Criteria::LIKE); $c->addDescendingOrderByColumn(NgTestApplicantPeer::CODE); $c->setLimit(1); $last_applicant = NgTestApplicantPeer::doSelectOne($c); if ($last_applicant) { $lap = $last_applicant->getCode(); $lap = substr_replace($lap, '', 0, $code_len); $lap = substr($lap, 0, $v[1]); $lap++; $code .= str_pad($lap, $v[1], '0', STR_PAD_LEFT); } else { $code .= str_pad(1, $v[1], '0', STR_PAD_LEFT); break; } } $sc[$k] = $v; } **/ $newCode = $this->pmbTools->generateApplicantCode(NgStatusApplicant::CONFIRMED, $this->getRequestParameter('department_id')); if ($action_type == $action_i18n || !$this->getRequestParameter('id')) { $ng_test_applicant = new NgTestApplicant(); } else { $ng_test_applicant = NgTestApplicantPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($ng_test_applicant); } $ng_test_applicant->setCode($newCode); $ng_test_applicant->setNgStatusApplicantId(NgStatusApplicant::CONFIRMED); $ng_test_applicant->save(); $c = new Criteria(); $c->add(NgRegTestPeriodPeer::NG_REG_PERIOD_ID, $ng_test_applicant->getNgRegTestPeriod()->getNgRegPeriodId()); $nrtps = NgRegTestPeriodPeer::doSelect($c); foreach ($nrtps as $nrtp) { $cw = new Criteria(); $cw->add(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, $nrtp->getId()); $cw->addAscendingorderByColumn(NgTestSchedulePeer::ID); $scheds = NgTestSchedulePeer::doSelect($cw); $s1 = array(); foreach ($scheds as $s) { $s1[$s->getNgRegTestPeriodId()][] = array('ng_reg_test_period_id' => $s->getNgRegTestPeriodId(), 'used' => $s->countNgTestApplScheds(), 'capacity' => $s->getCapacity(), 'sched' => $s); } foreach ($s1 as $s) { $c = new Criteria(); $c->add(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, $nrtp->getId()); $c->addJoin(TestApplSchedPeer::TEST_SCHEDULE_ID, TestSchedulePeer::ID); $c->add(NgTestApplSchedPeer::NG_TEST_APPLICANT_ID, $ng_test_applicant->getId()); $tas = NgTestApplSchedPeer::doSelectOne($c); if ($tas == null) { $i = 0; while ($s[$i]) { $sched = $s[$i]; if ($sched['used'] < $sched['capacity']) { $tas = new NgTestApplSched(); $tas->setNgTestApplicant($ng_test_applicant); $tas->setNgTestSchedule($sched['sched']); $tas->save(); break; } $i++; } } } } return $this->redirect('ng_test_applicant/list'); }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = NgTestSchedulePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNgRegTestPeriodId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setLocationId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setStart($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setEnd($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setTitle($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCapacity($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setCreated($arr[$keys[7]]); } }
public function executeGetApplSched() { $this->ng_reg_period = NgRegPeriodPeer::retrieveByPK($this->getRequestParameter('ng_reg_period_id')); $this->forward404Unless($this->ng_reg_period); $this->ng_reg_test_period = NgRegTestPeriodPeer::retrieveByPK($this->getRequestParameter('ng_reg_test_period_id')); $this->forward404Unless($this->ng_reg_test_period); $this->ng_test_schedule = NgTestSchedulePeer::retrieveByPK($this->getRequestParameter('ng_test_schedule_id')); $this->forward404Unless($this->ng_test_schedule); $ct = new Criteria(); $ct->add(NgTestSubjectPeer::COURSE_MODEL, DepartmentPeer::retrieveByPK($this->ng_reg_period->getAcademicCalendar()->getDepartmentId())->getCourseModel()); $this->test_subjects = NgTestSubjectPeer::doSelect($ct); $c = new Criteria(); $c->add(NgTestApplSchedPeer::NG_TEST_SCHEDULE_ID, $this->ng_test_schedule->getId()); $c->addJoin(NgTestApplicantPeer::ID, NgTestApplSchedPeer::NG_TEST_APPLICANT_ID); $rpp = $this->getRequestParameter('max_per_page', $this->getUser()->getAttribute('max_per_page', ParamsPeer::retrieveByCode('row_per_page')->getValue(), 'applicant')); $this->getUser()->setAttribute('max_per_page', $rpp, 'applicant'); $pager = new sfPropelPager('NgTestApplicant', $rpp); $pager->setCriteria($c); $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'applicant')); $this->getUser()->setAttribute('page', $page, 'applicant'); $pager->setPage($page); $pager->init(); $this->pager = $pager; $this->type = 'edit'; $this->actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")), array('name' => 'cancel', 'url' => 'ng_reg_detail/listTest?id=' . $this->ng_reg_period->getId(), 'color' => 'black')); }
public function getNgTestSchedulesJoinLocation($criteria = null, $con = null) { include_once 'lib/model/om/BaseNgTestSchedulePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNgTestSchedules === null) { if ($this->isNew()) { $this->collNgTestSchedules = array(); } else { $criteria->add(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, $this->getId()); $this->collNgTestSchedules = NgTestSchedulePeer::doSelectJoinLocation($criteria, $con); } } else { $criteria->add(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, $this->getId()); if (!isset($this->lastNgTestScheduleCriteria) || !$this->lastNgTestScheduleCriteria->equals($criteria)) { $this->collNgTestSchedules = NgTestSchedulePeer::doSelectJoinLocation($criteria, $con); } } $this->lastNgTestScheduleCriteria = $criteria; return $this->collNgTestSchedules; }
<?php if ($pager->getNbResults() < 1) { ?> <tr class="list"><td colspan="100"><div class="no_record"><?php echo __('No record found'); ?> </div></td></tr> <?php } else { ?> <?php $i = 0; foreach ($pager->getResults() as $ng_reg_test_period) { $c = new Criteria(); $c->add(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, $ng_reg_test_period->getId()); $ng_reg_test_period->child = NgTestSchedulePeer::doCount($c); ?> <tr id='cs_<?php echo $ng_reg_test_period->getId(); ?> ' class="list<?php ++$i; if ($i % 2 == 0) { echo ' even'; } ?> "> <td id='cs_<?php echo $ng_reg_test_period->getId(); ?> _expand' style="vertical-align: middle; text-align: center;">
public function getNgTestSchedule($con = null) { include_once 'lib/model/om/BaseNgTestSchedulePeer.php'; if ($this->aNgTestSchedule === null && $this->ng_test_schedule_id !== null) { $this->aNgTestSchedule = NgTestSchedulePeer::retrieveByPK($this->ng_test_schedule_id, $con); } return $this->aNgTestSchedule; }
public static function doSelectJoinAllExceptNgTestApplicant(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } NgTestApplSchedPeer::addSelectColumns($c); $startcol2 = NgTestApplSchedPeer::NUM_COLUMNS - NgTestApplSchedPeer::NUM_LAZY_LOAD_COLUMNS + 1; NgTestSchedulePeer::addSelectColumns($c); $startcol3 = $startcol2 + NgTestSchedulePeer::NUM_COLUMNS; $c->addJoin(NgTestApplSchedPeer::NG_TEST_SCHEDULE_ID, NgTestSchedulePeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = NgTestApplSchedPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = NgTestSchedulePeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getNgTestSchedule(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addNgTestApplSched($obj1); break; } } if ($newObject) { $obj2->initNgTestApplScheds(); $obj2->addNgTestApplSched($obj1); } $results[] = $obj1; } return $results; }