r83556 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83555‎ | r83556 | r83557 >
Date:00:22, 9 March 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
added donor history form for major gifts reporting. Hosted on grosley /srv/org.wikimedia.fundraising/stats
Modified paths:
  • /trunk/fundraiser-statistics/reporting/donor_history.html (added) (history)
  • /trunk/fundraiser-statistics/reporting/donor_history.sql (added) (history)
  • /trunk/fundraiser-statistics/reporting/donor_history_proc.php (added) (history)
  • /trunk/fundraiser-statistics/reporting/fundraiser_analytics.html (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/reporting/donor_history_proc.php
@@ -0,0 +1,89 @@
 2+<?
 3+
 4+/*
 5+ Ryan Faulkner
 6+ Wikimedia Foundation
 7+ 2011
 8+*/
 9+
 10+// Authenticate form
 11+$pwd_key=$_POST["pwd"];
 12+
 13+if ($pwd_key != "angelface") {
 14+ $message = "Invalid Key.\n";
 15+ die($message);
 16+}
 17+
 18+// we connect to example.com and port 3307
 19+$link = mysql_connect('storage3.pmtpa.wmnet', 'rfaulk');
 20+
 21+if (!$link) {
 22+ die('Could not connect: ' . mysql_error());
 23+}
 24+
 25+// echo 'Connected successfully<br>';
 26+
 27+$db_selected = mysql_select_db('faulkner', $link);
 28+if (!$db_selected) {
 29+ die ('Can\'t use faulkner : ' . mysql_error());
 30+}
 31+
 32+$sql_file=$_POST["sqlFile"];
 33+$first_name=$_POST["first_name"];
 34+$last_name=$_POST["last_name"];
 35+
 36+$query = file_get_contents ($sql_file);
 37+
 38+$query_parts = explode('\\',$query);
 39+$query='';
 40+for ( $counter = 0; $counter < count($query_parts); $counter += 1)
 41+{
 42+ $query=$query.$query_parts[$counter];
 43+}
 44+
 45+
 46+// FORMAT THE SQL QUERY BASED ON THE FILE WHICH INDICATES THE REQUEST
 47+$query = sprintf($query, "%", "%", "%", "%", $first_name, $last_name);
 48+
 49+// Perform Query
 50+$result = mysql_query($query);
 51+
 52+// Check result
 53+// This shows the actual query sent to MySQL, and the error. Useful for debugging.
 54+if (!$result) {
 55+ $message = 'Invalid query: ' . mysql_error() . "\n";
 56+ $message .= 'Whole query: ' . $query;
 57+ die($message);
 58+}
 59+
 60+// Title line - donor's name
 61+echo "<b>".$first_name." ".$last_name."'s donation history ...</b><br><br>";
 62+
 63+// Build Table
 64+
 65+//loop thru the field names to print the correct headers
 66+echo "<table width='100%'><tr>";
 67+if (mysql_num_rows($result)>0)
 68+{
 69+ //loop thru the field names to print the correct headers
 70+ $i = 0;
 71+ while ($i < mysql_num_fields($result))
 72+ {
 73+ echo "<th>". mysql_field_name($result, $i) . "</th>";
 74+ $i++;
 75+ }
 76+ echo "</tr>";
 77+
 78+
 79+ while ($row = mysql_fetch_assoc($result)) {
 80+ echo "<tr>";
 81+ foreach ($row as $data)
 82+ {
 83+ echo "<td align='center'>". $data . "</td>";
 84+ }
 85+ }
 86+
 87+ echo "</table>";
 88+}
 89+
 90+?>
\ No newline at end of file
Index: trunk/fundraiser-statistics/reporting/fundraiser_analytics.html
@@ -33,7 +33,8 @@
3434 <h2>Major Donations</h2>
3535
3636 <h3><a href="http://fundraising.wikimedia.org/stats/report_ecomm_by_amount.html">$100+ donors in the last 7 days</a></h3>
37 -<h3><a href="http://fundraising.wikimedia.org/stats/report_ecomm_by_contact.html">Major Donor History</a> - derived from the major donor <a href="http://fundraising.wikimedia.org/Rebeccas_Contacts_Donation_Alerts.csv">list</a></h3>
 37+<h3><a href="http://fundraising.wikimedia.org/stats/report_ecomm_by_contact.html">Major Donor History</a> - derived from the major donor <a href="http://fundraising.wikimedia.org/stats/Rebeccas_Contacts_Donation_Alerts.csv">list</a></h3>
 38+<h3><a href="http://fundraising.wikimedia.org/stats/donor_history.html">Donor History Form</a> - generate a history log for donors by name</a></h3>
3839
3940 <br>
4041
Index: trunk/fundraiser-statistics/reporting/donor_history.sql
@@ -0,0 +1,27 @@
 2+
 3+
 4+select
 5+
 6+ecomm.stamp as stamp,
 7+civicrm.civicrm_country.name as country_name,
 8+civicrm.civicrm_country.iso_code as iso_code,
 9+converted_amount as amount
 10+
 11+
 12+from
 13+(
 14+select
 15+DATE_FORMAT(receive_date, '%sY-%sm-%sd %sH') as stamp,
 16+civicrm.civicrm_contribution.id,
 17+converted_amount,
 18+civicrm.public_reporting.contact_id
 19+
 20+from civicrm.civicrm_contribution left join civicrm.public_reporting on civicrm.civicrm_contribution.id = civicrm.public_reporting.contribution_id
 21+) as ecomm
 22+
 23+join civicrm.civicrm_contact on ecomm.contact_id = civicrm.civicrm_contact.id
 24+join civicrm.civicrm_address on civicrm.civicrm_contact.id = civicrm.civicrm_address.contact_id
 25+join civicrm.civicrm_country on civicrm.civicrm_address.country_id = civicrm.civicrm_country.id
 26+
 27+where civicrm.civicrm_contact.first_name = '%s' and civicrm.civicrm_contact.last_name = '%s' group by 1;
 28+
Index: trunk/fundraiser-statistics/reporting/donor_history.html
@@ -0,0 +1,37 @@
 2+
 3+<html>
 4+
 5+<head>
 6+
 7+<title>Donor History Form</title>
 8+
 9+</head>
 10+
 11+<body>
 12+<h1><u>Donor History Form:</u></h1>
 13+
 14+<form action="donor_history_proc.php" method="post">
 15+<input type="hidden" name="sqlFile" value="donor_history.sql">
 16+<br/>
 17+<br/>
 18+<label for="first_name">
 19+<pre>Donor's First Name: </pre>
 20+</label>
 21+ <input type="text" name="first_name" />
 22+<br/>
 23+<label for="last_name">
 24+<pre>Donor's Last Name: </pre>
 25+</label>
 26+<input type="text" name="last_name" />
 27+<br/>
 28+<br/>
 29+<label for="pwd">
 30+<pre>Key: </pre>
 31+</label>
 32+<input type="password" name="pwd" size="20">
 33+<br/>
 34+<input type="submit" value="Run Banner Test">
 35+</form>
 36+
 37+</body>
 38+</html>
\ No newline at end of file

Status & tagging log