diff options
author | Ivan Kohler <ivan@freeside.biz> | 2012-09-23 18:07:47 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2012-09-23 18:07:47 -0700 |
commit | 36a1e9c1661fb552d368f2f675dcb0793d733748 (patch) | |
tree | a4d2e0c2bb10ae1f49017ea1a900f72c7dd48a75 /httemplate | |
parent | aa38c070977cf63365a4d26a3e4a7e5049ad70d0 (diff) |
export host selection per service, RT#17914
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/edit/process/svc_acct.cgi | 27 | ||||
-rwxr-xr-x | httemplate/edit/svc_acct.cgi | 6 | ||||
-rw-r--r-- | httemplate/elements/tr-svc_export_machine.html | 37 | ||||
-rw-r--r-- | httemplate/view/elements/tr-svc_export_machine.html | 27 | ||||
-rw-r--r-- | httemplate/view/svc_acct/basics.html | 5 |
5 files changed, 95 insertions, 7 deletions
diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index a7d5136fb..41aca65ee 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -56,13 +56,14 @@ my $new = new FS::svc_acct ( \%hash ); my $error = ''; +my $part_svc = $svcnum ? + $old->part_svc : + qsearchs( 'part_svc', + { 'svcpart' => $cgi->param('svcpart') } + ); + # google captcha auth if ( $cgi->param('captcha_response') ) { - my $part_svc = $svcnum ? - $old->part_svc : - qsearchs( 'part_svc', - { 'svcpart' => $cgi->param('svcpart') } - ); my ($export) = $part_svc->part_export('acct_google'); if ( $export and ! $export->captcha_auth($cgi->param('captcha_response')) ) { @@ -79,6 +80,18 @@ if ( $cgi->param('clear_password') eq '*HIDDEN*' } if ( ! $error ) { + + my $export_info = FS::part_export::export_info(); + + my @svc_export_machine = + map FS::svc_export_machine->new({ + 'svcnum' => $svcnum, + 'exportnum' => $_->exportnum, + 'machinenum' => scalar($cgi->param('exportnum'.$_->exportnum.'machinenum')), + }), + grep { $_->machine eq '_SVC_MACHINE' } + $part_svc->part_export; + if ( $svcnum ) { foreach ( grep { $old->$_ != $new->$_ } qw( seconds upbytes downbytes totalbytes ) @@ -92,9 +105,9 @@ if ( ! $error ) { $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes last; #once is enough } - $error ||= $new->replace($old); + $error ||= $new->replace($old, 'child_objects'=>\@svc_export_machine); } else { - $error ||= $new->insert; + $error ||= $new->insert('child_objects'=>\@svc_export_machine); $svcnum = $new->svcnum; } } diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 38567ef67..142c11150 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -173,6 +173,12 @@ function randomPass() { <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>"> %} +<& /elements/tr-svc_export_machine.html, + 'svc' => $svc_acct, + 'part_svc' => $part_svc, + 'cgi' => $cgi, +&> + % #uid/gid % foreach my $xid (qw( uid gid )) { % diff --git a/httemplate/elements/tr-svc_export_machine.html b/httemplate/elements/tr-svc_export_machine.html new file mode 100644 index 000000000..92b6ac1d7 --- /dev/null +++ b/httemplate/elements/tr-svc_export_machine.html @@ -0,0 +1,37 @@ +% foreach my $part_export (@part_export) { +% my $label = ( $part_export->exportname +% ? $part_export->exportname +% : $part_export->label +% ). +% ' hostname'; +% +% my $element = 'exportnum'. $part_export->exportnum. 'machinenum'; +% my $machinenum = $opt{cgi}->param($element); +% if ( ! $machinenum && $opt{svc}->svcnum ) { +% my $svc_export_machine = qsearchs('svc_export_machine', { +% 'svcnum' => $opt{svc}->svcnum, +% 'exportnum' => $part_export->exportnum, +% }); +% $machinenum = $svc_export_machine->machinenum if $svc_export_machine; +% } + + <& /elements/tr-select-table.html, + 'label' => $label, + 'element_name' => 'exportnum'. $part_export->exportnum. 'machinenum', + 'table' => 'part_export_machine', + 'name_col' => 'machine', + 'hashref' => { 'exportnum' => $part_export->exportnum, + 'disabled' => '', + }, + 'curr_value' => $machinenum, + 'empty_label' => 'Select export hostname', + &> +% } +<%init> + +my %opt = @_; + +my @part_export = grep { $_->machine eq '_SVC_MACHINE' } + $opt{part_svc}->part_export; + +</%init> diff --git a/httemplate/view/elements/tr-svc_export_machine.html b/httemplate/view/elements/tr-svc_export_machine.html new file mode 100644 index 000000000..1ba8d74a1 --- /dev/null +++ b/httemplate/view/elements/tr-svc_export_machine.html @@ -0,0 +1,27 @@ +% foreach my $part_export (@part_export) { +% my $label = ( $part_export->exportname +% ? $part_export->exportname +% : $part_export->label +% ). +% ' hostname'; +% +% my $svc_export_machine = qsearchs('svc_export_machine', { +% 'svcnum' => $opt{svc}->svcnum, +% 'exportnum' => $part_export->exportnum, +% }); + + <& tr.html, + 'label' => $label, + 'value' => $svc_export_machine + ? $svc_export_machine->part_export_machine->machine + : '', + &> +% } +<%init> + +my %opt = @_; + +my @part_export = grep { $_->machine eq '_SVC_MACHINE' } + $opt{part_svc}->part_export; + +</%init> diff --git a/httemplate/view/svc_acct/basics.html b/httemplate/view/svc_acct/basics.html index bcd84696e..1cdf77615 100644 --- a/httemplate/view/svc_acct/basics.html +++ b/httemplate/view/svc_acct/basics.html @@ -56,6 +56,11 @@ &> % } +<& /view/elements/tr-svc_export_machine.html, + 'svc' => $svc_acct, + 'part_svc' => $part_svc, +&> + % if ($svc_acct->uid ne '') { <& /view/elements/tr.html, label=>mt('UID'), value=>$svc_acct->uid &> % } |