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(); $processing_file_path = $template->getProcessingFilePath("project_csv.php"); $object = json_decode($template->getJSON()); $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"); require $processing_file_path; fclose($handle); ?>