Skip to content
Snippets Groups Projects
Commit 00a5bae5 authored by Tim Steiner's avatar Tim Steiner
Browse files

Order requests by course code in Requests.php functions

parent 8fb6670c
Branches
Tags
No related merge requests found
......@@ -25,13 +25,39 @@ class Requests extends Nmc_Db_Table {
public function getRequestsForUser(Person $user)
{
$usersTable = Users::getInstance();
$usersPrimaryKey = $usersTable->getPrimaryKeyName();
$inflector = new Zend_Db_Inflector();
$usersPrimaryKey = $inflector->camelize($usersPrimaryKey);
$db = $this->getAdapter();
$where = $db->quoteInto('owner = ?', $user->getPrimaryKey());
$requests = $this->fetchAllSorted($where);
return $requests;
}
public function fetchAllSorted($where = null)
{
$db = $this->getAdapter();
$rq = $this->getTableName();
$cg = CourseGenerations::getInstance()->getTableName();
$cx = CourseCrosslistings::getInstance()->getTableName();
$cc = CourseCodes::getInstance()->getTableName();
$select = $db->select();
$select->from($rq, '*');
$select->join($cg, $rq . '.' . $this->getPrimaryKeyName() . ' = ' . $cg . '.request');
$select->join($cx, $cg . '.' . CourseGenerations::getInstance()->getPrimaryKeyName() . ' = ' . $cx . '.generation');
$select->join($cc, $cx . '.course_code = ' . $cc . '.' . CourseCodes::getInstance()->getPrimaryKeyName());
$select->where($cx . ".type = 'home listing'");
if ($where) {
$select->where($where);
}
$select->order('subject, course_number, course_letter');
$data = $db->fetchAll($select);
$config['db'] = $db;
$config['table'] = $this;
$config['data'] = $data;
$requests = new Nmc_Db_Table_Rowset($config);
$where = $this->_db->quoteInto('owner = ?', $user->$usersPrimaryKey);
$requests = $this->fetchAll($where);
return $requests;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment