Index: trunk/extensions/ContributionReporting/ContributionReporting.i18n.php |
— | — | @@ -52,6 +52,11 @@ |
53 | 53 | |
54 | 54 | // Fundraiser statistics |
55 | 55 | 'fundraiserstatistics' => 'Fundraiser statistics', |
| 56 | + 'fundraiserstats-date' => 'Date', |
| 57 | + 'fundraiserstats-total' => 'Total (USD)', |
| 58 | + 'fundraiserstats-avg' => 'Average (USD)', |
| 59 | + 'fundraiserstats-min' => 'Minimum (USD)', |
| 60 | + 'fundraiserstats-max' => 'Maximum (USD)', |
56 | 61 | ); |
57 | 62 | |
58 | 63 | /** Message documentation (Message documentation) |
Index: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php |
— | — | @@ -26,7 +26,30 @@ |
27 | 27 | // Begin output |
28 | 28 | $this->setHeaders(); |
29 | 29 | |
30 | | - $htmlOut = Xml::openElement( 'div', array( 'style' => 'margin-bottom: 10px;' ) ); |
| 30 | + $style = <<<END |
| 31 | +.fundraiserstats-view-box { |
| 32 | + width: 100%; |
| 33 | + height: 200px; |
| 34 | + margin-top:20px; |
| 35 | + border: solid 1px silver; |
| 36 | +} |
| 37 | + |
| 38 | +END; |
| 39 | + $script = <<<END |
| 40 | +var currentLayerID = 'fundraiserstats-view-box-0'; |
| 41 | +function replaceView( newLayerID ) { |
| 42 | + var currentLayer = document.getElementById( currentLayerID ); |
| 43 | + currentLayer.style.display = 'none'; |
| 44 | + var newLayer = document.getElementById( newLayerID ); |
| 45 | + newLayer.style.display = 'block'; |
| 46 | + currentLayerID = newLayerID; |
| 47 | +} |
| 48 | +END; |
| 49 | + |
| 50 | + $htmlOut = Xml::element( 'style', array( 'type' => 'text/css' ), $style ); |
| 51 | + $htmlOut .= Xml::element( 'script', array( 'type' => 'text/javascript' ), $script ); |
| 52 | + |
| 53 | + $htmlOut .= Xml::openElement( 'div', array( 'style' => 'margin-bottom: 20px;' ) ); |
31 | 54 | $today = strtotime( date( 'M j Y' ) ); |
32 | 55 | |
33 | 56 | $max = 0; |
— | — | @@ -34,13 +57,15 @@ |
35 | 58 | $days = $this->getDailyTotals( $fundraiser['start'], $fundraiser['end'] ); |
36 | 59 | // Determine maximimum for fundraiser |
37 | 60 | foreach ( $days as $day ) { |
38 | | - if ( $day[0] > $max ) { |
39 | | - $max = $day[0]; |
| 61 | + if ( $day[1] > $max ) { |
| 62 | + $max = $day[1]; |
40 | 63 | } |
41 | 64 | } |
42 | 65 | } |
43 | 66 | |
44 | 67 | $columns = array(); |
| 68 | + $views = array(); |
| 69 | + $view = 0; |
45 | 70 | foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) { |
46 | 71 | $htmlOut .= Xml::element( 'span', |
47 | 72 | array( |
— | — | @@ -64,7 +89,7 @@ |
65 | 90 | // Build columns |
66 | 91 | $column = 0; |
67 | 92 | foreach( $days as $day ) { |
68 | | - $height = ( 200 / $max ) * $day[0]; |
| 93 | + $height = ( 200 / $max ) * $day[1]; |
69 | 94 | if ( !isset( $columns[$column] ) ) { |
70 | 95 | $columns[$column] = ''; |
71 | 96 | } |
— | — | @@ -81,12 +106,55 @@ |
82 | 107 | ); |
83 | 108 | } |
84 | 109 | $columns[$column] .= Xml::tags( 'td', array( 'valign' => 'bottom' ), |
85 | | - Xml::element( 'div', array( 'style' => $style ), '', false ) . $extra |
| 110 | + Xml::element( 'div', |
| 111 | + array( |
| 112 | + 'style' => $style, |
| 113 | + 'onMouseOver' => "replaceView( 'fundraiserstats-view-box-{$view}' )" |
| 114 | + ), |
| 115 | + '', |
| 116 | + false |
| 117 | + ) . $extra |
86 | 118 | ); |
| 119 | + |
| 120 | + $viewHTML = Xml::openElement( 'table', |
| 121 | + array( |
| 122 | + 'cellpadding' => 5, |
| 123 | + 'cellspacing' => 0, |
| 124 | + 'border' => 0, |
| 125 | + 'style' => 'margin:10px' |
| 126 | + ) |
| 127 | + ); |
| 128 | + $viewHTML .= Xml::tags( 'tr', null, |
| 129 | + Xml::element( 'td', null, wfMsg( 'fundraiserstats-date' ) ) . |
| 130 | + Xml::element( 'td', null, $day[0] ) |
| 131 | + ); |
| 132 | + $viewHTML .= Xml::tags( 'tr', null, |
| 133 | + Xml::element( 'td', null, wfMsg( 'fundraiserstats-total' ) ) . |
| 134 | + Xml::element( 'td', null, $day[1] ) |
| 135 | + ); |
| 136 | + $viewHTML .= Xml::tags( 'tr', null, |
| 137 | + Xml::element( 'td', null, wfMsg( 'fundraiserstats-avg' ) ) . |
| 138 | + Xml::element( 'td', null, $day[2] ) |
| 139 | + ); |
| 140 | + $viewHTML .= Xml::tags( 'tr', null, |
| 141 | + Xml::element( 'td', null, wfMsg( 'fundraiserstats-max' ) ) . |
| 142 | + Xml::element( 'td', null, $day[3] ) |
| 143 | + ); |
| 144 | + $viewHTML .= Xml::closeElement( 'table' ); |
| 145 | + |
| 146 | + $views[$day[1]] = Xml::tags( 'div', |
| 147 | + array( |
| 148 | + 'id' => 'fundraiserstats-view-box-' . $view, |
| 149 | + 'class' => 'fundraiserstats-view-box', |
| 150 | + 'style' => 'display: ' . ( $view == 0 ? 'block' : 'none' ) |
| 151 | + ), |
| 152 | + $viewHTML |
| 153 | + ); |
| 154 | + |
87 | 155 | $column++; |
| 156 | + $view++; |
88 | 157 | } |
89 | 158 | } |
90 | | - |
91 | 159 | $htmlOut .= Xml::closeElement( 'div' ); |
92 | 160 | |
93 | 161 | // Show bar graph |
— | — | @@ -98,14 +166,35 @@ |
99 | 167 | ) |
100 | 168 | ); |
101 | 169 | $htmlOut .= Xml::openElement( 'tr' ); |
102 | | - foreach( $columns as $column ) { |
| 170 | + $htmlOut .= Xml::openElement( 'td' ); |
| 171 | + $htmlOut .= Xml::openElement( 'table', |
| 172 | + array( |
| 173 | + 'cellpadding' => 0, |
| 174 | + 'cellspacing' => 0, |
| 175 | + 'border' => 0 |
| 176 | + ) |
| 177 | + ); |
| 178 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 179 | + foreach( $columns as $i => $column ) { |
103 | 180 | $htmlOut .= $column; |
104 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'bottom' ), |
105 | | - Xml::element( 'div', array( 'style' => "width:4px;" ), '', false ) |
106 | | - ); |
| 181 | + if ( $i < count( $columns ) - 1 ) { |
| 182 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'bottom' ), |
| 183 | + Xml::element( 'div', array( 'style' => "width:4px;" ), '', false ) |
| 184 | + ); |
| 185 | + } |
107 | 186 | } |
108 | 187 | $htmlOut .= Xml::closeElement( 'tr' ); |
109 | 188 | $htmlOut .= Xml::closeElement( 'table' ); |
| 189 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 190 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 191 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 192 | + $htmlOut .= Xml::openElement( 'td' ); |
| 193 | + foreach( $views as $view ) { |
| 194 | + $htmlOut .= $view; |
| 195 | + } |
| 196 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 197 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 198 | + $htmlOut .= Xml::closeElement( 'table' ); |
110 | 199 | |
111 | 200 | $wgOut->addHTML( $htmlOut ); |
112 | 201 | } |
— | — | @@ -122,8 +211,10 @@ |
123 | 212 | // Select sums and dates of contributions grouped by day |
124 | 213 | $res = $dbr->select( 'public_reporting', |
125 | 214 | array( |
| 215 | + "FROM_UNIXTIME(received, '%Y-%m-%d')", |
126 | 216 | 'sum(converted_amount)', |
127 | | - "FROM_UNIXTIME(received, '%Y-%m-%d')" |
| 217 | + 'avg(converted_amount)', |
| 218 | + 'max(converted_amount)', |
128 | 219 | ), |
129 | 220 | array_merge( |
130 | 221 | array( |