[freeside-commits] freeside/httemplate/edit/process cust_credit.cgi, 1.10, 1.10.2.1
Jeff Finucane,420,,
jeff at wavetail.420.am
Tue Dec 4 10:19:09 PST 2007
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail:/tmp/cvs-serv22683/httemplate/edit/process
Modified Files:
Tag: FREESIDE_1_7_BRANCH
cust_credit.cgi
Log Message:
change credit reasons from freetext to new reason/reason type system (#2777)
Index: cust_credit.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/cust_credit.cgi,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- cust_credit.cgi 23 Aug 2006 22:25:37 -0000 1.10
+++ cust_credit.cgi 4 Dec 2007 18:19:07 -0000 1.10.2.1
@@ -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')
-%} );
+%$cgi->param('reasonnum') =~ /^(-?\d+)$/ or die "Illegal reasonnum";
+%my $reasonnum = $1;
%
-%my $error = $new->insert;
+%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">
More information about the freeside-commits
mailing list