[freeside-commits] freeside/httemplate/misc did_order_provision.html, 1.2, 1.3 did_order_confirmed.html, 1.3, 1.4

Erik Levinson levinse at wavetail.420.am
Tue Jun 7 22:37:40 PDT 2011


Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail.420.am:/tmp/cvs-serv9780/httemplate/misc

Modified Files:
	did_order_provision.html did_order_confirmed.html 
Log Message:
DID inventory/import / bulk DID orders - phase 2, RT12754

Index: did_order_confirmed.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/did_order_confirmed.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- did_order_confirmed.html	17 Apr 2011 03:27:42 -0000	1.3
+++ did_order_confirmed.html	8 Jun 2011 05:37:38 -0000	1.4
@@ -1,17 +1,19 @@
-<% include('/elements/header-popup.html', $success_msg ) %>
+<% include("/elements/header$popup.html", $header ) %>
+<% include('/elements/error.html') %>
+% unless ( $cgi->param('error') ) {
   <SCRIPT TYPE="text/javascript">
     <% $js %>
   </SCRIPT>
+% }
   </BODY>
 </HTML>
 <%init>
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Import');
 
-$cgi->param('action') =~ /^(confirm|cancel|provision)$/ or die 'illegal action';
 my $action = $1;
-my $success_msg = '';
-my $error = '';
+my $header = '';
+my $popup = '';
 my $js = 'window.top.location.reload();';
 
 $cgi->param('ordernum') =~ /^(\d+)$/ or die 'illegal ordernum';
@@ -22,9 +24,10 @@
 } );
 die "No order $ordernum" unless $did_order;
 
+my $action = $cgi->param('action');
 if ( $action eq 'confirm' ) {
     my $confirmed = '';
-    my $sucess_msg = 'DID order confirmed';
+    $header = 'DID order confirmed';
     $confirmed = parse_datetime($cgi->param('confirmed'))
         if $cgi->param('confirmed') && $cgi->param('confirmed') !~ /^\d+$/;
     $confirmed = $1
@@ -34,24 +37,31 @@
 
     $did_order->confirmed($confirmed);
     $did_order->vendor_order_id($cgi->param('vendor_order_id'));
-    $error = $did_order->replace;
-    if ( $error ) {
-        $cgi->param('error', $error);
-        print $cgi->redirect(popurl(1). "did_order_confirm.html?". $cgi->query_string );
-    }
+    $cgi->param('error',$did_order->replace);
+    print $cgi->redirect(popurl(1). "did_order_confirm.html?". $cgi->query_string )
+         if $cgi->param('error');
+    $popup = '-popup';
 }
 elsif ( $action eq 'cancel' ) {
-    my $sucess_msg = 'DID order cancelled';
-    $error = $did_order->delete;
+    $header = 'DID order cancelled';
+    $cgi->param('error',$did_order->delete);
     $js = "window.location.href = '${p}browse/did_order.html'";
 }
 elsif ( $action eq 'provision' ) {
-    my $sucess_msg = 'DID order provisioned';
-    $cgi->param('pkgnum_svcpart') =~ /^(\d+)_(\d+)$/ or die 'illegal pkgnum_svcpart';
-    my $pkgnum = $1;
-    my $svcpart = $2;
+    $header = 'DID order provisioned';
     my @dids = qsearch( 'phone_avail', { ordernum => $ordernum } );
     die "no DIDs on order" unless scalar(@dids);
+    my @params = $cgi->param;
+    foreach my $param ( @params ) {
+        next unless $param =~ /^custnum(\d+)_pkgnum_svcpart$/;
+        my $custnum = $1;
+        my $value = $cgi->param($param);
+        next unless $value =~ /^(\d+)_(\d+)$/;
+        my $pkgnum = $1;
+        my $svcpart = $2;
+        if ( $did_order->custnum && $did_order->custnum == $custnum ) {
+        # this is our old per-order custnum case
+
     foreach my $did ( @dids ) {
         my $svc_phone = new FS::svc_phone({
             pkgnum  => $pkgnum,
@@ -59,9 +69,30 @@
             countrycode => 1,
             phonenum    => $did->npa.$did->nxx.$did->station,
         });
-        $error = $svc_phone->insert;
-        last if $error;
+                $cgi->param('error',$svc_phone->insert);
+                last if $cgi->param('error');
+            }
     }
+        # XXX: now what do we do for order items? Not clear how to match a DID in an order item
+    }
+    $popup = '-popup';
 }
+elsif ( $action eq 'merge' ) {
+    $header = 'DID order merged';
+    $cgi->param('target_ordernum') =~ /^(\d+)$/ or die 'illegal target_ordernum';
+    my $target_ordernum = $1;
+    my $target_did_order = qsearchs( {
+      'table'     => 'did_order',
+      'hashref'   => { 'ordernum' => $target_ordernum },
+    } );
+    die "No order $target_ordernum" unless $target_did_order;
+    $cgi->param('error',$target_did_order->merge($did_order));
+    $js = "window.location.href = '${p}browse/did_order.html'";
+}
+else { 
+    die "illegal action";
+}
+
+$header = 'Error' if $cgi->param('error');
 
 </%init>

