|
|
@@ -48,6 +48,46 @@ if($sort == "internal-id") {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+$action = http::value("action");
|
|
|
+if(!empty($action)) {
|
|
|
+ switch($action) {
|
|
|
+ case "export":
|
|
|
+
|
|
|
+ if(!Core::$user->canAdmin()) throw new Exception("You do not have permission to access this resource.");
|
|
|
+
|
|
|
+ header("Content-Type: text/csv; charset=utf-8");
|
|
|
+ header("Content-Disposition: attachment; filename=export.csv");
|
|
|
+
|
|
|
+ $handle = fopen("php://output", "w");
|
|
|
+
|
|
|
+ fputcsv($handle, [
|
|
|
+ "Internal ID", "City", "Legal Entity", "Region", "Area", "Open", "Close", "Name", "Address", "Postcode", "Email", "Latitude", "Longitude"
|
|
|
+ ]);
|
|
|
+
|
|
|
+ foreach($locations as $location) {
|
|
|
+ fputcsv($handle, [
|
|
|
+ $location->internal_id,
|
|
|
+ $location->city,
|
|
|
+ $location->legal_entity_name,
|
|
|
+ $location->region,
|
|
|
+ $location->area_manager,
|
|
|
+ "",
|
|
|
+ "",
|
|
|
+ $location->name,
|
|
|
+ $location->address_1,
|
|
|
+ $location->postal_code,
|
|
|
+ $location->email,
|
|
|
+ $location->latitude,
|
|
|
+ $location->longitude,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ fclose($handle);
|
|
|
+
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
$filter_count = count($nvp) - 1;
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|