diff options
author | Mark Wells <mark@freeside.biz> | 2012-10-27 14:24:00 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-10-27 14:24:00 -0700 |
commit | eccc8de2366e2e004a37761b8da2b447ec861ecb (patch) | |
tree | bce8f9b106ae4fec53432600847352a48b0d14b5 /httemplate | |
parent | 2c2da653a3d39945d8d2c244d102ccbee862053b (diff) |
ICS invoice spool format and email delivery, #17620
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/browse/ftp_target.html | 56 | ||||
-rw-r--r-- | httemplate/browse/upload_target.html | 49 | ||||
-rwxr-xr-x | httemplate/edit/ftp_target.html | 46 | ||||
-rw-r--r-- | httemplate/edit/process/ftp_target.html | 12 | ||||
-rw-r--r-- | httemplate/edit/process/upload_target.html | 25 | ||||
-rwxr-xr-x | httemplate/edit/upload_target.html | 82 | ||||
-rw-r--r-- | httemplate/elements/menu.html | 2 |
7 files changed, 157 insertions, 115 deletions
diff --git a/httemplate/browse/ftp_target.html b/httemplate/browse/ftp_target.html deleted file mode 100644 index 4a5782058..000000000 --- a/httemplate/browse/ftp_target.html +++ /dev/null @@ -1,56 +0,0 @@ -<& elements/browse.html, - 'title' => 'FTP targets', - 'menubar' => [ 'Add a target' => $p.'edit/ftp_target.html', ], - 'name' => 'FTP targets', - 'query' => { 'table' => 'ftp_target', - 'hashref' => {}, - }, - 'count_query' => $count_query, - 'header' => [ '#', - 'Server', - 'Username', - 'Password', - 'Path', - 'Protocol', - '', #handling - ], - 'fields' => [ 'targetnum', - 'hostname', - 'username', - 'password', - 'path', - sub { - my $ftp_target = shift; - my $label; - if ($ftp_target->secure) { - $label = 'SFTP'; - $label .= ' (port '.$ftp_target->port.')' - if $ftp_target->port != 22; - } - else { - $label = 'FTP'; - $label .= ' (port '.$ftp_target->port.')' - if $ftp_target->port != 21; - } - $label; - }, - 'handling', - ], - 'links' => [ $link, $link ], -&> -</TABLE> - -<% include('/elements/footer.html') %> - -<%once> - -my $count_query = 'SELECT COUNT(*) FROM ftp_target'; - -</%once> -<%init> - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); - -my $link = [ $p.'edit/ftp_target.html?', 'targetnum' ]; -</%init> diff --git a/httemplate/browse/upload_target.html b/httemplate/browse/upload_target.html new file mode 100644 index 000000000..e166f3520 --- /dev/null +++ b/httemplate/browse/upload_target.html @@ -0,0 +1,49 @@ +<& elements/browse.html, + 'title' => 'Upload targets', + 'menubar' => [ 'Add a target' => $p.'edit/upload_target.html', ], + 'name' => 'targets', + 'query' => { 'table' => 'upload_target', + 'hashref' => {}, + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Protocol', + 'Username', + 'Server/Domain', + 'Password', + 'Path', + '', #handling + ], + 'fields' => [ 'targetnum', + sub { + my $target = shift; + $label{$target->protocol} + }, + 'username', + 'hostname', + 'password', + 'path', + 'handling', + ], + 'links' => [ $link, $link, $link, $link, ], +&> +</TABLE> + +<% include('/elements/footer.html') %> + +<%once> + +my $count_query = 'SELECT COUNT(*) FROM upload_target'; +my %label = ( + email => 'Email', + ftp => 'FTP', + sftp => 'SFTP', +); +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $link = [ $p.'edit/upload_target.html?', 'targetnum' ]; +</%init> diff --git a/httemplate/edit/ftp_target.html b/httemplate/edit/ftp_target.html deleted file mode 100755 index aebf9aaed..000000000 --- a/httemplate/edit/ftp_target.html +++ /dev/null @@ -1,46 +0,0 @@ -<& elements/edit.html, - 'post_url' => popurl(1).'process/ftp_target.html', - 'name' => 'FTP target', - 'table' => 'ftp_target', - 'viewall_url' => "${p}browse/ftp_target.html", - 'labels' => { targetnum => 'Target', - hostname => 'Server', - username => 'Username', - password => 'Password', - path => 'Directory', - port => 'Port', - secure => 'Use SFTP', - handling => 'Special handling', - }, - 'fields' => [ - { field => 'hostname', size => 40 }, - { field => 'port', size => 8 }, - { field => 'secure', type => 'checkbox', value => 'Y' }, - 'username', - 'password', - { field => 'path', size => 40 }, - { field => 'handling', - type => 'select', - options => [ FS::ftp_target->handling_types ], - }, - ], - 'menubar' => \@menubar, - 'edit_callback' => $edit_callback, -&> -<%init> - -my $curuser = $FS::CurrentUser::CurrentUser; - -die "access denied" - unless $curuser->access_right('Configuration'); - -my @menubar = ('View all FTP targets' => $p.'browse/ftp_target.html'); -my $edit_callback = sub { - my ($cgi, $object) = @_; - if ( $object->targetnum ) { - push @menubar, 'Delete this target', - $p.'misc/delete-ftp_target.html?'.$object->targetnum; - } -}; - -</%init> diff --git a/httemplate/edit/process/ftp_target.html b/httemplate/edit/process/ftp_target.html deleted file mode 100644 index 35f56c490..000000000 --- a/httemplate/edit/process/ftp_target.html +++ /dev/null @@ -1,12 +0,0 @@ -<& elements/process.html, - 'table' => 'ftp_target', - 'viewall_dir' => 'browse', - 'agent_null' => 1, -&> -<%init> -my $curuser = $FS::CurrentUser::CurrentUser; - -die "access denied" - unless $curuser->access_right('Configuration'); - -</%init> diff --git a/httemplate/edit/process/upload_target.html b/httemplate/edit/process/upload_target.html new file mode 100644 index 000000000..8755bed56 --- /dev/null +++ b/httemplate/edit/process/upload_target.html @@ -0,0 +1,25 @@ +<& elements/process.html, + 'table' => 'upload_target', + 'viewall_dir' => 'browse', + 'agent_null' => 1, + 'precheck_callback'=> \&precheck, +&> +<%init> +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Configuration'); + +sub precheck { + my $cgi = shift; + my $protocol = $cgi->param('protocol'); + # promote whatever set of fields was selected to the "real" values + my $params = $cgi->Vars; + foreach ( keys %$params ) { + if ( $_ =~ /^${protocol}_(\w+)/ ) { + $cgi->param($1, $cgi->param($_)); + } + } +} + +</%init> diff --git a/httemplate/edit/upload_target.html b/httemplate/edit/upload_target.html new file mode 100755 index 000000000..47fea78a0 --- /dev/null +++ b/httemplate/edit/upload_target.html @@ -0,0 +1,82 @@ +<& elements/edit.html, + 'post_url' => popurl(1).'process/upload_target.html', + 'name' => 'Upload target', + 'table' => 'upload_target', + 'viewall_url' => "${p}browse/upload_target.html", + 'labels' => { targetnum => 'Target', + protocol => 'Protocol', + handling => 'Special handling', + }, + 'fields' => [ + { field => 'protocol', + type => 'selectlayers', + options => [ '', 'sftp', 'ftp', 'email' ], + labels => { '' => '', + 'email' => 'Email', + 'sftp' => 'SFTP', + 'ftp' => 'FTP', + }, + layer_fields => \%protocol_fields, + layer_values_callback => \&values_callback, + }, + { field => 'handling', + type => 'select', + options => [ FS::upload_target->handling_types ], + }, + ], + 'menubar' => \@menubar, + 'edit_callback' => $edit_callback, +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Configuration'); + +my @menubar = ('View all FTP targets' => $p.'browse/upload_target.html'); +my $edit_callback = sub { + my ($cgi, $object) = @_; + if ( $object->targetnum ) { + push @menubar, 'Delete this target', + $p.'misc/delete-upload_target.html?'.$object->targetnum; + } +}; + +my %protocol_fields = ( + '' => [], + 'sftp' => [ + 'hostname' => { label => 'Server' }, + 'username' => { label => 'Username' }, + 'password' => { label => 'Password' }, + 'port' => { label => 'Port', size => 8 }, + 'path' => { label => 'Path', size => 30 }, + ], + 'email' => [ + 'username' => { label => 'To:' }, + 'hostname' => { label => '@' }, + 'subject' => { label => 'Subject:' }, + ], +); +$protocol_fields{'ftp'} = [ @{ $protocol_fields{'sftp'} } ]; +foreach my $k (keys %protocol_fields) { + # disambiguate the field names + foreach (@{ $protocol_fields{$k} }) { + $_ = $k.'_'.$_ unless ref $_; + } +} + +sub values_callback { + my ($cgi, $object) = @_; + my $layer_values; + # really simple, the interpretation of the fields is the same for all + # three layers + foreach my $l (qw(email ftp sftp)) { + $layer_values->{$l} = { map { $l.'_'.$_ => ($cgi->param($l.'_'.$_) || + $object->get($_) ) } + $object->fields }; + } + $layer_values; +} + +</%init> diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index b2141e991..bfbc179b9 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -629,7 +629,7 @@ $config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_cla || $curuser->access_right('Edit global inventory') || $curuser->access_right('Configuration'); -$config_misc{'FTP targets'} = [ $fsurl.'browse/ftp_target.html', 'FTP servers for billing and payment processing' ] +$config_misc{'Upload targets'} = [ $fsurl.'browse/upload_target.html', 'Billing and payment upload destinations' ] if $curuser->access_right('Configuration'); tie my %config_menu, 'Tie::IxHash'; |