$allBdays = $MEMBER ? $MEMBER->HasPrivilege(PRIV_EXPORT_BDATE) : true; // Clerks, secretaries, EQ/RS presidency members, and bishopric can see site activity info // for administrative purposes. Stake leaders can, too. $showActivityInfo = $LEADER || $MEMBER && $MEMBER->HasPresetCalling() ? true : false; // Get a list of all ward members $q = "SELECT ID FROM Members WHERE WardID='{$WARD->ID()}' ORDER BY FirstName ASC, LastName ASC"; $r = DB::Run($q); // Get a list of the questions this person is allowed to see $permissions = $USER->Permissions(true); // Our custom-built worky guy! $csv = new CSVBuilder(); // Array of SurveyQuestion objects which this user can see $questions = array(); // (populating in a moment) // Add the fields to the header of the CSV file $csv->AddField("First Name"); $csv->AddField("Middle Name"); $csv->AddField("Last Name"); $csv->AddField("Gender"); $csv->AddField("Home Address"); $csv->AddField("Mobile Phone"); if ($allEmails) { $csv->AddField("Email Address"); } $csv->AddField("Birthday"); if ($showActivityInfo) { $csv->AddField("Registration Date"); $csv->AddField("Last Updated"); $csv->AddField("Last Activity"); } // Build questions array based on permissions
@($dd = $_POST['day']); if (!$yyyy || !$mm || !$dd || $yyyy < 2011 || $yyyy > date("Y") || $mm < 1 || $mm > 12 || $dd < 1 || $dd > 31 || !is_numeric($yyyy) || !is_numeric($mm) || !is_numeric($dd)) { fail("Please be sure to select a cutoff date: day, month, and year."); } // The filename of the to-be-downloaded file. Make safe and strip out common words $safeName = str_replace(" ", "_", strtolower($WARD->Name)); $safeName = preg_replace("/[^0-9A-Za-z_]+/", "", $safeName); $safeName = preg_replace("/provo|utah|ysa|logan|ogden|orem|alpine|salt_lake_city|slc|salt_lake/", "", $safeName); $safeName = trim($safeName, "_- "); $filename = "{$safeName}_mls.csv"; // Run query; prepare to use results $q = DB::Run("SELECT ID FROM Members WHERE WardID='{$WARD->ID()}' AND RegistrationDate >= '{$yyyy}-{$mm}-{$dd}' ORDER BY RegistrationDate ASC"); // Prepare the csv file $csv = new CSVBuilder(); // Fields for the header of the file $csv->AddField("Name"); $csv->AddField("Birth Date"); $csv->AddField("Address"); $csv->AddField("City"); $csv->AddField("State"); $csv->AddField("Postal"); $csv->AddField("Phone"); $csv->AddField("Prior Unit"); // Add all the data to the file while ($r = mysql_fetch_array($q)) { $m = Member::Load($r['ID']); $res = $m->Residence(); // Get parts of the birth date so we can put in that funky MLS format $bdate = strtotime($m->Birthday); $month = date("m", $bdate); $day = date("d", $bdate);