| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?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();
- $processing_file_path = $template->getProcessingFilePath("project_customer_csv.php");
- $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");
- require $processing_file_path;
- fclose($handle);
- ?>
|