diff --git a/openstack/code/sangria/SangriaPageExportDataExtension.php b/openstack/code/sangria/SangriaPageExportDataExtension.php index 62d20b7..3e541e2 100644 --- a/openstack/code/sangria/SangriaPageExportDataExtension.php +++ b/openstack/code/sangria/SangriaPageExportDataExtension.php @@ -29,6 +29,7 @@ final class SangriaPageExportDataExtension extends Extension 'ExportAppDevSurveyResults', 'exportFoundationMembers', 'exportCorporateSponsors', + 'exportDupUsers', )); @@ -40,6 +41,7 @@ final class SangriaPageExportDataExtension extends Extension 'ExportAppDevSurveyResults', 'exportFoundationMembers', 'exportCorporateSponsors', + 'exportDupUsers', )); } @@ -248,7 +250,6 @@ SQL; $filename = "survey_results" . $fileDate . ".csv"; return CSVExporter::getInstance()->export($filename, $data, ','); - } // Export CSV of all App Dev Surveys @@ -416,4 +417,37 @@ SQL; return CSVExporter::getInstance()->export($filename, $data); } + + public function exportDupUsers(){ + + $fileDate = date('Ymdhis'); + + SangriaPage_Controller::generateDateFilters('s'); + + $sql = <<< SQL +select FirstName, Surname, count(FirstName) AS Qty , group_concat(Email SEPARATOR '|') AS Emails,group_concat(ID SEPARATOR '|') AS MemberIds +from Member +group by FirstName, Surname +having count(FirstName) > 1 +order by FirstName, Surname; +SQL; + + $res = DB::query($sql); + + $fields = array('FirstName','Surname','Qty','Emails','MemberIds'); + $data = array(); + + foreach ($res as $row) { + $member = array(); + foreach ($fields as $field) { + $member[$field] = $row[$field]; + } + array_push($data, $member); + } + + $filename = "dup_users_report" . $fileDate . ".csv"; + + return CSVExporter::getInstance()->export($filename, $data, ','); + } + } \ No newline at end of file diff --git a/themes/openstack/templates/Layout/SangriaPage_ExportData.ss b/themes/openstack/templates/Layout/SangriaPage_ExportData.ss index c5745af..1b49862 100644 --- a/themes/openstack/templates/Layout/SangriaPage_ExportData.ss +++ b/themes/openstack/templates/Layout/SangriaPage_ExportData.ss @@ -68,7 +68,12 @@ - +
+
+

Duplicate Users Report

+
+ +