Пример #1
0
 public static function doSelectJoinAllExceptNgTestSubject(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     NgTestApplScorePeer::addSelectColumns($c);
     $startcol2 = NgTestApplScorePeer::NUM_COLUMNS - NgTestApplScorePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     NgTestApplSchedPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + NgTestApplSchedPeer::NUM_COLUMNS;
     $c->addJoin(NgTestApplScorePeer::NG_TEST_APPL_SCHED_ID, NgTestApplSchedPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = NgTestApplScorePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = NgTestApplSchedPeer::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->getNgTestApplSched();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addNgTestApplScore($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initNgTestApplScores();
             $obj2->addNgTestApplScore($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Пример #2
0
 public function getNgTestApplSchedsJoinNgTestApplicant($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseNgTestApplSchedPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collNgTestApplScheds === null) {
         if ($this->isNew()) {
             $this->collNgTestApplScheds = array();
         } else {
             $criteria->add(NgTestApplSchedPeer::NG_TEST_SCHEDULE_ID, $this->getId());
             $this->collNgTestApplScheds = NgTestApplSchedPeer::doSelectJoinNgTestApplicant($criteria, $con);
         }
     } else {
         $criteria->add(NgTestApplSchedPeer::NG_TEST_SCHEDULE_ID, $this->getId());
         if (!isset($this->lastNgTestApplSchedCriteria) || !$this->lastNgTestApplSchedCriteria->equals($criteria)) {
             $this->collNgTestApplScheds = NgTestApplSchedPeer::doSelectJoinNgTestApplicant($criteria, $con);
         }
     }
     $this->lastNgTestApplSchedCriteria = $criteria;
     return $this->collNgTestApplScheds;
 }
Пример #3
0
 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');
 }
Пример #4
0
 public function executeDelete()
 {
     $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);
     $c = new Criteria();
     $c->add(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, $this->ng_reg_detail->getId());
     $test_sched = NgTestSchedulePeer::doSelect($c);
     if ($test_sched) {
         $sched_count = NgTestSchedulePeer::doCount($c);
         $test_appl = 0;
         foreach ($test_sched as $ts) {
             $ct = new Criteria();
             $ct->add(NgTestApplSchedPeer::NG_TEST_SCHEDULE_ID, $ts->getId());
             $tas = NgTestApplSchedPeer::doSelect($ct);
             if ($tas) {
                 foreach ($tas as $ta) {
                     $test_appl += 1;
                     $ta->delete();
                 }
             }
             $ts->delete();
         }
         #$this->info = 'Data yg dihapus';
         $this->getRequest()->setError('ng_reg_detail/delete', '_DATA_DELETE_ ' . $this->ng_reg_detail->toString() . ' (' . $test_appl . ' Jadwal #' . $sched_count . ' Pendaftar)');
         $this->ng_reg_detail->delete();
     } else {
         $this->ng_reg_detail->delete();
     }
     $this->getRequest()->setParameter('id', $this->ng_reg_period->getId());
     return $this->forward('ng_reg_detail', 'list');
 }
Пример #5
0
 public function getNgTestApplSched($con = null)
 {
     include_once 'lib/model/om/BaseNgTestApplSchedPeer.php';
     if ($this->aNgTestApplSched === null && $this->ng_test_appl_sched_id !== null) {
         $this->aNgTestApplSched = NgTestApplSchedPeer::retrieveByPK($this->ng_test_appl_sched_id, $con);
     }
     return $this->aNgTestApplSched;
 }
Пример #6
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = NgTestApplSchedPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setNgTestScheduleId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setNgTestApplicantId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setAvgScore($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setRank($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setCreated($arr[$keys[5]]);
     }
 }
Пример #7
0
 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(NgTestApplSchedPeer::ID, $pks, Criteria::IN);
         $objs = NgTestApplSchedPeer::doSelect($criteria, $con);
     }
     return $objs;
 }