Changeset View
Changeset View
Standalone View
Standalone View
fundraisers/yearend2016/index.php
Show All 12 Lines | 11 | $pageConfig = array_merge($pageConfig, [ | |||
---|---|---|---|---|---|
13 | 'cssFile' => '/css/announce.css' | 13 | 'cssFile' => '/css/announce.css' | ||
14 | ]); | 14 | ]); | ||
15 | 15 | | |||
16 | require('../../aether/header.php'); | 16 | require('../../aether/header.php'); | ||
17 | $site_root = "../../"; | 17 | $site_root = "../../"; | ||
18 | 18 | | |||
19 | require("donations_auth.inc"); | 19 | require("donations_auth.inc"); | ||
20 | 20 | | |||
21 | $countStmt = $dbConnection->prepare("SELECT COUNT(*) FROM yearend2016donations ORDER BY CREATED_AT DESC;"); | ||||
22 | $countStmt->execute(); | ||||
23 | $n = $countStmt->fetchColumn(); | ||||
24 | | ||||
25 | $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM yearend2016donations ORDER BY CREATED_AT DESC;"); | ||||
21 | $query = "select count(*) from yearend2016donations;"; | 26 | $query = "select count(*) from yearend2016donations;"; | ||
22 | $q = mysql_query($query,$sq); | 27 | | ||
ognarb: query not used | |||||
23 | echo mysql_error(); | | |||
24 | $row = mysql_fetch_array($q); | | |||
25 | $index = $row[0]; | | |||
26 | | ||||
27 | $query = "select *,unix_timestamp(date) as date_t from yearend2016donations order by date desc;"; | | |||
28 | $q = mysql_query($query,$sq); | | |||
29 | echo mysql_error(); | | |||
30 | $total = 0; | 28 | $total = 0; | ||
31 | $table = "<table border='1' width='100%'>"; | 29 | $table = "<table border='1' width='100%'>"; | ||
32 | $table.="<tr><th width='20'></th><th width='180'>".i18n_var("Date")."</th><th width='80'>".i18n_var("Amount")."</th><th style='text-align:left'>".i18n_var("Donor Name")."</th></tr>"; | 30 | $table.="<tr><th width='20'></th><th width='180'>".i18n_var("Date")."</th><th width='80'>".i18n_var("Amount")."</th><th style='text-align:left'>".i18n_var("Donor Name")."</th></tr>"; | ||
33 | while ($row = mysql_fetch_array($q)) { | 31 | while ($row = $res->fetch()) { | ||
34 | $msg = htmlspecialchars($row["message"]); | 32 | $msg = htmlspecialchars($row["message"]); | ||
35 | if ($msg == "") { | 33 | if ($msg == "") { | ||
36 | $msg = "<i>".i18n_var("Anonymous donation")."</i>"; | 34 | $msg = "<i>".i18n_var("Anonymous donation")."</i>"; | ||
37 | } | 35 | } | ||
38 | $amount = $row["amount"]; | 36 | $amount = $row["amount"]; | ||
39 | $table.="<tr>"; | 37 | $table.="<tr>"; | ||
40 | $table.="<td align='center'>".$index."</td>"; | 38 | $table.="<td align='center'>".$index."</td>"; | ||
41 | $table.="<td align='center'>".date("jS F Y", $row["date_t"])."</td>"; | 39 | $table.="<td align='center'>".date("jS F Y", $row["date_t"])."</td>"; | ||
42 | $table.="<td align='right'>€ ".number_format($amount,2)."</td>"; | 40 | $table.="<td align='right'>€ ".number_format($amount,2)."</td>"; | ||
43 | $total += $amount; | 41 | $total += $amount; | ||
44 | $table.="<td>".$msg."</td>"; | 42 | $table.="<td>".$msg."</td>"; | ||
45 | $table.="</tr>"; | 43 | $table.="</tr>"; | ||
46 | $index--; | 44 | $index--; | ||
47 | } | 45 | } | ||
48 | $table.="</table><br/>"; | 46 | $table.="</table><br/>"; | ||
49 | $total = number_format($total, 0, ".", " "); | 47 | $total = number_format($total, 0, ".", " "); | ||
50 | 48 | | |||
51 | // This is select from select seems mysql specific? | 49 | // This is select from select seems mysql specific? | ||
52 | $query = "select MIN(sum_amount) from ( select sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount DESC LIMIT 9 ) as tops;"; | 50 | $query = "select MIN(sum_amount) from ( select sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount DESC LIMIT 9 ) as tops;"; | ||
53 | $q = mysql_query($query,$sq); | 51 | $limitStmt = $dbConnection->prepare($query); | ||
54 | echo mysql_error(); | 52 | $limitStmt->execute(); | ||
55 | $limit_amount = mysql_fetch_array($q)[0]; | 53 | $limit_amount = $limitStmt->fetchColumn(); | ||
56 | 54 | | |||
57 | $query = "select * from ( select email, sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount ) as tops where sum_amount >= ".$limit_amount." order by sum_amount DESC;"; | 55 | $query = "select * from ( select email, sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount ) as tops where sum_amount >= :limit_amount order by sum_amount DESC;"; | ||
58 | $q = mysql_query($query,$sq); | 56 | $q = $dbConnection->prepare($query); | ||
59 | echo mysql_error(); | 57 | $q->execute(['limit_amount' => $limit_amount]); | ||
60 | 58 | | |||
61 | $top9table = "<table border='1' width='100%'>"; | 59 | $top9table = "<table border='1' width='100%'>"; | ||
62 | $top9table.="<tr><th width='20'></th><th width='180'>".i18n_var("Total Amount")."</th><th style='text-align:left'>".i18n_var("Donor Name")."</th></tr>"; | 60 | $top9table.="<tr><th width='20'></th><th width='180'>".i18n_var("Total Amount")."</th><th style='text-align:left'>".i18n_var("Donor Name")."</th></tr>"; | ||
63 | $count = 0; | 61 | $count = 0; | ||
64 | $last_amount = -1; | 62 | $last_amount = -1; | ||
65 | $last_was_same_amount = false; | 63 | $last_was_same_amount = false; | ||
66 | while ($row = mysql_fetch_array($q)) { | 64 | $q2 = $dbConnection->prepare('select distinct message as name from yearend2016donations where email=:email'); | ||
65 | while ($row = $q->fetch()) { | ||||
ognarb: I forgot execute() | |||||
67 | $amount = $row["sum_amount"]; | 66 | $amount = $row["sum_amount"]; | ||
68 | $email = $row['email']; | 67 | $email = $row['email']; | ||
69 | $query2 = "select distinct message as name from yearend2016donations where email='".$email."';"; | 68 | $q2->execute(['email' => $email]); | ||
70 | $q2 = mysql_query($query2,$sq); | | |||
71 | echo mysql_error(); | | |||
72 | $donation_count = 0; | 69 | $donation_count = 0; | ||
73 | while ($row2 = mysql_fetch_array($q2)) { | 70 | while ($row2 = $q2-fetch()) { | ||
74 | $msg = $row2["name"]; | 71 | $msg = $row2["name"]; | ||
75 | $donation_count++; | 72 | $donation_count++; | ||
76 | } | 73 | } | ||
77 | 74 | | |||
78 | if ($donation_count !== 1) { | 75 | if ($donation_count !== 1) { | ||
79 | $msg = "<i>".i18n_var("Anonymous donation")."</i>"; | 76 | $msg = "<i>".i18n_var("Anonymous donation")."</i>"; | ||
80 | } | 77 | } | ||
81 | if ($msg == "") { | 78 | if ($msg == "") { | ||
▲ Show 20 Lines • Show All 245 Lines • Show Last 20 Lines |
query not used