| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- $project = Project::get($id);
- if(!$project) throw new Exception("Project cannot be found.");
- if(!Core::$user->hasPermission($project)) throw new Exception("You do not have permission to access this resource.");
- header("Content-Type: text/csv");
- header("Content-Disposition: attachment; filename=\"export.csv\"");
- header("Cache-Control: private, max-age=0, must-revalidate");
- header("Pragma: public");
- $template = $project->getTemplate();
- $object = json_decode($template->json);
- $fields_1 = $object->beforeTest;
- $fields_2 = $object->duringTest;
- $fields = array_merge($fields_1, $fields_2);
- $fields = array_filter($fields, function($field) {
- if(!isset($field->name)) return false;
- if($field->type == "file") return false;
- return true;
- });
- $tests = Test::query([
- "project_id" => $id,
- "status" => (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED),
- ]);
- $locations = Location::load(array_column($tests, "location_id"));
- $testers = User::load(array_column($tests, "tester_id"));
- $handle = fopen("php://output", "w");
- fclose($handle);
- ?>
|