Example #1
0
 public function executeListTest()
 {
     $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo');
     $c = new Criteria();
     $c->add(JobPeer::CODE, 'reg_test_period');
     $job = JobPeer::doSelectOne($c);
     $acl = AclPeer::retrieveByPK($group_id, $job->getId());
     if (!$acl) {
         $this->forward('default', 'error404');
     }
     $this->can_add = $acl->getAddPriv() == 1;
     $this->can_edit = $acl->getEditPriv() == 1;
     $this->can_remove = $acl->getRemovePriv() == 1;
     $reg_period = RegPeriodPeer::retrieveByPk($this->getRequestParameter('reg_period_id'));
     $this->forward404Unless($reg_period);
     $reg_test_period = RegTestPeriodPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($reg_test_period);
     $c = new Criteria();
     $c->add(TestSchedulePeer::REG_TEST_PERIOD_ID, $reg_test_period->getId());
     $c->addAscendingOrderByColumn(TestSchedulePeer::ID);
     $this->sort($c);
     if ($this->getRequest()->hasParameter('filters')) {
         $filters = $this->getRequestParameter('filters');
         if ($filters == 'clear') {
             $this->filters = null;
         } else {
             $defined_filter = false;
             foreach ($filters as $f) {
                 if (is_array($f)) {
                     if (strlen($f['from']) > 0 || strlen($f['to']) > 0) {
                         $defined_filter = true;
                         break;
                     }
                 } else {
                     if ($f != null && $f != '') {
                         $defined_filter = true;
                         break;
                     }
                 }
             }
             if ($defined_filter) {
                 $this->filters = $filters;
                 $this->filter($c, $this->getRequestParameter('filters'));
             }
         }
     }
     $rpp = $this->getRequestParameter('max_per_page', $this->getUser()->getAttribute('max_per_page', ParamsPeer::retrieveByCode('row_per_page')->getValue(), 'test'));
     $this->getUser()->setAttribute('max_per_page', $rpp, 'test');
     $pager = new sfPropelPager('TestSchedule', $rpp);
     $pager->setCriteria($c);
     $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'test'));
     $this->getUser()->setAttribute('page', $page, 'test');
     $pager->setPage($page);
     $pager->init();
     $this->pager = $pager;
     $actions = array(array('name' => 'filter', 'color' => 'white'));
     $filter_string = "";
     if ($this->filters) {
         foreach ($this->filters as $key => $val) {
             $filter_string .= "&filters[{$key}]={$val}";
         }
         $filter_string = preg_replace('/^&/', '', $filter_string);
     }
     array_unshift($actions, array('name' => 'back', 'url' => 'reg_period/listTest?id=' . $reg_period->getId(), 'color' => 'black'));
     array_unshift($actions, array('name' => 'add', 'url' => 'locate_test/create?test_id=' . $reg_test_period->getId(), 'color' => 'black'));
     $this->actions = $actions;
     $this->reg_test_period = $reg_test_period;
     $this->reg_period = $reg_period;
     $this->subtitle = $reg_test_period->toString();
     $actions2 = array(array('name' => '<span>Jadwal Test</span>', 'url' => 'reg_period/listTest?id=' . $reg_test_period->getRegPeriodId(), 'color' => 'sky'));
     array_push($actions2, array('name' => '<span>Detail Jadwal</span>', 'url' => 'reg_schedule_test/list?id=' . $reg_test_period->getId() . '&reg_period_id=' . $reg_test_period->getRegPeriodId(), 'color' => 'sky'));
     array_push($actions2, array('name' => '<span>Daftar Ruangan Test</span>', 'url' => 'locate_test/list?id=' . $reg_test_period->getId(), 'color' => 'sun', 'type' => 'direct'));
     $this->actions2 = $actions2;
 }