[freeside-commits] freeside/httemplate/edit/process cust_pkg.cgi, 1.6, 1.7
Ivan,,,
ivan at wavetail.420.am
Thu Aug 2 16:09:45 PDT 2007
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail:/tmp/cvs-serv27332/httemplate/edit/process
Modified Files:
cust_pkg.cgi
Log Message:
fix slowness on change package and also make it into a popup
Index: cust_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/cust_pkg.cgi,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cust_pkg.cgi 23 Aug 2006 22:25:37 -0000 1.6
+++ cust_pkg.cgi 2 Aug 2007 23:09:43 -0000 1.7
@@ -1,44 +1,55 @@
-%
-%
-%my $error = '';
-%
-%#untaint custnum
-%$cgi->param('custnum') =~ /^(\d+)$/;
-%my $custnum = $1;
-%
-%my @remove_pkgnums = map {
-% /^(\d+)$/ or die "Illegal remove_pkg value!";
-% $1;
-%} $cgi->param('remove_pkg');
-%
-%my $error_redirect;
-%my @pkgparts;
-%if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi
-% $error_redirect = "misc/change_pkg.cgi";
-% @pkgparts = ($1);
-%} else { #came from edit/cust_pkg.cgi
-% $error_redirect = "edit/cust_pkg.cgi";
-% foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) {
-% if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) {
-% my $num_pkgs = $1;
-% while ( $num_pkgs-- ) {
-% push @pkgparts,$pkgpart;
-% }
-% } else {
-% $error = "Illegal quantity";
-% last;
-% }
-% }
-%}
-%
-%$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums);
-%
-%if ($error) {
-% $cgi->param('error', $error);
-% print $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string );
-%} else {
-% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
-%}
-%
-%
+% if ($error) {
+% $cgi->param('error', $error);
+% $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string );
+% } elsif ( $action eq 'change' ) {
+ <% header("Package changed") %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY>
+ </HTML>
+
+% } elsif ( $action eq 'bulk' ) {
+% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
+% } else {
+% die "guru exception #5: action is neither change nor bulk!";
+% }
+<%init>
+
+my $error = '';
+
+#untaint custnum
+$cgi->param('custnum') =~ /^(\d+)$/;
+my $custnum = $1;
+
+my @remove_pkgnums = map {
+ /^(\d+)$/ or die "Illegal remove_pkg value!";
+ $1;
+} $cgi->param('remove_pkg');
+
+my( $action, $error_redirect );
+my @pkgparts = ();
+if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi
+ $action = 'change';
+ $error_redirect = "misc/change_pkg.cgi";
+ @pkgparts = ($1);
+} else { #came from edit/cust_pkg.cgi
+ $action = 'bulk';
+ $error_redirect = "edit/cust_pkg.cgi";
+ foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) {
+ if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) {
+ my $num_pkgs = $1;
+ while ( $num_pkgs-- ) {
+ push @pkgparts,$pkgpart;
+ }
+ } else {
+ $error = "Illegal quantity";
+ last;
+ }
+ }
+}
+
+$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums);
+
+</%init>
More information about the freeside-commits
mailing list