plugins/reports/registrants/RegistrantReportPlugin.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import('classes.plugins.ReportPlugin');
00019 
00020 class RegistrantReportPlugin extends ReportPlugin {
00027    function register($category, $path) {
00028       $success = parent::register($category, $path);
00029       if ($success) {
00030          $this->import('RegistrantReportDAO');
00031          $registrantReportDAO = new RegistrantReportDAO();
00032          DAORegistry::registerDAO('RegistrantReportDAO', $registrantReportDAO);
00033       }
00034       $this->addLocaleData();
00035       return $success;
00036    }
00037 
00043    function getName() {
00044       return 'RegistrantReportPlugin';
00045    }
00046 
00047    function getDisplayName() {
00048       return __('plugins.reports.registrants.displayName');
00049    }
00050 
00051    function getDescription() {
00052       return __('plugins.reports.registrants.description');
00053    }
00054 
00055    function display(&$args) {
00056       $conference =& Request::getConference();
00057       $schedConf =& Request::getSchedConf();
00058       AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_OCS_MANAGER));
00059 
00060       header('content-type: text/comma-separated-values; charset=utf-8');
00061       header('content-disposition: attachment; filename=report.csv');
00062 
00063       $registrantReportDao =& DAORegistry::getDAO('RegistrantReportDAO');
00064       list($registrants, $registrantOptions) = $registrantReportDao->getRegistrantReport(
00065          $conference->getId(),
00066          $schedConf->getId()
00067       );
00068             
00069       $columns = array(
00070          'userid' => __('plugins.reports.registrants.userid'),
00071          'uname' => __('user.username'),
00072          'fname' => __('user.firstName'),
00073          'mname' => __('user.middleName'),
00074          'lname' => __('user.lastName'),
00075          'affiliation' => __('user.affiliation'),
00076          'url' => __('user.url'),
00077          'email' => __('user.email'),
00078          'phone' => __('user.phone'),
00079          'fax' => __('user.fax'),
00080          'address' => __('common.mailingAddress'),
00081          'country' => __('common.country'),
00082          'type' => __('manager.registration.registrationType')
00083       );
00084       
00085       $registrationOptionDAO =& DAORegistry::getDAO('RegistrationOptionDAO');
00086       $registrationOptions =& $registrationOptionDAO->getRegistrationOptionsBySchedConfId($schedConf->getId());
00087       
00088       // column name = 'option' + optionId => column value = name of the registration option
00089       while ($registrationOption =& $registrationOptions->next()) {
00090          $registrationOptionIds[] = $registrationOption->getOptionId();
00091          $columns = array_merge($columns, array('option' . $registrationOption->getOptionId() => $registrationOption->getRegistrationOptionName()));
00092          unset($registrationOption);
00093       } 
00094       
00095       $columns = array_merge($columns, array(
00096          'regdate' => __('manager.registration.dateRegistered'),
00097          'paiddate' => __('manager.registration.datePaid'),
00098          'specialreq' => __('schedConf.registration.specialRequests')
00099          ));
00100 
00101 
00102       $fp = fopen('php://output', 'wt');
00103       String::fputcsv($fp, array_values($columns));
00104 
00105       while ($row =& $registrants->next()) {
00106          if ( isset($registrantOptions[$row['registration_id']]) ) { 
00107             $options = $this->mergeRegistrantOptions($registrationOptionIds, $registrantOptions[$row['registration_id']]);
00108          } else {
00109             $options = $this->mergeRegistrantOptions($registrationOptionIds);
00110          }
00111          
00112          foreach ($columns as $index => $junk) {
00113             if (isset($row[$index])) {
00114                $columns[$index] = $index == 'affiliation'?
00115                   html_entity_decode(strip_tags($row[$index]), ENT_QUOTES, 'UTF-8'):
00116                   $row[$index];
00117             } else if (isset($options[$index])) {
00118                $columns[$index] = $options[$index];
00119             } else $columns[$index] = '';
00120          }
00121          
00122          String::fputcsv($fp, $columns);
00123          unset($row);
00124       }
00125       fclose($fp);
00126    }
00127 
00128    
00135    function mergeRegistrantOptions($registrationOptionIds, $registrantOptions = array()) {
00136       $returner = array();
00137       foreach ( $registrationOptionIds as $id ) { 
00138          $returner['option'. $id] = ( in_array($id, $registrantOptions) )?__('common.yes'):__('common.no');
00139       }
00140       return $returner;
00141    }
00142 }
00143 
00144 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7