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

Erik Levinson levinse at wavetail.420.am
Sat Apr 16 20:27:44 PDT 2011


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

Modified Files:
	did_order_confirmed.html did_order_provision.html 
Log Message:
bulk DID orders/inventory enhancements, RT11291

Index: did_order_confirmed.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/did_order_confirmed.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- did_order_confirmed.html	15 Apr 2011 03:04:12 -0000	1.2
+++ did_order_confirmed.html	17 Apr 2011 03:27:42 -0000	1.3
@@ -8,7 +8,7 @@
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Import');
 
-$cgi->param('action') =~ /^(confirm|cancel)$/ or die 'illegal action';
+$cgi->param('action') =~ /^(confirm|cancel|provision)$/ or die 'illegal action';
 my $action = $1;
 my $success_msg = '';
 my $error = '';
@@ -45,4 +45,23 @@
     $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;
+    my @dids = qsearch( 'phone_avail', { ordernum => $ordernum } );
+    die "no DIDs on order" unless scalar(@dids);
+    foreach my $did ( @dids ) {
+        my $svc_phone = new FS::svc_phone({
+            pkgnum  => $pkgnum,
+            svcpart => $svcpart,
+            countrycode => 1,
+            phonenum    => $did->npa.$did->nxx.$did->station,
+        });
+        $error = $svc_phone->insert;
+        last if $error;
+    }
+}
+
 </%init>

Index: did_order_provision.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/did_order_provision.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- did_order_provision.html	15 Apr 2011 03:04:12 -0000	1.1
+++ did_order_provision.html	17 Apr 2011 03:27:42 -0000	1.2
@@ -11,8 +11,33 @@
         <TD><% $ordernum %></TD>
     </TR>
     <TR>
+        <TD>Customer</TD>
+        <TD><% $cust_main->name %></TD>
+    <TR>
+        <TD>Package/Service</TD>
+        <TD>
+%           if ( !$avail ) {
+                No packages exist for this customer having at least <% scalar(@dids) %>
+                    unprovisioned DIDs, as required for this order.
+%           } else {
+           <SELECT NAME="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} %>
+                    </OPTION>
+%               }
+%           }
+           </SELECT>
+%           }
+       </TD>
+    </TR>
+%   if ( $avail ) {
+    <TR>
         <TD COLSPAN="2"><INPUT TYPE="SUBMIT" value="Provision"></TD>
     </TR>
+%  }
 </TABLE>
 
 <%init>
@@ -31,5 +56,31 @@
 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 @pkgs = $cust_main->ncancelled_pkgs;
+die "no packages" unless scalar(@pkgs);
+
+my @dids = qsearch( 'phone_avail', { ordernum => $ordernum } );
+die "no DIDs on order" unless scalar(@dids);
+
+my (%cust_pkg_phone, %cust_pkg_label, %svc_label );
+
+foreach my $pkg ( @pkgs ) {
+    my @avail_part_svc = $pkg->available_part_svc;
+    my @svcpart;
+    foreach my $avail_part_svc ( @avail_part_svc ) {
+        if ($avail_part_svc->svcdb eq 'svc_phone'
+                  && $avail_part_svc->num_avail >= scalar(@dids)) {
+            push @svcpart, $avail_part_svc->svcpart;
+            $svc_label{$avail_part_svc->svcpart} = $avail_part_svc->svc;
+        }
+    }
+    $cust_pkg_phone{$pkg->pkgnum} = \@svcpart if scalar(@svcpart);
+    $cust_pkg_label{$pkg->pkgnum} = $pkg->part_pkg->pkg;
+}
+
+my $avail = keys(%cust_pkg_phone);
 
 </%init>



More information about the freeside-commits mailing list