Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public function getNgRegTestPeriod($con = null)
 {
     include_once 'lib/model/om/BaseNgRegTestPeriodPeer.php';
     if ($this->aNgRegTestPeriod === null && $this->ng_reg_test_period_id !== null) {
         $this->aNgRegTestPeriod = NgRegTestPeriodPeer::retrieveByPK($this->ng_reg_test_period_id, $con);
     }
     return $this->aNgRegTestPeriod;
 }
Esempio n. 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');
 }
Esempio n. 4
0
 public static function doSelectJoinAllExceptLocation(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     NgTestSchedulePeer::addSelectColumns($c);
     $startcol2 = NgTestSchedulePeer::NUM_COLUMNS - NgTestSchedulePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     NgRegTestPeriodPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + NgRegTestPeriodPeer::NUM_COLUMNS;
     $c->addJoin(NgTestSchedulePeer::NG_REG_TEST_PERIOD_ID, NgRegTestPeriodPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = NgTestSchedulePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = NgRegTestPeriodPeer::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->getNgRegTestPeriod();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addNgTestSchedule($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initNgTestSchedules();
             $obj2->addNgTestSchedule($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Esempio n. 5
0
 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'));
 }
Esempio n. 6
0
 public function countNgRegTestPeriods($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseNgRegTestPeriodPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(NgRegTestPeriodPeer::NG_REG_PERIOD_ID, $this->getId());
     return NgRegTestPeriodPeer::doCount($criteria, $distinct, $con);
 }
Esempio n. 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(NgRegTestPeriodPeer::ID, $pks, Criteria::IN);
         $objs = NgRegTestPeriodPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 8
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = NgRegTestPeriodPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setNgRegPeriodId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setStart($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEnd($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCode($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setName($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setDetail($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setRegType($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setCreated($arr[$keys[8]]);
     }
 }
Esempio n. 9
0
 public static function doSelectJoinAllExceptClassLevelRelatedByLastClass(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     NgTestApplicantPeer::addSelectColumns($c);
     $startcol2 = NgTestApplicantPeer::NUM_COLUMNS - NgTestApplicantPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     NgRegInfoPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + NgRegInfoPeer::NUM_COLUMNS;
     DepartmentPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + DepartmentPeer::NUM_COLUMNS;
     NgRegTestPeriodPeer::addSelectColumns($c);
     $startcol5 = $startcol4 + NgRegTestPeriodPeer::NUM_COLUMNS;
     NgStatusApplicantPeer::addSelectColumns($c);
     $startcol6 = $startcol5 + NgStatusApplicantPeer::NUM_COLUMNS;
     NgApplicantCategoryPeer::addSelectColumns($c);
     $startcol7 = $startcol6 + NgApplicantCategoryPeer::NUM_COLUMNS;
     CountryPeer::addSelectColumns($c);
     $startcol8 = $startcol7 + CountryPeer::NUM_COLUMNS;
     ReligionPeer::addSelectColumns($c);
     $startcol9 = $startcol8 + ReligionPeer::NUM_COLUMNS;
     RegionPeer::addSelectColumns($c);
     $startcol10 = $startcol9 + RegionPeer::NUM_COLUMNS;
     CityPeer::addSelectColumns($c);
     $startcol11 = $startcol10 + CityPeer::NUM_COLUMNS;
     DistrictPeer::addSelectColumns($c);
     $startcol12 = $startcol11 + DistrictPeer::NUM_COLUMNS;
     SubdistrictPeer::addSelectColumns($c);
     $startcol13 = $startcol12 + SubdistrictPeer::NUM_COLUMNS;
     $c->addJoin(NgTestApplicantPeer::NG_REG_INFO_ID, NgRegInfoPeer::ID);
     $c->addJoin(NgTestApplicantPeer::DEPARTMENT_ID, DepartmentPeer::ID);
     $c->addJoin(NgTestApplicantPeer::NG_REG_TEST_PERIOD_ID, NgRegTestPeriodPeer::ID);
     $c->addJoin(NgTestApplicantPeer::NG_STATUS_APPLICANT_ID, NgStatusApplicantPeer::ID);
     $c->addJoin(NgTestApplicantPeer::NG_APPLICANT_CATEGORY_ID, NgApplicantCategoryPeer::ID);
     $c->addJoin(NgTestApplicantPeer::COUNTRY_ID, CountryPeer::ID);
     $c->addJoin(NgTestApplicantPeer::RELIGION_ID, ReligionPeer::ID);
     $c->addJoin(NgTestApplicantPeer::REGION_ID, RegionPeer::ID);
     $c->addJoin(NgTestApplicantPeer::CITY_ID, CityPeer::ID);
     $c->addJoin(NgTestApplicantPeer::DISTRICT_ID, DistrictPeer::ID);
     $c->addJoin(NgTestApplicantPeer::SUBDISTRICT_ID, SubdistrictPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = NgTestApplicantPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = NgRegInfoPeer::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->getNgRegInfo();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initNgTestApplicants();
             $obj2->addNgTestApplicant($obj1);
         }
         $omClass = DepartmentPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj3 = new $cls();
         $obj3->hydrate($rs, $startcol3);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj3 = $temp_obj1->getDepartment();
             if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj3->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj3->initNgTestApplicants();
             $obj3->addNgTestApplicant($obj1);
         }
         $omClass = NgRegTestPeriodPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj4 = new $cls();
         $obj4->hydrate($rs, $startcol4);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj4 = $temp_obj1->getNgRegTestPeriod();
             if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj4->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj4->initNgTestApplicants();
             $obj4->addNgTestApplicant($obj1);
         }
         $omClass = NgStatusApplicantPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj5 = new $cls();
         $obj5->hydrate($rs, $startcol5);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj5 = $temp_obj1->getNgStatusApplicant();
             if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj5->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj5->initNgTestApplicants();
             $obj5->addNgTestApplicant($obj1);
         }
         $omClass = NgApplicantCategoryPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj6 = new $cls();
         $obj6->hydrate($rs, $startcol6);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj6 = $temp_obj1->getNgApplicantCategory();
             if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj6->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj6->initNgTestApplicants();
             $obj6->addNgTestApplicant($obj1);
         }
         $omClass = CountryPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj7 = new $cls();
         $obj7->hydrate($rs, $startcol7);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj7 = $temp_obj1->getCountry();
             if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj7->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj7->initNgTestApplicants();
             $obj7->addNgTestApplicant($obj1);
         }
         $omClass = ReligionPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj8 = new $cls();
         $obj8->hydrate($rs, $startcol8);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj8 = $temp_obj1->getReligion();
             if ($temp_obj8->getPrimaryKey() === $obj8->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj8->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj8->initNgTestApplicants();
             $obj8->addNgTestApplicant($obj1);
         }
         $omClass = RegionPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj9 = new $cls();
         $obj9->hydrate($rs, $startcol9);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj9 = $temp_obj1->getRegion();
             if ($temp_obj9->getPrimaryKey() === $obj9->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj9->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj9->initNgTestApplicants();
             $obj9->addNgTestApplicant($obj1);
         }
         $omClass = CityPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj10 = new $cls();
         $obj10->hydrate($rs, $startcol10);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj10 = $temp_obj1->getCity();
             if ($temp_obj10->getPrimaryKey() === $obj10->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj10->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj10->initNgTestApplicants();
             $obj10->addNgTestApplicant($obj1);
         }
         $omClass = DistrictPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj11 = new $cls();
         $obj11->hydrate($rs, $startcol11);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj11 = $temp_obj1->getDistrict();
             if ($temp_obj11->getPrimaryKey() === $obj11->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj11->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj11->initNgTestApplicants();
             $obj11->addNgTestApplicant($obj1);
         }
         $omClass = SubdistrictPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj12 = new $cls();
         $obj12->hydrate($rs, $startcol12);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj12 = $temp_obj1->getSubdistrict();
             if ($temp_obj12->getPrimaryKey() === $obj12->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj12->addNgTestApplicant($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj12->initNgTestApplicants();
             $obj12->addNgTestApplicant($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }