#!/usr/local/bin/perl
# table_form.cgi
# Display a form for creating a table

require './mysql-lib.pl';
&ReadParse();
&can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
$access{'edonly'} && &error($text{'dbase_ecannot'});
&ui_print_header(undef, $text{'table_title2'}, "", "table_form");

print "<form action=create_table.cgi>\n";
print "<input type=hidden name=db value='$in{'db'}'>\n";
print "<table border>\n";
print "<tr $tb> <td><b>$text{'table_header2'}</b></td> </tr>\n";
print "<tr $cb> <td><table>\n";

print "<tr> <td width=25%><b>$text{'table_name'}</b></td>\n";
print "<td><input name=name size=30></td> </tr>\n";

print "<tr> <td width=25%><b>$text{'table_copy'}</b></td>\n";
print "<td><select name=copy>\n";
print "<option value='' checked>$text{'table_copynone'}\n";
foreach $d (&list_databases()) {
	next if (!&can_edit_db($d));
	foreach $t (&list_tables($d, 1)) {
		print "<option>$d.$t\n";
		}
	}
print "</select></td> </tr>\n";

print "<tr> <td width=25%><b>$text{'table_type'}</b></td>\n";
print "<td><select name=type>\n";
foreach $t ('', 'isam', 'myisam', 'heap', 'merge', 'innodb') {
	printf "<option value='%s'> %s\n", $t, $text{"table_type_$t"};
	}
print "</select></td> </tr>\n";

print "<tr> <td colspan=2>";
&show_table_form($in{"fields"} || 4);
print "</td> </tr>\n";

print "<tr> <td colspan=2 align=right><input type=submit ",
      "value='$text{'create'}'></td> </tr>\n";

print "</table></td></tr></table></form>\n";

&ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
	"", $text{'index_return'});

