diff options
author | jeff <jeff> | 2007-12-04 18:19:08 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-12-04 18:19:08 +0000 |
commit | 2c6b7c910668dc09dff9ec34b169a240850f16c0 (patch) | |
tree | b0b9097ddab86f3ee59d95ec6d267b4514693d92 /httemplate/edit | |
parent | b15c501be0d1d1331758916ec3bb1b4aab3b78ef (diff) |
change credit reasons from freetext to new reason/reason type system (#2777)
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-x | httemplate/edit/cust_credit.cgi | 7 | ||||
-rw-r--r-- | httemplate/edit/elements/edit.html | 16 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_credit.cgi | 38 | ||||
-rw-r--r-- | httemplate/edit/reason.html | 5 | ||||
-rw-r--r-- | httemplate/edit/reason_type.html | 6 |
5 files changed, 48 insertions, 24 deletions
diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi index 13d062c74..b6924f4d9 100755 --- a/httemplate/edit/cust_credit.cgi +++ b/httemplate/edit/cust_credit.cgi @@ -5,7 +5,7 @@ <BR><BR> % } -<FORM ACTION="<% $p1 %>process/cust_credit.cgi" METHOD=POST> +<FORM NAME="credit_popup" ACTION="<% $p1 %>process/cust_credit.cgi" METHOD=POST> <INPUT TYPE="hidden" NAME="crednum" VALUE=""> <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> <INPUT TYPE="hidden" NAME="paybatch" VALUE=""> @@ -30,10 +30,7 @@ Credit %#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!; % - <TR> - <TD ALIGN="right">Reason</TD> - <TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<% $reason %>" SIZE=32></TD> - </TR> +<% include('/elements/tr-select-reason.html', 'reasonnum', 'R', '', '', '', 'document.credit_popup.submit',) %> <TR> <TD ALIGN="right">Auto-apply<BR>to invoices</TD> diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 17c5ad3eb..22143a3f0 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -187,12 +187,20 @@ </TD> % } elsif ( $type eq 'select' ) { +% +% my $aref = $f->{'value'}{'values'}; +% my $vkey = $f->{'value'}{'vcolumn'}; +% my $ckey = $f->{'value'}{'ccolumn'}; +% +% if (scalar(@$aref) == 1) { + + <TD BGCOLOR="#dddddd"><% @$aref[0]->$ckey %></TD> + <INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% @$aref[0]->$vkey %>"> + +% }else{ <TD> <SELECT NAME="<% $field %>" -% my $aref = $f->{'value'}{'values'}; -% my $vkey = $f->{'value'}{'vcolumn'}; -% my $ckey = $f->{'value'}{'ccolumn'}; % foreach my $v (@$aref) { <OPTION <% ($object->$field() eq $v->$vkey) ? 'SELECTED' : '' %> VALUE="<% $v->$vkey %>"><% $v->$ckey %></OPTION> @@ -200,6 +208,8 @@ </SELECT> </TD> +% } + % } else { <TD> diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi index 19faca47a..9dcad7f68 100755 --- a/httemplate/edit/process/cust_credit.cgi +++ b/httemplate/edit/process/cust_credit.cgi @@ -3,16 +3,39 @@ %$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; %my $custnum = $1; % -%my $new = new FS::cust_credit ( { -% map { -% $_, scalar($cgi->param($_)); -% } fields('cust_credit') -%} ); -% -%my $error = $new->insert; +%$cgi->param('reasonnum') =~ /^(-?\d+)$/ or die "Illegal reasonnum"; +%my $reasonnum = $1; +% +%my $oldAutoCommit = $FS::UID::AutoCommit; +%local $FS::UID::AutoCommit = 0; +%my $dbh = dbh; +% +%my $error = ''; +%if ($reasonnum == -1) { +% +% $error = 'Enter a new reason (or select an existing one)' +% unless $cgi->param('newreasonnum') !~ /^\s*$/; +% my $reason = new FS::reason({ 'reason_type' => $cgi->param('newreasonnumT'), +% 'reason' => $cgi->param('newreasonnum'), +% }); +% $error ||= $reason->insert; +% $cgi->param('reasonnum', $reason->reasonnum) +% unless $error; +%} +% +%unless ($error) { +% my $new = new FS::cust_credit ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('cust_credit') +% } ); +% $error = $new->insert; +%} % %if ( $error ) { +% $cgi->param('reasonnum', $reasonnum); % $cgi->param('error', $error); +% $dbh->rollback if $oldAutoCommit; % % <% $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %> @@ -27,6 +50,7 @@ % } % #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); % +% $dbh->commit or die $dbh->errstr if $oldAutoCommit; % <% header('Credit sucessful') %> <SCRIPT TYPE="text/javascript"> diff --git a/httemplate/edit/reason.html b/httemplate/edit/reason.html index 7c0722cea..b76eb72bf 100644 --- a/httemplate/edit/reason.html +++ b/httemplate/edit/reason.html @@ -2,10 +2,7 @@ % $cgi->param('class') =~ /^(\w)$/ or die "illegal class"; % my $class=$1; % -% my %classmap = ('C' => 'cancel', -% 'S' => 'suspend', -% ); -% my $classname = $classmap{$class}; +% my $classname = $FS::reason_type::class_name{$class}; % % my (@types) = qsearch( 'reason_type', { 'class' => $class } ); % diff --git a/httemplate/edit/reason_type.html b/httemplate/edit/reason_type.html index 970529e35..056544e5d 100644 --- a/httemplate/edit/reason_type.html +++ b/httemplate/edit/reason_type.html @@ -2,11 +2,7 @@ %$cgi->param('class') =~ /^(\w)$/; %my $class = $1; % -%my %classmap = ( 'C' => 'Cancel', -% 'S' => 'Suspend', -% ); -% -%my $classname = $classmap{$class}; +%my $classname = $FS::reason_type::class_name{$class}; % <% include( 'elements/edit.html', 'name' => $classname . ' Reason Type', |