Index: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php |
— | — | @@ -17,6 +17,17 @@ |
18 | 18 | public function execute( $sub ) { |
19 | 19 | global $wgRequest, $wgOut, $wgUser, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers; |
20 | 20 | |
| 21 | + $showYear = array(); |
| 22 | + foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) { |
| 23 | + if ( $wgRequest->wasPosted() ) { |
| 24 | + $showYear[$fundraiser['id']] = $wgRequest->getCheck( 'toogle'.$fundraiser['id'] ); |
| 25 | + } else { |
| 26 | + $showYear[$fundraiser['id']] = true; |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + $this->timezone = $wgRequest->getText( 'timezone', '+0:00' ); |
| 31 | + |
21 | 32 | /* Configuration (this isn't totally static data, some of it gets built on the fly) */ |
22 | 33 | |
23 | 34 | $charts = array( |
— | — | @@ -101,9 +112,25 @@ |
102 | 113 | if ( !isset( $charts[$name]['data'][$column] ) ) { |
103 | 114 | $charts[$name]['data'][$column] = ''; |
104 | 115 | } |
| 116 | + |
| 117 | + // Add spacer between days |
| 118 | + if ( $fundraiserIndex == 0 ) { |
| 119 | + $attributes = array( |
| 120 | + 'style' => 'height:1px', |
| 121 | + 'class' => 'fundraiserstats-bar-space' |
| 122 | + ); |
| 123 | + $charts[$name]['data'][$column] .= Xml::tags( |
| 124 | + 'td', array( 'valign' => 'bottom' ), Xml::element( 'div', $attributes, '', false ) |
| 125 | + ); |
| 126 | + } |
| 127 | + |
105 | 128 | $height = $chart['factor'] * $day[$chart['index']]; |
| 129 | + $style = "height:{$height}px;"; |
| 130 | + if ( $showYear[$fundraiser['id']] !== true ) { |
| 131 | + $style .= "display:none;"; |
| 132 | + } |
106 | 133 | $attributes = array( |
107 | | - 'style' => "height:{$height}px", |
| 134 | + 'style' => $style, |
108 | 135 | 'class' => "fundraiserstats-bar fundraiserstats-bar-{$fundraiser['id']}", |
109 | 136 | 'rel' => "fundraiserstats-view-box-{$view}", |
110 | 137 | ); |
— | — | @@ -162,6 +189,27 @@ |
163 | 190 | } |
164 | 191 | } |
165 | 192 | } |
| 193 | + |
| 194 | + $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'configtoggle' ) ) ); |
| 195 | + $wgOut->addHTML( '<a id="customize-chart">Customize</a>' ); |
| 196 | + $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
| 197 | + |
| 198 | + $wgOut->addHTML( Xml::openElement( 'form', array( 'method' => 'post', 'id' => 'configform' ) ) ); |
| 199 | + |
| 200 | + $years = 'Show the following years:<br/>'; |
| 201 | + foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) { |
| 202 | + $years .= Xml::check( 'toogle'.$fundraiser['id'], $showYear[$fundraiser['id']], array( 'id' => 'bar-'.$fundraiser['id'], 'class' => 'yeartoggle' ) ); |
| 203 | + $years .= Xml::label( $fundraiser['id'], 'toogle'.$fundraiser['id'] ); |
| 204 | + $years .= "<br/>"; |
| 205 | + } |
| 206 | + $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'configholder' ) ) ); |
| 207 | + $wgOut->addHTML( $years ); |
| 208 | + $wgOut->addHTML( 'Time Zone:<br/>' ); |
| 209 | + $wgOut->addHTML( ' '.Xml::listDropDown( 'timezone', $this->dropDownList( range ( -12, 14, 1 ) ), '', $this->timezone, '', 1 ).' (from UTC)' ); |
| 210 | + $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
| 211 | + |
| 212 | + $wgOut->addHTML( Xml::closeElement( 'form' ) ); |
| 213 | + |
166 | 214 | // Instructions |
167 | 215 | $wgOut->addWikiMsg( 'fundraiserstats-instructions' ); |
168 | 216 | |
— | — | @@ -236,7 +284,7 @@ |
237 | 285 | case 'dailyTotals': |
238 | 286 | $select = $dbr->select( 'public_reporting', |
239 | 287 | array( |
240 | | - "FROM_UNIXTIME(received, '%Y-%m-%d')", |
| 288 | + "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')", |
241 | 289 | 'sum(converted_amount)', |
242 | 290 | 'count(*)', |
243 | 291 | 'avg(converted_amount)', |
— | — | @@ -246,7 +294,7 @@ |
247 | 295 | __METHOD__, |
248 | 296 | array( |
249 | 297 | 'ORDER BY' => 'received', |
250 | | - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')" |
| 298 | + 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')" |
251 | 299 | ) |
252 | 300 | ); |
253 | 301 | $result = array(); |
— | — | @@ -263,7 +311,7 @@ |
264 | 312 | __METHOD__, |
265 | 313 | array( |
266 | 314 | 'ORDER BY' => 'sum DESC', |
267 | | - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')", |
| 315 | + 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')" |
268 | 316 | ) |
269 | 317 | ); |
270 | 318 | break; |
— | — | @@ -281,7 +329,7 @@ |
282 | 330 | __METHOD__, |
283 | 331 | array( |
284 | 332 | 'ORDER BY' => 'sum DESC', |
285 | | - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')", |
| 333 | + 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')" |
286 | 334 | ) |
287 | 335 | ); |
288 | 336 | break; |
— | — | @@ -292,7 +340,7 @@ |
293 | 341 | __METHOD__, |
294 | 342 | array( |
295 | 343 | 'ORDER BY' => 'sum DESC', |
296 | | - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')", |
| 344 | + 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')" |
297 | 345 | ) |
298 | 346 | ); |
299 | 347 | break; |
— | — | @@ -303,7 +351,7 @@ |
304 | 352 | __METHOD__, |
305 | 353 | array( |
306 | 354 | 'ORDER BY' => 'sum DESC', |
307 | | - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')", |
| 355 | + 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')" |
308 | 356 | ) |
309 | 357 | ); |
310 | 358 | break; |
— | — | @@ -314,4 +362,13 @@ |
315 | 363 | } |
316 | 364 | return null; |
317 | 365 | } |
| 366 | + |
| 367 | + private function dropDownList ( $values ) { |
| 368 | + $dropDown = ''; |
| 369 | + foreach ( $values as $value ) { |
| 370 | + if ( $value >= 0 ) $dropDown .= '+'; |
| 371 | + $dropDown .= "$value:00\n"; |
| 372 | + } |
| 373 | + return $dropDown; |
| 374 | + } |
318 | 375 | } |
Index: trunk/extensions/ContributionReporting/FundraiserStatistics.css |
— | — | @@ -1,3 +1,33 @@ |
| 2 | +div#configholder { |
| 3 | + position: absolute; |
| 4 | + top: 22px; |
| 5 | + right: 0; |
| 6 | + z-index: 200; |
| 7 | + width: 180px; |
| 8 | + border: 1px solid silver; |
| 9 | + background-color: white; |
| 10 | + padding: 2px 5px 5px 5px; |
| 11 | + display: none; |
| 12 | +} |
| 13 | +div#configtoggle { |
| 14 | + position: absolute; |
| 15 | + top: 0; |
| 16 | + right: 0; |
| 17 | + z-index: 199; |
| 18 | + height: 17px; |
| 19 | + border: 1px solid silver; |
| 20 | + background-color: white; |
| 21 | + padding: 2px 5px 2px 0px; |
| 22 | + cursor: pointer; |
| 23 | +} |
| 24 | +div#configtoggle a, div#configtoggle a:visited { |
| 25 | + background-image: url("arrow.png"); |
| 26 | + background-position: 0px -3px; |
| 27 | + background-repeat: no-repeat; |
| 28 | + padding-left: 16px; |
| 29 | + outline: 0; |
| 30 | +} |
| 31 | + |
2 | 32 | .fundraiserstats-view-box { |
3 | 33 | border: solid 1px silver; |
4 | 34 | } |
— | — | @@ -13,29 +43,27 @@ |
14 | 44 | margin-top: 3px; |
15 | 45 | margin-left: -1px; |
16 | 46 | } |
| 47 | +.fundraiserstats-bar { |
| 48 | + width: 2px; |
| 49 | +} |
17 | 50 | .fundraiserstats-bar-2007 { |
18 | 51 | background-color: #AAAAFF; |
19 | 52 | border: outset 1px #AAAAFF; |
20 | | - width: 2px; |
21 | | - margin-left: 3px; |
22 | 53 | } |
23 | 54 | .fundraiserstats-bar-2008 { |
24 | 55 | background-color: #AAFFAA; |
25 | 56 | border: outset 1px #AAFFAA; |
26 | | - width: 2px; |
27 | 57 | } |
28 | 58 | .fundraiserstats-bar-2009 { |
29 | 59 | background-color: #FFAAAA; |
30 | 60 | border: outset 1px #FFAAAA; |
31 | | - width: 2px; |
32 | 61 | } |
33 | 62 | .fundraiserstats-bar-2010 { |
34 | 63 | background-color: #FF0000; |
35 | 64 | border: outset 1px #FF0000; |
36 | | - width: 2px; |
37 | 65 | } |
38 | 66 | .fundraiserstats-bar-space { |
39 | | - width: 2px; |
| 67 | + width: 3px; |
40 | 68 | } |
41 | 69 | .fundraiserstats-chart { |
42 | 70 | padding: 10px; |
Index: trunk/extensions/ContributionReporting/FundraiserStatistics.js |
— | — | @@ -33,4 +33,19 @@ |
34 | 34 | $j( '.fundraiserstats-current' ).each( function() { |
35 | 35 | replaceView( $j(this).attr( 'rel' ) ) |
36 | 36 | } ); |
| 37 | + $j( '#configholder .yeartoggle' ).click( function() { |
| 38 | + $j('.fundraiserstats-'+$j(this).attr( 'id' )).toggle(); |
| 39 | + } ); |
| 40 | + $j( '#configtoggle' ).click( function() { |
| 41 | + $j('#configholder').toggle(); |
| 42 | + if ($j( '#configtoggle a' ).css( 'background-position' ) == '0px -18px') { |
| 43 | + $j( '#configtoggle a' ).css( 'background-position', '0px -3px' ); |
| 44 | + } else { |
| 45 | + $j( '#configtoggle a' ).css( 'background-position','0px -18px' ); |
| 46 | + } |
| 47 | + } ); |
| 48 | + $j( '#timezone' ).change( function() { |
| 49 | + $j('#configform').submit(); |
| 50 | + } ); |
| 51 | + |
37 | 52 | } ); |