2 # Show a form for exporting CSV data
4 require './postgresql-lib.pl';
6 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
7 $access{'edonly'} && &error($text{'dbase_ecannot'});
9 $desc = &text('table_header', "<tt>$in{'table'}</tt>", "<tt>$in{'db'}</tt>");
10 &ui_print_header($desc, $text{'csv_title'}, "", "csv");
12 print &ui_form_start("csv.cgi/$in{'table'}.csv", "post");
13 print &ui_hidden("db", $in{'db'}),"\n";
14 print &ui_hidden("table", $in{'table'}),"\n";
15 print &ui_table_start($text{'csv_header'}, undef, 2);
17 print &ui_table_row($text{'csv_format'},
18 &ui_radio("format", 0, [ [ 0, $text{'csv_format0'} ],
19 [ 1, $text{'csv_format1'} ],
20 [ 2, $text{'csv_format2'} ] ]));
22 print &ui_table_row($text{'csv_headers'},
23 &ui_yesno_radio("headers", 0));
25 if ($access{'backup'}) {
26 # Only allow saving to file if a backup user is configured
27 print &ui_table_row($text{'csv_dest'},
28 &ui_radio("dest", 0, [ [ 0, $text{'csv_browser'}."<br>" ],
29 [ 1, $text{'csv_file'} ] ])."\n".
30 &ui_textbox("file", undef, 40)." ".
31 &file_chooser_button("file"));
34 print &ui_table_row($text{'csv_where'},
35 &ui_opt_textbox("where", undef, 30, $text{'csv_all'}));
38 @str = &table_structure($in{'db'}, $in{'table'});
39 @cols = map { $_->{'field'} } @str;
40 print &ui_table_row($text{'csv_cols'},
41 &ui_select("cols", \@cols,
42 [ map { [ $_->{'field'}, "$_->{'field'} - $_->{'type'}" ] } @str ], 5, 1));
44 print &ui_table_end();
45 print &ui_form_end([ [ "ok", $text{'csv_ok'} ] ]);
47 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
48 "", $text{'index_return'});