summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
authorivan <ivan>2007-08-02 23:09:43 +0000
committerivan <ivan>2007-08-02 23:09:43 +0000
commit8e2487662e3555c1efbb7b8ed90e4bda0f8b6cd2 (patch)
tree1eeadb6ee448f22fd1dddb0d74221d897bde9034 /httemplate/edit/process
parent58cfac8638978d97857ee42883e8f8b56b22451b (diff)
fix slowness on change package and also make it into a popup
Diffstat (limited to 'httemplate/edit/process')
-rwxr-xr-xhttemplate/edit/process/cust_pkg.cgi97
1 files changed, 54 insertions, 43 deletions
diff --git a/httemplate/edit/process/cust_pkg.cgi b/httemplate/edit/process/cust_pkg.cgi
index 817c88087..25b826758 100755
--- a/httemplate/edit/process/cust_pkg.cgi
+++ b/httemplate/edit/process/cust_pkg.cgi
@@ -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>