/** * Fetches Class Id * @param unknown_type $department_id * @param unknown_type $programme_id * @param unknown_type $semester_id */ public function fetchClassIds($department_id = null, $programme_id = null, $batch_id = null, $semester_id = null, $is_active = null) { $adapter = $this->getDbTable()->getAdapter(); $class_dbtable = $this->getDbTable(); $class_table = $class_dbtable->info('name'); $batch_dbTable = new Core_Model_DbTable_Batch(); $batch_table = $batch_dbTable->info('name'); $cond = $class_table . '.batch_id =' . $batch_table . '.batch_id'; $class_cols = array('class_id'); $select = $adapter->select()->from($class_table, $class_cols); if (isset($department_id)) { $select->where('department_id = ?', $department_id); } if (isset($programme_id)) { $select->where('programme_id = ?', $programme_id); } if (isset($semester_id)) { $select->where('semester_id = ?', $semester_id); } if (isset($batch_id)) { $select->where('batch_id = ?', $batch_id); } if (isset($is_active)) { $select->where('is_active = ?', $is_active); } $class_ids = array(); $class_ids = $select->query()->fetchAll(Zend_Db::FETCH_COLUMN); return $class_ids; }
/** * Get students of a given batch of a department's degree */ public function getbatchstudentAction() { $request = $this->getRequest(); $format = $request->getParam('format', 'json'); $department = $request->getParam('department_id'); $degree = $request->getParam('degree_id'); $batch = $request->getParam('batch_id'); if (isset($degree) and isset($department) and isset($batch)) { $result = Core_Model_DbTable_Batch::getBatchStudent($department, $degree, $batch); switch (strtolower($format)) { case 'json': $this->_helper->json($result); return; case 'select': echo '<select>'; echo '<option>Select one</option>'; foreach ($result as $key => $row) { echo '<option value="' . $row['batch_start'] . '">' . $row['batch_start'] . '</option>'; } echo '</select>'; return; default: $this->getResponse()->setException('Unsupported format request')->setHttpResponseCode(400); } } else { $this->getResponse()->setException('Valid parameters are required')->setHttpResponseCode(400); } }