diff --git a/libraries/classes/Database/MultiTableQuery.php b/libraries/classes/Database/MultiTableQuery.php
index f52c3af33b..9259116207 100644
--- a/libraries/classes/Database/MultiTableQuery.php
+++ b/libraries/classes/Database/MultiTableQuery.php
@@ -42,45 +42,12 @@ class MultiTableQuery
private function getColumnsHTML()
{
$tables = $GLOBALS['dbi']->getTables($this->_db);
- $html_output = '
';
- for ($i = 0; $i < count($tables); $i++)
- {
- $html_output .= '';
- $table_fields = $GLOBALS['dbi']->getColumns($this->_db, $tables[$i]);
- $html_output .= ' * ';
- foreach ($table_fields as $key => $value)
- {
- $html_output .= '' . $key . ' ';
- }
- $html_output .= '
';
- }
-
- $html_output .= '';
- $html_output .= Template::get('database/multi_table_query/new_column')->render(array(
- 'id' => 0,
- 'tables' => $tables
- ));
- $html_output .= '
';
-
- for ($i = 1; $i <= $this->_default_no_of_columns; $i++)
- {
- $html_output .= Template::get('database/multi_table_query/new_column')->render(array(
- 'id' => $i,
- 'tables' => $tables
- ));
- }
- $html_output .= '';
- $html_output .= ' ';
- $html_output .= ' ';
- $html_output .= ' ';
-
- $html_output .= '';
- $html_output .= '';
- $html_output .= ' ';
-
- $html_output .= ' ';
-
- return $html_output;
+ return Template::get('database/multi_table_query/columns')->render([
+ 'tables' => $tables,
+ 'dbi' => $GLOBALS['dbi'],
+ 'db' => $this->_db,
+ 'default_no_of_columns' => $this->_default_no_of_columns,
+ ]);
}
public function getFormHTML()
diff --git a/templates/database/multi_table_query/columns.twig b/templates/database/multi_table_query/columns.twig
new file mode 100644
index 0000000000..c17c4114ea
--- /dev/null
+++ b/templates/database/multi_table_query/columns.twig
@@ -0,0 +1,34 @@
+
+ {% set tables_count = tables|length - 1 %}
+ {% for i in 0..tables_count %}
+
+ {% set table_fields = dbi.getColumns(db, tables[i]) %}
+ *
+ {% for key in table_fields|keys %}
+ {{ key }}
+ {% endfor %}
+
+ {% endfor %}
+
+
+ {% include 'database/multi_table_query/new_column.twig' with {
+ 'id': 0,
+ 'tables': tables
+ } only %}
+
+
+ {% for i in 1..default_no_of_columns %}
+ {% include 'database/multi_table_query/new_column.twig' with {
+ 'id': i,
+ 'tables': tables
+ } only %}
+ {% endfor %}
+
+
+
+
+
+
+
+
+