|
@@ -2,15 +2,23 @@
|
|
|
|
|
|
|
|
namespace Exports;
|
|
namespace Exports;
|
|
|
|
|
|
|
|
|
|
+use Exception;
|
|
|
|
|
+use Location;
|
|
|
|
|
+
|
|
|
class LocationCsvExport {
|
|
class LocationCsvExport {
|
|
|
|
|
|
|
|
- /** @var \Location[] */
|
|
|
|
|
- private $locations = [];
|
|
|
|
|
|
|
+ /** @var Location[] */
|
|
|
|
|
+ private array $locations;
|
|
|
|
|
|
|
|
public function __construct(array $locations) {
|
|
public function __construct(array $locations) {
|
|
|
$this->locations = $locations;
|
|
$this->locations = $locations;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param string $filename
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
public function export(string $filename): void {
|
|
public function export(string $filename): void {
|
|
|
header("Content-Type: text/csv; charset=utf-8");
|
|
header("Content-Type: text/csv; charset=utf-8");
|
|
|
header("Content-Disposition: attachment; filename=$filename");
|
|
header("Content-Disposition: attachment; filename=$filename");
|
|
@@ -18,10 +26,13 @@ class LocationCsvExport {
|
|
|
$handle = fopen("php://output", "wb");
|
|
$handle = fopen("php://output", "wb");
|
|
|
|
|
|
|
|
fputcsv($handle, [
|
|
fputcsv($handle, [
|
|
|
- "ID", "Internal ID", "City", "Legal Entity", "Brand", "Region", "Area Manager", "Area Manager Email", "Open", "Close", "Name", "Address", "Postcode", "Email", "Latitude", "Longitude", "Archived", "Closed",
|
|
|
|
|
|
|
+ "ID", "Internal ID", "City", "Legal Entity", "Brand", "Region", "Area Manager", "Area Manager Email", "Open", "Close", "Name", "Address", "Postcode", "Email", "Latitude", "Longitude", "Archived", "Closed", "Created", "Updated", "Updated By"
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
foreach($this->locations as $location) {
|
|
foreach($this->locations as $location) {
|
|
|
|
|
+ $entries = $location->getUpdateLogEntries([], ["limit" => 1]);
|
|
|
|
|
+ $entry = $entries[0] ?? null;
|
|
|
|
|
+
|
|
|
fputcsv($handle, [
|
|
fputcsv($handle, [
|
|
|
$location->id,
|
|
$location->id,
|
|
|
$location->internal_id,
|
|
$location->internal_id,
|
|
@@ -41,6 +52,9 @@ class LocationCsvExport {
|
|
|
$location->longitude,
|
|
$location->longitude,
|
|
|
$location->archived,
|
|
$location->archived,
|
|
|
$location->closed,
|
|
$location->closed,
|
|
|
|
|
+ $location->dts_created,
|
|
|
|
|
+ $entry ? $entry->dts : "",
|
|
|
|
|
+ $entry ? $entry->getUser()->getDisplayName() : "",
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|