### Eclipse Workspace Patch 1.0 #P ocs-base Index: plugins/reports/registrants/RegistrantReportDAO.inc.php =================================================================== RCS file: /cvs/ocs2/plugins/reports/registrants/RegistrantReportDAO.inc.php,v retrieving revision 1.3 diff -u -r1.3 RegistrantReportDAO.inc.php --- plugins/reports/registrants/RegistrantReportDAO.inc.php 2 Jul 2008 16:55:25 -0000 1.3 +++ plugins/reports/registrants/RegistrantReportDAO.inc.php 3 Nov 2008 15:23:25 -0000 @@ -22,12 +22,13 @@ * @param $schedConfId int * @return array */ - function &getRegistrantReport($conferenceId, $schedConfId) { + function getRegistrantReport($conferenceId, $schedConfId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve( 'SELECT + r.registration_id AS registration_id, r.user_id AS userid, u.username AS uname, u.first_name AS fname, @@ -62,8 +63,30 @@ ) ); - $returner =& new DBRowIterator($result); - return $returner; + // prepare an iterator of all the registration information + $registrationReturner =& new DBRowIterator($result); + + $result =& $this->retrieve( + 'SELECT + r.registration_id as registration_id, + roa.option_id as option_id + FROM + registrations r + LEFT JOIN registration_option_assoc roa ON (r.registration_id = roa.registration_id) + WHERE + r.sched_conf_id= ?', + $schedConfId + ); + + // Prepare an array of registration Options by registration Id + $registrationOptionDAO =& DAORegistry::getDAO('RegistrationOptionDAO'); + $iterator =& new DBRowIterator($result); + while ($row =& $iterator->next()) { + $registrationId = $row['registration_id']; + $registrationOptionReturner[$registrationId] =& $registrationOptionDAO->getRegistrationOptions($registrationId); + } + + return array($registrationReturner, $registrationOptionReturner); } } Index: plugins/reports/registrants/RegistrantReportPlugin.inc.php =================================================================== RCS file: /cvs/ocs2/plugins/reports/registrants/RegistrantReportPlugin.inc.php,v retrieving revision 1.4 diff -u -r1.4 RegistrantReportPlugin.inc.php --- plugins/reports/registrants/RegistrantReportPlugin.inc.php 2 Jul 2008 16:55:25 -0000 1.4 +++ plugins/reports/registrants/RegistrantReportPlugin.inc.php 3 Nov 2008 15:23:25 -0000 @@ -60,11 +60,11 @@ header('content-disposition: attachment; filename=report.csv'); $registrantReportDao =& DAORegistry::getDAO('RegistrantReportDAO'); - $iterator =& $registrantReportDao->getRegistrantReport( + list($registrants, $registrantOptions) = $registrantReportDao->getRegistrantReport( $conference->getConferenceId(), $schedConf->getSchedConfId() ); - + $columns = array( 'userid' => Locale::translate('plugins.reports.registrants.userid'), 'uname' => Locale::translate('user.username'), @@ -78,24 +78,64 @@ 'fax' => Locale::translate('user.fax'), 'address' => Locale::translate('common.mailingAddress'), 'country' => Locale::translate('common.country'), - 'type' => Locale::translate('manager.registration.registrationType'), + 'type' => Locale::translate('manager.registration.registrationType') + ); + + $registrationOptionDAO =& DAORegistry::getDAO('RegistrationOptionDAO'); + $registrationOptions =& $registrationOptionDAO->getRegistrationOptionsBySchedConfId($schedConf->getSchedConfId()); + + // column name = 'option' + optionId => column value = name of the registration option + while ($registrationOption =& $registrationOptions->next()) { + $registrationOptionIds[] = $registrationOption->getOptionId(); + $columns = array_merge($columns, array('option' . $registrationOption->getOptionId() => $registrationOption->getRegistrationOptionName())); + unset($registrationOption); + } + + $columns = array_merge($columns, array( 'regdate' => Locale::translate('manager.registration.dateRegistered'), 'paiddate' => Locale::translate('manager.registration.datePaid'), 'specialreq' => Locale::translate('schedConf.registration.specialRequests') - ); + )); + $fp = fopen('php://output', 'wt'); String::fputcsv($fp, array_values($columns)); - while ($row =& $iterator->next()) { + while ($row =& $registrants->next()) { + if ( isset($registrantOptions[$row['registration_id']]) ) { + $options = $this->mergeRegistrantOptions($registrationOptionIds, $registrantOptions[$row['registration_id']]); + } else { + $options = $this->mergeRegistrantOptions($registrationOptionIds); + } + foreach ($columns as $index => $junk) { - $columns[$index] = $row[$index]; + if (isset($row[$index])) { + $columns[$index] = $row[$index]; + } else if (isset($options[$index])) { + $columns[$index] = $options[$index]; + } else $columns[$index] = ''; } + String::fputcsv($fp, $columns); unset($row); } fclose($fp); } + + + /** + * Make a single array of "Yes"/"No" for each option id + * @param $registrationOptionIds array list of Option Ids for a given schedConfId + * @param $registrantOptions array list of Option Ids for a given Registrant + * @return array + */ + function mergeRegistrantOptions($registrationOptionIds, $registrantOptions = array()) { + $returner = array(); + foreach ( $registrationOptionIds as $id ) { + $returner['option'. $id] = ( in_array($id, $registrantOptions) )?Locale::translate('common.yes'):Locale::translate('common.no'); + } + return $returner; + } } ?>