Example #1
0
 public function countVStudentCourses($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseVStudentCoursePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(VStudentCoursePeer::SUBJECT_CURR_ID, $this->getId());
     return VStudentCoursePeer::doCount($criteria, $distinct, $con);
 }
Example #2
0
 public function executeListByEmployee()
 {
     $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
     $employee = EmployeePeer::retrieveByPK($employee_id);
     $this->forward404Unless($employee);
     $counseling_id = $this->getRequestParameter('counseling_id');
     $counseling = CounselingPeer::retrieveByPK($counseling_id);
     $this->forward404Unless($counseling);
     $student_id = $this->getRequestParameter('student_id');
     $student = StudentPeer::retrieveByPK($student_id);
     $this->student = $student;
     $this->forward404Unless($student);
     $c = new Criteria();
     $c->add(VStudentCoursePeer::STUDENT_ID, $student->getId());
     $this->student = $student;
     $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(), 'student_course'));
     $this->getUser()->setAttribute('max_per_page', $rpp, 'student_course');
     $pager = new sfPropelPager('VStudentCourse', $rpp);
     $pager->setCriteria($c);
     $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'student_course'));
     $this->getUser()->setAttribute('page', $page, 'student_course');
     $pager->setPage($page);
     $pager->init();
     $this->pager = $pager;
     $actions = array(array('name' => 'filter', 'color' => 'white'));
     array_unshift($actions, array('name' => 'back', 'url' => 'counseling/listStudentByEmployee?counseling_id=' . $counseling->getId(), 'color' => 'black'));
     $filter_string = "";
     if ($this->filters) {
         foreach ($this->filters as $key => $val) {
             $filter_string .= "&filters[{$key}]={$val}";
         }
         $filter_string = preg_replace('/^&/', '', $filter_string);
     }
     $this->actions = $actions;
     $this->counseling_id = $counseling_id;
     // do we need to display bank_transfer_confirmation link?
     $c = new Criteria();
     $c->add(VStudentCoursePeer::STATUS, StudentCourse::STATUS_APPROVED);
     $this->approved_sc = VStudentCoursePeer::doCount($c) > 0;
 }