sub handler {
my $r = shift;
my $html = MyApache2::AppPage->new({reqrec => $r, title => 'Upload File'});
$html->add_header('header', { fixed => 1 });
$html->add_pages([ { title => 'Upload file', id => 'upload_file', cache => 1 }, ]);
my $navbar = &MyApache2::Admin::Upload::generate_nav($html);
$html->add_navbar($navbar);
$html->add_content('upload_file', 'h1', 'Upload voter data file');
$html->add_content('upload_file', 'p', 'You can upload voter data here. Upload the file and choose the type
of data you are uploading. There are two kinds of data you can upload. One is a list of registered voters an
d associated information called a "Voter registration file." The other is a list of voters who partici
pated in a particular election called a "Voter activity file."');
my $form = $html->create_comp('form', 'ul_form', {method => 'post', enctype => "multipart/form-data"});
$form->add_element('file', 'file_upload_field', {required => 1,
allowed_exts => ['csv'],
label => 'File (csv format only)'});
$form->add_element('selectmenu', 'file_type',
{ label => 'Data file type',
options => ['Voter registration file', 'Voter activity file'],
required => 1,
options_label => 'Select voter data type...',
unhide => {'activity_data' => ['Voter activity file'],
'reg_data' => ['Voter registration file'],
},
});
my $reg_fields = $form->add_element('html', 'reg_data', { hide => 1, show_container => 1});
$form->add_element($reg_fields, 'textfield', 'date',
{ label => 'Date data was created',
subtype => 'date', required => 1 });
my $act_fields = $form->add_element('html', 'activity_data', { hide => 1, show_container => 1 });
$form->add_element($act_fields, 'textfield', 'election_date',
{ subtype => 'date', label => 'Election Date', required => 1 });
$form->add_element($act_fields, 'textfield', 'election_desc',
{label => 'Description of election', required => 1 });
$html->add_content('upload_file', $form);
$html->generate;
return Apache2::Const::OK;
}