X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Felements%2FApplicationCommon.html;h=ea2462aed48fa3d3943150d5dae5b34821c61ff5;hb=4d5e45b24200386a7fc47f2cd69949e82e4bc9c3;hp=e0c5bd707833b7cd681d3a34619f1fbb29278008;hpb=87ddf7284561e5c912aefe2ecc3f348649b78183;p=freeside.git diff --git a/httemplate/edit/process/elements/ApplicationCommon.html b/httemplate/edit/process/elements/ApplicationCommon.html index e0c5bd707..ea2462aed 100644 --- a/httemplate/edit/process/elements/ApplicationCommon.html +++ b/httemplate/edit/process/elements/ApplicationCommon.html @@ -21,11 +21,12 @@ Examples: %if ( $error ) { % $cgi->param('error', $error); -<% $cgi->redirect(popurl(2). $opt{error_redirect}. '?'. $cgi->query_string ) %> +% my $query = $m->scomp('/elements/create_uri_query'); +<% $cgi->redirect(popurl(2). $opt{error_redirect}. "?$query") %> %} else { -<% header("$src_thing application$to sucessful") %> +<& /elements/header-popup.html, "$src_thing application$to sucessful" &> @@ -34,6 +35,8 @@ Examples: my %opt = @_; +my $error = ''; + my $src_thing = ucfirst($opt{'src_thing'}); my $src_table = $opt{'src_table'}; my $src_pkey = dbdef->table($src_table)->primary_key; @@ -51,6 +54,18 @@ my $cust_main = qsearchs('cust_main', { 'custnum' => $src->custnum } ) my $custnum = $cust_main->custnum; +my @subnames = grep { /.+/ } map { /^subnum(\d+)$/ ? $1 : '' } $cgi->param; +my @subitems = map { [ $cgi->param("subnum$_"), $cgi->param("subamount$_"), $cgi->param("taxXlocationnum$_") ] } + @subnames; +{ local $^W = 0; @subitems = grep { $_->[1] + 0 } @subitems; } + +my %options = (); +$options{subitems} = \@subitems if scalar(@subitems); + +my $oldAutoCommit = $FS::UID::AutoCommit; +local $FS::UID::AutoCommit = 0; +my $dbh = dbh; + my $new; # $new = new FS::cust_refund ( { # 'reason' => 'Refunding payment', #enter reason in UI @@ -62,6 +77,11 @@ my $new; # } ); #} else { + if ($src->amount != $cgi->param('src_amount')) { + $src->amount($cgi->param('src_amount')); + $error = $src->replace; + } + my $class = 'FS::'. $opt{link_table}; $new = $class->new( { @@ -72,6 +92,13 @@ my $new; #} -my $error = $new->insert( 'manual' => 1 ); +$options{manual} = 1; +$error ||= $new->insert( %options ); + +if ($error) { + $dbh->rollback if $oldAutoCommit; +} else { + $dbh->commit or die $dbh->errstr if $oldAutoCommit; +}