public static function doFiltered(Criteria $criteria, $con = null) { $id = sfContext::getInstance()->getRequest()->getParameter('ng_reg_period_id'); $nrp = NgRegPeriodPeer::retrieveByPK($id); $criteria->add(NgRegTestPeriodPeer::NG_REG_PERIOD_ID, $nrp->getId()); $criteria->add(NgRegTestPeriodPeer::REG_TYPE, NgRegTestPeriod::TEST); $criteria->addDescendingOrderByColumn(NgRegTestPeriodPeer::ID); return NgRegTestPeriodPeer::doSelect($criteria); }
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 getNgRegTestPeriods($criteria = null, $con = null) { include_once 'lib/model/om/BaseNgRegTestPeriodPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNgRegTestPeriods === null) { if ($this->isNew()) { $this->collNgRegTestPeriods = array(); } else { $criteria->add(NgRegTestPeriodPeer::NG_REG_PERIOD_ID, $this->getId()); NgRegTestPeriodPeer::addSelectColumns($criteria); $this->collNgRegTestPeriods = NgRegTestPeriodPeer::doSelect($criteria, $con); } } else { if (!$this->isNew()) { $criteria->add(NgRegTestPeriodPeer::NG_REG_PERIOD_ID, $this->getId()); NgRegTestPeriodPeer::addSelectColumns($criteria); if (!isset($this->lastNgRegTestPeriodCriteria) || !$this->lastNgRegTestPeriodCriteria->equals($criteria)) { $this->collNgRegTestPeriods = NgRegTestPeriodPeer::doSelect($criteria, $con); } } } $this->lastNgRegTestPeriodCriteria = $criteria; return $this->collNgRegTestPeriods; }
public function executeEditOther() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); $c->add(JobPeer::CODE, 'ng_reg_period'); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); if (!$acl) { $this->forward('default', 'error404'); } $this->ng_reg_period = NgRegPeriodPeer::retrieveByPK($this->getRequestParameter('ng_reg_period_id')); $this->forward404Unless($this->ng_reg_period); $this->ng_reg_detail = NgRegTestPeriodPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->ng_reg_detail); $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); if ($acl->getRemovePriv()) { array_push($actions, array('name' => 'delete', 'url' => 'ng_reg_detail/deleteOther?id=' . $this->ng_reg_detail->getId() . '&ng_reg_period_id=' . $this->ng_reg_period->getId(), 'color' => 'red')); } array_push($actions, array('name' => 'cancel', 'url' => 'ng_reg_detail/listOther?id=' . $this->ng_reg_period->getId(), 'color' => 'black')); $ct = new Criteria(); $ct->add(NgRegTestPeriodPeer::NG_REG_PERIOD_ID, $this->ng_reg_period->getId()); $ct->add(NgRegTestPeriodPeer::REG_TYPE, NgRegTestPeriod::TEST); $test_period = NgRegTestPeriodPeer::doSelect($ct); $actions2 = array(array('name' => $this->ng_reg_period->toString(), 'url' => 'ng_reg_period/list', 'color' => 'sky')); array_push($actions2, array('name' => 'Reg Period Detail Schedule', 'url' => 'ng_reg_detail/listOther?id=' . $this->ng_reg_period->getId(), 'color' => 'sun', 'type' => 'direct')); array_push($actions2, array('name' => 'Reg Test Period', 'url' => 'ng_reg_detail/list?id=' . $this->ng_reg_period->getId(), 'color' => 'sky')); if ($test_period) { array_push($actions2, array('name' => 'Reg Test Period Detail Schedule', 'url' => 'ng_reg_detail/listDetail?id=' . $this->ng_reg_period->getId(), 'color' => 'sky')); array_push($actions2, array('name' => 'Assessment Test', 'url' => 'ng_reg_detail/listTest?id=' . $this->ng_reg_period->getId(), 'color' => 'sky')); } $this->actions2 = $actions2; $this->subtitle = $this->ng_reg_detail->toString() . ' - id:' . $this->ng_reg_detail->getId(); $this->type = 'edit'; $this->setTemplate('edit'); $this->actions = $actions; $this->reg_type = NgRegTestPeriod::OTHER; $this->title = 'Reg Period Detail Schedule'; }
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(NgRegTestPeriodPeer::ID, $pks, Criteria::IN); $objs = NgRegTestPeriodPeer::doSelect($criteria, $con); } return $objs; }