X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Felements%2FApplicationCommon.html;h=097a45d4fda183537e07490cc0581ffdafcc6645;hb=fe58901b811f0ab26e8f93a9563fb93bc98e4c19;hp=3cb7ae6bf15f7255886679020560e02ad42809aa;hpb=64fcb43c61c196766260319cd9219eb70ea27767;p=freeside.git diff --git a/httemplate/edit/process/elements/ApplicationCommon.html b/httemplate/edit/process/elements/ApplicationCommon.html index 3cb7ae6bf..097a45d4f 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; @@ -58,18 +61,27 @@ my @subitems = map { [ $cgi->param("subnum$_"), $cgi->param("subamount$_"), $cgi 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 -# 'refund' => $cgi->param('amount'), +# 'refund' => scalar($cgi->param('amount')), # 'payby' => 'BILL', -# #'_date' => $cgi->param('_date'), +# #'_date' => scalar($cgi->param('_date')), # 'payinfo' => 'Cash', #enter payinfo in UI # 'paynum' => $paynum, # } ); #} 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( { @@ -82,6 +94,11 @@ my $new; $options{manual} = 1; -my $error = $new->insert( %options ); +$error ||= $new->insert( %options ); +if ($error) { + $dbh->rollback if $oldAutoCommit; +} else { + $dbh->commit or die $dbh->errstr if $oldAutoCommit; +}