// We're done adding fields; now fill up the values row by row. while ($row = mysql_fetch_array($r)) { $m = Member::Load($row['ID']); // Get parts of the birth date (so we can hide the year, if necessary) $bdate = strtotime($m->Birthday); $month = date("F", $bdate); $day = date("j", $bdate); $mm = date("m", $bdate); $dd = date("d", $bdate); $yyyy = date("Y", $bdate); // Prepare the member's last activity info in case we need to provide it $regDate = strtotime($m->RegistrationDate()); $lastUpdated = strtotime($m->LastUpdated()); $lastActivity = strtotime($m->LastActivity()); // Add fields in the same order as the first line. Very important! $csv->AddValue($m->FirstName); $csv->AddValue($m->MiddleName); $csv->AddValue($m->LastName); $csv->AddValue(Gender::Render($m->Gender)); $csv->AddValue($m->ResidenceString()); $csv->AddValue(!$m->HidePhone || $allPhones ? formatPhoneForDisplay($m->PhoneNumber) : ""); if ($allEmails) { $csv->AddValue($m->Email); } if ($allBdays) { $csv->AddValue("{$mm}-{$dd}-{$yyyy}"); } else { $csv->AddValue(!$m->HideBirthday ? "{$month} {$day}" : ''); } // doesn't work as well in contact importers. oh well. if ($showActivityInfo) {
$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); $year = date("Y", $bdate); // If the address isn't custom, the street portion needs to have the unit number appended $streetAddr = $res ? $res->Address : ""; if ($res && !$res->Custom() && trim($m->Apartment) != "") { $streetAddr .= " Apt " . $m->Apartment; } // Build this row $csv->AddValue($m->LastName . ", " . $m->FirstName); $csv->AddValue($year . $month . $day); $csv->AddValue($streetAddr); $csv->AddValue($res ? $res->City : ""); $csv->AddValue($res ? $res->State : ""); $csv->AddValue($res ? $res->PostalCode : ""); $csv->AddValue(formatPhoneForDisplay($m->PhoneNumber)); $csv->AddValue(""); $csv->NextRow(); } // Send file as a download $csv->Download($filename);