public function init() { $authInfo = Zend_Auth::getInstance()->getStorage()->read(); $this->department_id = $authInfo['department_id']; $this->view->assign('masterDepartment', $this->department_id); $slaves = Acad_Model_DbTable_SemesterDegree::slaveDepartment($this->department_id); $this->view->assign('slaveDepartment', $slaves); parent::init(); }
public function fillgridAction() { $request = $this->getRequest(); $valid = $request->getParam('nd'); $upcoming = $request->getParam('upcoming'); if ($valid) { $this->grid = $this->_helper->grid(); $slaves = Acad_Model_DbTable_SemesterDegree::slaveInfo($this->department_id); $where = ''; $setOr = false; foreach ($slaves as $num => $slave) { if ($setOr) { $where .= ' OR '; } $setAnd = false; $where .= ' ( `prd`.'; foreach ($slave as $column => $value) { if ($setAnd) { $where .= ' AND '; } $where .= $this->model->getAdapter()->quoteInto("{$column} = ?", $value); $setAnd = true; } $where .= ' ) '; $setOr = true; } $sql = Zend_Db_Table::getDefaultAdapter()->select()->from(array('prd' => 'period'), array('department_id', 'degree_id', 'semester_id', 'weekday_number', 'period_number'))->join(array('tt' => 'timetable'), '`prd`.period_id = `tt`.period_id', array('timetable_id', 'subject_code', 'subject_mode_id', 'group_id', 'staff_id', 'period_duration', 'periods_covered', 'valid_from', 'valid_upto', 'block_id', 'room_id')); if ($upcoming) { $sql->where('( `tt`.valid_from > CURDATE() AND CURDATE() < `tt`.valid_upto)'); } else { $sql->where('(CURDATE() BETWEEN `tt`.valid_from AND `tt`.valid_upto)'); } /* if ($this->debug) { $this->_helper->logger($where); }*/ if ($where) { $sql->where($where); } $searchOn = $request->getParam('_search'); if ($searchOn != 'false') { $sarr = $request->getParams(); foreach ($sarr as $key => $value) { switch ($key) { case 'department_id': $sql->where("prd.department_id LIKE ?", $value . '%'); break; case 'weekday_number': $sql->where("weekday_number LIKE ?", $value . '%'); break; case 'period_number': $sql->where("prd.period_number = ?", $value); break; case 'group_id': $sql->where("{$key} = ?", $value); break; case 'staff_id': $sql->where("first_name LIKE ?", $value . '%'); break; case 'semester_id': $sql->where("semester_id = ?", $value); break; case 'degree_id': case 'subject_code': case 'subject_mode_id': $sql->where("{$key} LIKE ?", $value . '%'); break; default: $this->_helper->logger("Search : key = {$key} and value = {$value}."); } } } $this->grid->sql = $sql; self::fillgridfinal(); } else { echo '<b>Oops!! </b><br/>No use of peeping like that.. :)'; } }