Use template for getColumnsHTML
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
d66d86c5d6
commit
c82669ba57
@ -42,45 +42,12 @@ class MultiTableQuery
|
||||
private function getColumnsHTML()
|
||||
{
|
||||
$tables = $GLOBALS['dbi']->getTables($this->_db);
|
||||
$html_output = '<fieldset>';
|
||||
for ($i = 0; $i < count($tables); $i++)
|
||||
{
|
||||
$html_output .= '<div style="display:none" id="' . md5($tables[$i]) . '">';
|
||||
$table_fields = $GLOBALS['dbi']->getColumns($this->_db, $tables[$i]);
|
||||
$html_output .= '<option value="*"> * </option>';
|
||||
foreach ($table_fields as $key => $value)
|
||||
{
|
||||
$html_output .= '<option value="' . $key . '">' . $key . '</option>';
|
||||
}
|
||||
$html_output .= '</div>';
|
||||
}
|
||||
|
||||
$html_output .= '<div style="display:none" id="new_column_layout">';
|
||||
$html_output .= Template::get('database/multi_table_query/new_column')->render(array(
|
||||
'id' => 0,
|
||||
'tables' => $tables
|
||||
));
|
||||
$html_output .= '</div>';
|
||||
|
||||
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 .= '<fieldset style="display:inline">';
|
||||
$html_output .= '<input type="button" value="' . __('+ Add column') . '" id="add_column_button">';
|
||||
$html_output .= '<br> ';
|
||||
$html_output .= '</fieldset>';
|
||||
|
||||
$html_output .= '<fieldset>';
|
||||
$html_output .= '<textarea cols="80" rows="4" style="float:left" name="sql_query" id="MultiSqlquery" dir="ltr"></textarea>';
|
||||
$html_output .= '</fieldset>';
|
||||
|
||||
$html_output .= '</fieldset>';
|
||||
|
||||
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()
|
||||
|
||||
34
templates/database/multi_table_query/columns.twig
Normal file
34
templates/database/multi_table_query/columns.twig
Normal file
@ -0,0 +1,34 @@
|
||||
<fieldset>
|
||||
{% set tables_count = tables|length - 1 %}
|
||||
{% for i in 0..tables_count %}
|
||||
<div style="display:none" id="{{ md5(tables[i]) }}">
|
||||
{% set table_fields = dbi.getColumns(db, tables[i]) %}
|
||||
<option value="*">*</option>
|
||||
{% for key in table_fields|keys %}
|
||||
<option value="{{ key }}">{{ key }}</option>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div style="display:none" id="new_column_layout">
|
||||
{% include 'database/multi_table_query/new_column.twig' with {
|
||||
'id': 0,
|
||||
'tables': tables
|
||||
} only %}
|
||||
</div>
|
||||
|
||||
{% for i in 1..default_no_of_columns %}
|
||||
{% include 'database/multi_table_query/new_column.twig' with {
|
||||
'id': i,
|
||||
'tables': tables
|
||||
} only %}
|
||||
{% endfor %}
|
||||
<fieldset style="display:inline">
|
||||
<input type="button" value="{% trans '+ Add column' %}" id="add_column_button">
|
||||
<br>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<textarea cols="80" rows="4" style="float:left" name="sql_query" id="MultiSqlquery" dir="ltr"></textarea>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
Loading…
Reference in New Issue
Block a user