Exemplo n.º 1
0
 /**
  * 
  * Enter description here ...
  * @param Acad_Model_Course_Subject $subject
  * @param Date $dateFrom
  * @param Date $dateUpto
  * @param string $status
  * @param string $group_id
  * @param string $subject_mode_id
  * @param int $maxAbsent Maximum limit of absentism (It means minimum present)
  * @param int $minAbsent Minimum limit of absentism (maximum present count)
  */
 public function fetchStudentAttendance(Acad_Model_Course_Subject $subject, $dateFrom = NULL, $dateUpto = NULL, $status = NULL, $group_id = NULL, $maxAbsent = NULL, $minAbsent = NULL, $coditionalMode = NULL)
 {
     $subject_code = $subject->getSubject_code();
     $department = $subject->getDepartment_id();
     $groupByCols = array('department_id', 'programme_id', 'semester_id', 'group_id', 'subject_code', 'subject_mode_id', 'student_roll_no', 'status');
     $orderByCols = array('programme_id ASC', 'semester_id ASC', 'subject_code ASC', 'subject_mode_id ASC', 'group_id ASC', 'student_roll_no ASC', 'status ASC');
     $select = $this->getDbTable()->getAdapter()->select()->from('vw_student_attendance', array('subject_mode_id', 'student_roll_no', 'status', 'counts' => 'COUNT(student_roll_no)'))->where('subject_code = ?', $subject_code)->where('student_roll_no IS NOT NULL')->group($groupByCols)->order($orderByCols);
     if ($department) {
         $select->where('department_id = ?', $department);
     }
     if ($dateFrom) {
         $date = new Zend_Date($dateFrom);
         $select->where('period_date >= ?', $date->get(Zend_Date::ISO_8601));
     }
     if ($dateUpto) {
         $date = new Zend_Date($dateUpto);
         $select->where('period_date <= ?', $date->get(Zend_Date::ISO_8601));
     }
     if ($status) {
         $select->where('status = ?', $status);
     }
     if ($group_id) {
         $select->where('group_id = ?', $group_id);
     } else {
         $select->columns('group_id');
     }
     if ($maxAbsent) {
         $select->having('counts <= ?', $maxAbsent);
     }
     if ($minAbsent) {
         $select->having('counts >= ?', $minAbsent);
     }
     if (is_string($coditionalMode) and $coditionalMode) {
         $select->where('subject_mode_id = ?', $coditionalMode);
     } else {
         $modeString = self::_subjectModeQuery($subject);
         $select->where($modeString);
     }
     return $select->query()->fetchAll(Zend_Db::FETCH_GROUP);
 }