Exemplo n.º 1
0
// ** But it is only a non-null value if a member is logged in and not a stake leader.
// Get this member's privileges (viewing full or hidden info)
$allEmails = $MEMBER ? $MEMBER->HasPrivilege(PRIV_EXPORT_EMAIL) : true;
// Stake Leaders can see all info anyway
$allPhones = $MEMBER ? $MEMBER->HasPrivilege(PRIV_EXPORT_PHONE) : true;
$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) {
 /**
  *
  * @param array $searchResult
  * @return string 
  */
 public function getCsvContentDetail($searchResult)
 {
     $headers = array("Reviewer", "Log", "Comment", "Performance", "Added Date", "Modified Date");
     foreach ($headers as &$header) {
         $header = __($header);
     }
     $csvResultSet = array();
     foreach ($searchResult as $log) {
         $csvRow = array();
         $csvRow[] = $log->getReviewerName();
         $csvRow[] = $log->getLog();
         $csvRow[] = $log->getComment();
         $csvRow[] = $log->getAchievementText();
         $csvRow[] = set_datepicker_date_format($log->getAddedDate());
         $csvRow[] = set_datepicker_date_format($log->getModifiedDate());
         $csvResultSet[] = $csvRow;
     }
     $csvBuilder = new CSVBuilder();
     return $csvBuilder->createCSVString($headers, $csvResultSet);
 }
Exemplo n.º 3
0
@($yyyy = $_POST['year']);
@($mm = $_POST['month']);
@($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);