$ids]); $template_ids = array_column($projects, "template_id"); $template_ids = array_unique($template_ids); if(count($template_ids) != 1) throw new Exception("Cannot create export with different templates."); $template = Template::get($template_ids[0]); if(!$template) throw new Exception("Template cannot be found."); $tests = Test::query([ "project_id" => $ids, "status" => (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED), ]); switch($type) { case "admin": $template->exportTestsCSV("project_csv.php", $tests); break; case "customer": $template->exportTestsCSV("project_customer_csv.php", $tests); break; case "kml": // TODO break; }