Index: did_order_provision.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/did_order_provision.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- did_order_provision.html	17 Apr 2011 03:27:42 -0000	1.2
+++ did_order_provision.html	8 Jun 2011 05:37:38 -0000	1.3
@@ -5,27 +5,33 @@
 <FORM NAME="did_order_confirm" ACTION="<% popurl(1) %>did_order_confirmed.html" METHOD=POST>
 <INPUT TYPE="hidden" NAME="action" VALUE="provision">
 <INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
+
+
 <TABLE>
     <TR>    
-        <TD>Order #</TD>
-        <TD><% $ordernum %></TD>
+        <TH COLSPAN="2" ALIGN="LEFT">Order # <% $ordernum %></TH>
     </TR>
     <TR>    
-        <TD>Customer</TD>
-        <TD><% $cust_main->name %></TD>
+        <TH>Customer</TH>
+        <TH>Package/Service</TH>
+    </TR>
+% my $anyavail = 0;
+% foreach my $cust_main ( @cust_main ) {
+%  my($cust_pkg_phone,$cust_pkg_label,$svc_label) = possible_pkgs($cust_main);
+%  my $avail = keys(%$cust_pkg_phone);
+%  $anyavail = 1 if $avail;
     <TR>
-        <TD>Package/Service</TD>
+        <TD><% $cust_main->name %></TD>
         <TD>
 %           if ( !$avail ) {
-                No packages exist for this customer having at least <% scalar(@dids) %>
-                    unprovisioned DIDs, as required for this order.
+                No suitable packages exist for this customer.
 %           } else {
-           <SELECT NAME="pkgnum_svcpart">
-%           foreach my $pkgnum ( keys %cust_pkg_phone ) {
-%               my @svcpart = @{$cust_pkg_phone{$pkgnum}};
+           <SELECT NAME="custnum<%$cust_main->custnum%>_pkgnum_svcpart">
+%           foreach my $pkgnum ( keys %$cust_pkg_phone ) {
+%               my @svcpart = @{$cust_pkg_phone->{$pkgnum}};
 %               foreach my $svcpart ( @svcpart ) {
                     <OPTION value="<%"${pkgnum}_$svcpart"%>">
-                        <% $cust_pkg_label{$pkgnum} %> / <% $svc_label{$svcpart} %>
+                        <% $cust_pkg_label->{$pkgnum} %> / <% $svc_label->{$svcpart} %>
                     </OPTION>
 %               }
 %           }
@@ -33,10 +39,9 @@
 %           }
        </TD>
     </TR>
-%   if ( $avail ) {
-    <TR>
-        <TD COLSPAN="2"><INPUT TYPE="SUBMIT" value="Provision"></TD>
-    </TR>
+% }
+% if ( $anyavail ) {
+    <TR><TD COLSPAN="2"><INPUT TYPE="SUBMIT" value="Provision"></TD></TR>
 %  }
 </TABLE>
 
@@ -53,20 +58,22 @@
 } );
 die "No order $ordernum" unless $did_order;
 
-die "Order is not in received status and/or DIDs not assigned to a customer"
-    unless $did_order->received && $did_order->custnum; 
-
-my $cust_main = qsearchs('cust_main', { custnum => $did_order->custnum } );
-die "invalid customer" unless $cust_main;
+my @cust_main = $did_order->cust_main;
 
-my @pkgs = $cust_main->ncancelled_pkgs;
-die "no packages" unless scalar(@pkgs);
+die "Order is not in received status and/or DIDs not assigned to any customers"
+    unless $did_order->received && scalar(@cust_main);
 
 my @dids = qsearch( 'phone_avail', { ordernum => $ordernum } );
 die "no DIDs on order" unless scalar(@dids);
 
+sub possible_pkgs {
+    my $cust_main = shift;
+    
 my (%cust_pkg_phone, %cust_pkg_label, %svc_label );
 
+    my @pkgs = $cust_main->ncancelled_pkgs;
+    return (\%cust_pkg_phone,\%cust_pkg_label,\%svc_label) unless scalar(@pkgs);
+
 foreach my $pkg ( @pkgs ) {
     my @avail_part_svc = $pkg->available_part_svc;
     my @svcpart;
@@ -81,6 +88,7 @@
     $cust_pkg_label{$pkg->pkgnum} = $pkg->part_pkg->pkg;
 }
 
-my $avail = keys(%cust_pkg_phone);
+    (\%cust_pkg_phone,\%cust_pkg_label,\%svc_label);
+}
 
 </%init>



More information about the freeside-commits mailing list