Code Duplication    Length = 15-15 lines in 2 locations

core/db_classes/EE_Export.class.php 1 location

@@ 225-239 (lines=15) @@
222
	function report_attendees(){
223
		$attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( array( 'force_join' => array( 'State', 'Country' ) ) );
224
		$csv_data = array();
225
		foreach( $attendee_rows as $attendee_row ){
226
			$csv_row = array();
227
			foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
228
				if( $field_name == 'STA_ID' ){
229
					$state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' );
230
					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
231
				}elseif( $field_name == 'CNT_ISO' ){
232
					$country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' );
233
					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
234
				}else{
235
					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
236
				}
237
			}
238
			$csv_data[] = $csv_row;
239
		}
240
241
		$filename = $this->generate_filename ( 'contact-list-report' );
242

core/libraries/batch/JobHandlers/AttendeesReport.php 1 location

@@ 96-110 (lines=15) @@
93
					'limit' => array( $offset, $limit ),
94
					'force_join' => array( 'State', 'Country' ) ) );
95
		$csv_data = array();
96
		foreach( $attendee_rows as $attendee_row ){
97
			$csv_row = array();
98
			foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
99
				if( $field_name == 'STA_ID' ){
100
					$state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' );
101
					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
102
				}elseif( $field_name == 'CNT_ISO' ){
103
					$country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' );
104
					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
105
				}else{
106
					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
107
				}
108
			}
109
			$csv_data[] = $csv_row;
110
		}
111
		return $csv_data;
112
	}
113