X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Felements%2Fprocess.html;h=d9973c6bb0e75a99d629c31e8a81700bdaf97a82;hb=aa8b421f5b51cebbffbe8d0686a63f72d274106a;hp=9d8fa79d2ad4103df94f2b9e65e6e8f5d75cd926;hpb=e04a81044abea1d9bd0a53f96925c9a91e8e01e8;p=freeside.git diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index 9d8fa79d2..d9973c6bb 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -34,6 +34,11 @@ Example: 'clear_on_error' => [ 'form_field1', 'form_field2', ... ], + ## message will be returned to redirect page as cookie and read by header.html + ## append =status, =warning, =error to change color of message box. Default is status + ## status is green, warning is yellow, and error is red + 'message' => [ 'My message=status', 'Please restart=warning' ], + #pass an arrayref of hashrefs for multiple m2ms or m2names #be certain you incorporate m2m_Common if you see error: param @@ -62,6 +67,8 @@ Example: 'fields' => [qw( fieldname fieldname2 )], }, + 'process_locale' => 'fieldname', # update entries in the _msgcat table + 'process_upload' => { 'process' => 'misc/mytable-import.html', # fields to pass to the back end job, besides the @@ -77,6 +84,9 @@ Example: #return an error string or empty for no error 'precheck_callback' => sub { my( $cgi ) = @_; }, + #after the new object is created + 'post_new_object_callback' => sub { my( $cgi, $object ) = @_; }, + #after everything's inserted 'noerror_callback' => sub { my( $cgi, $object ) = @_; }, @@ -84,6 +94,9 @@ Example: # for use with tables that are FS::option_Common (among other things) 'args_callback' => sub { my( $cgi, $object ) = @_; }, + # if no errors after package insert or replace will update services attached to package. + 'update_svc' => sub { my( $cgi, $object ) = @_; }, + 'debug' => 1, #turns on debugging output #agent virtualization @@ -97,6 +110,12 @@ Example: %if ( $error ) { +% ## flatten any array refs so multi selects are sticky on error +% for my $param ($cgi->param) { +% if (ref($cgi->param($param)) eq "ARRAY") { +% $cgi->param($param, (join ",", @{$cgi->param($param)})); +% } +% } % % #my $query = $m->scomp('/elements/create_uri_query'); % #$cgi->redirect("$url?$query"); @@ -157,7 +176,28 @@ process(); <& /elements/footer.html &> -%} elsif ( $opt{'popup_reload'} ) { +% } elsif ( $opt{'progress_init'} ) { +% # some false laziness with the above +% my ($form_name, $job_fields) = @{ $opt{'progress_init'} }; +
+ +% foreach my $field (@$job_fields) { +% next if $field eq $pkey; + +% } +<& /elements/progress-init.html, + @{ $opt{'progress_init'} } +&> + +
+ +<& /elements/footer.html &> + +% } elsif ( $opt{'popup_reload'} ) { <% include('/elements/header-popup.html', $opt{'popup_reload'} ) %> @@ -219,7 +259,7 @@ my %hash = my @values = ( 1 ); if ( $bfield ) { @values = $cgi->param($bfield); - warn join(',', @values); + #warn join(',', @values); } my @uploaded_files; @@ -246,6 +286,10 @@ foreach my $value ( @values ) { } } + if ( $opt{'post_new_object_callback'} ) { + &{ $opt{'post_new_object_callback'} }( $cgi, $new ); + } + if ( $opt{'agent_virt'} ) { if ( ! $new->agentnum @@ -335,12 +379,21 @@ foreach my $value ( @values ) { } - if ( !$error && $opt{'process_o2m'} ) { - - my @process_o2m = ref($opt{'process_o2m'}) eq 'ARRAY' - ? @{ $opt{'process_o2m'} } - : ( $opt{'process_o2m'} ); + my @process_o2m; + if ( $opt{'process_o2m'} ) { + @process_o2m = ref($opt{'process_o2m'}) eq 'ARRAY' + ? @{ $opt{'process_o2m'} } + : ( $opt{'process_o2m'} ); + } + if ( $opt{'process_locale'} ) { + push @process_o2m, + { + 'table' => $table . '_msgcat', + 'fields' => [ 'locale', $opt{'process_locale'} ], + }; + } + if ( !$error ) { foreach my $process_o2m (@process_o2m) { @@ -399,9 +452,21 @@ foreach my $value ( @values ) { } } + if ( !$error and $opt{'update_svc'} ) { + my @args = (); + @args = &{ $opt{'args_callback'} }( $cgi, $new ) if $opt{'args_callback'}; + $error = &{ $opt{'update_svc'} }( $cgi, $new, @args ); + } + if ( $error ) { - $cgi->param('error', $error); + if ($opt{'update_svc'}) { + my $encoded_error = encode_base64($error); + $cgi->param('error_link', $encoded_error); + } else { + $cgi->param('error', $error); + } + if ( $opt{'clear_on_error'} && scalar(@{$opt{'clear_on_error'}}) ) { foreach my $field (@{$opt{'clear_on_error'}}) { $cgi->param($field, '') @@ -420,6 +485,20 @@ foreach my $value ( @values ) { } +if ($class eq "FS::tower" && !$error) { + foreach my $part_svc_broadband_export ( FS::tower_sector->part_export_svc_broadband ) { + if ($part_svc_broadband_export and $part_svc_broadband_export->can('export_tower_sector')) { + my $export_tower = $part_svc_broadband_export->export_tower_sector($new); + $error = $export_tower->{'error'} if $export_tower; + } + } + if ($error) { + my $encoded_error = encode_base64($error); + $cgi->param('error_link', $encoded_error) if $error; + + } +} + # set up redirect URLs my $redirect; @@ -442,6 +521,8 @@ if ( !$error ) { } } +my $messages = $opt{'message'} ? $opt{'message'} : ''; + my $edit_ext = $opt{'edit_ext'} || 'html'; my $error_redirect = $opt{'error_redirect'} || popurl(2)."$table.$edit_ext";