Breakfast suggestive sells fell from 42.1 percent last year, while they were offered at a full 15 percent more locations during late night this year over last.
array( 'sort_dir' => 'asc', 'indicator' => '', 'label' => 'Daypart', ), 'percent_offered' => array( 'sort_dir' => 'asc', 'indicator' => '', 'label' => 'Percent Offered', ), 'count_offered' => array( 'sort_dir' => 'asc', 'indicator' => '', 'label' => 'Count Offered', ), ); if ( isset( $_GET['sort'] ) && in_array( $_GET['sort'], array_keys( $headers ) ) ) { $sort_field = $_GET['sort']; } else { $sort_field = 'day_part'; } if ( isset( $_GET['dir'] ) && in_array( $_GET['dir'], array( 'asc', 'desc' ) ) ) { $sort_dir = $_GET['dir']; } else { $sort_dir = 'asc'; } $opposite_dir = ( $sort_dir == 'asc' ) ? 'desc' : 'asc'; $headers[$sort_field]['sort_dir'] = $opposite_dir; $headers[$sort_field]['indicator'] = theme_tablesort_indicator( array( 'style' => $sort_dir ) ); $header_cols = array(); foreach ( $headers as $field => $field_data ) { $header_cols[] = array( 'data' => l( $field_data['label'], $_GET['q'], array( 'query' => array( 'sort' => $field, 'dir' => $field_data['sort_dir'] ) ) ) . $field_data['indicator'], 'class' => 'header', ); } $table_rows = array(); $table_rows[] = $header_cols; /* begin of function area */ $sorted_data = array(); $values = array(); foreach ( $the_data as $id => $value ) { $values[$id] = $value->$sort_field; } if ( $sort_field == 'day_part' ) { uasort( $values, function ( $a, $b ) { $v = array( 'breakfast' => 1, 'lunch' => 2, 'snack' => 3, 'dinner' => 4, 'late night' => 5, ); $an = $v[strtolower( $a )]; $bn = $v[strtolower( $b )]; return ( $an $value ) { $data_cells = array(); foreach ( $headers as $field => $field_data ) { $cell_data = $the_data[$key]->$field; if ( $field == 'count_offered' ) { $cell_data = number_format( $cell_data ); } if ( $field == 'percent_offered' ) { $cell_data = number_format( $cell_data, 1 ) . '%'; } $classes = $field; if ( $field == $sort_field ) { $classes .= ' sorted'; } if( $key == 5 ) { $classes .= ' total-row'; } $data_cells[] = array( 'data' => $cell_data, 'class' => $classes ); } if($key != 5) { $table_rows[] = $data_cells; } else { $sum = $data_cells; } } $table_rows[] = $sum; /* end of functional area */ print theme( 'table', array( 'header' => array(), 'rows' => $table_rows, 'attributes' => array( 'id' => 'datatable' ) ) ); ?>