first commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
// ==================================
|
||||
// Export Recreationa lLicenses - CSV
|
||||
// ==================================
|
||||
|
||||
class Export_SelectedRecreationalLicenses_CSV extends Base {
|
||||
|
||||
// ==================
|
||||
// Class Constructor.
|
||||
// ==================
|
||||
|
||||
public function __construct() {
|
||||
|
||||
set_error_handler(array($this, "displayError"));
|
||||
|
||||
date_default_timezone_set(self::TIMEZONE);
|
||||
}
|
||||
|
||||
// ===============
|
||||
// Export the Data
|
||||
// ===============
|
||||
|
||||
public function export() {
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
$selected_licenses = filter_input(INPUT_POST, "selected_licenses") ?: "";
|
||||
|
||||
$licenses = (new FWCLicenses())->getSelectedLicenses($selected_licenses);
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="Selected_RecreationalLicenses.csv"');
|
||||
|
||||
$output = fopen('php://output', 'w');
|
||||
|
||||
// Add CSV headers
|
||||
fputcsv($output, ['lastname', 'firstname', 'Gender', 'ethnicity', 'county', 'city', 'licence_type', 'start_date', 'expire_date'], ',', '"', '\\');
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
|
||||
$last_name = $license->license_last_name;
|
||||
$first_name = $license->license_first_name;
|
||||
$address = "{$license->license_street1} {$license->license_city}, {$license->license_state} {$license->license_zip_code}";
|
||||
$phone_number = $this->formatPhoneNumber($license->license_phone_number);
|
||||
$email_address = $license->license_email_address;
|
||||
$gender = $license->license_gender;
|
||||
$ethnicity = $license->license_ethnicity;
|
||||
$county = $license->license_county;
|
||||
|
||||
$license_data = array($last_name, $first_name, $address, $phone_number, $email_address, $gender, $ethnicity, $county);
|
||||
|
||||
fputcsv($output, $license_data, ',', '"', '\\');
|
||||
}
|
||||
|
||||
fclose($output);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// ===============
|
||||
// Debug an Object
|
||||
// ===============
|
||||
|
||||
public function debug($object = "") {
|
||||
|
||||
echo "<pre>";
|
||||
print_r($object);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user