From: <gem...@li...> - 2012-06-21 12:08:03
|
Revision: 776 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=776&view=rev Author: mennodekker Date: 2012-06-21 12:07:52 +0000 (Thu, 21 Jun 2012) Log Message: ----------- RespondentExport: sort tracks on start date Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Tracker/TrackerInterface.php trunk/library/classes/Gems/Tracker.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 10:00:46 UTC (rev 775) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 12:07:52 UTC (rev 776) @@ -489,7 +489,7 @@ $form->populate($request->getParams()); if ($request->isPost()) { - $export->render((array) $this->getRequest()->getParam('id'), $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); + $export->render((array) $data['gr2o_patient_nr'], $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); } } } Modified: trunk/library/classes/Gems/Tracker/TrackerInterface.php =================================================================== --- trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-06-21 10:00:46 UTC (rev 775) +++ trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-06-21 12:07:52 UTC (rev 776) @@ -130,6 +130,18 @@ * @return Gems_Tracker_RespondentTrack */ public function getRespondentTrack($respTrackData); + + /** + * Get all tracks for a respondent + * + * Specify the optional $order to sort other than on start date + * + * @param int $userId + * @param int $organizationId + * @param mixed $order The column(s) and direction to order by + * @return array of Gems_Tracker_RespondentTrack + */ + public function getRespondentTracks($userId, $organizationId, $order = array('gr2t_start_date')); /** * Load project specific model or general Gems model otherwise Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-06-21 10:00:46 UTC (rev 775) +++ trunk/library/classes/Gems/Tracker.php 2012-06-21 12:07:52 UTC (rev 776) @@ -337,30 +337,9 @@ { return $this->getTokenLibrary()->filter($tokenId); } - + /** * - * @param int $userId - * @param int $organizationId - * @return array of Gems_Tracker_RespondentTrack - */ - public function getRespondentTracks($userId, $organizationId) - { - $sql = "SELECT * - FROM gems__respondent2track INNER JOIN gems__reception_codes ON gr2t_reception_code = grc_id_reception_code - WHERE gr2t_id_user = ? AND gr2t_id_organization = ?"; - $rows = $this->db->fetchAll($sql, array($userId, $organizationId)); - $tracks = array(); - - foreach ($rows as $row) { - $tracks[$row['gr2t_id_respondent_track']] = $this->getRespondentTrack($row); - } - - return $tracks; - } - - /** - * * @param mixed $respTrackData Track id or array containing trackdata * @return Gems_Tracker_RespondentTrack */ @@ -380,6 +359,39 @@ } /** + * Get all tracks for a respondent + * + * Specify the optional $order to sort other than on start date + * + * @param int $userId + * @param int $organizationId + * @param mixed $order The column(s) and direction to order by + * @return array of Gems_Tracker_RespondentTrack + */ + public function getRespondentTracks($userId, $organizationId, $order = array('gr2t_start_date')) + { + /*$sql = "SELECT * + FROM gems__respondent2track INNER JOIN gems__reception_codes ON gr2t_reception_code = grc_id_reception_code + WHERE gr2t_id_user = ? AND gr2t_id_organization = ?"; + */ + $select = $this->db->select() + ->from('gems__respondent2track') + ->joinInner('gems__reception_codes', 'gr2t_reception_code = grc_id_reception_code') + ->where('gr2t_id_user = ? AND gr2t_id_organization = ?'); + if (!is_null($order)) { + $select->order($order); + } + $rows = $this->db->fetchAll($select, array($userId, $organizationId)); + $tracks = array(); + + foreach ($rows as $row) { + $tracks[$row['gr2t_id_respondent_track']] = $this->getRespondentTrack($row); + } + + return $tracks; + } + + /** * Returns a form to ask for a token * * @param mixed $args_array MUtil_Ra::args array for Form initiation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |