From 073169e80bea0560b64e468a76121bf837de34f3 Mon Sep 17 00:00:00 2001 From: levinse Date: Sun, 17 Apr 2011 03:27:42 +0000 Subject: bulk DID orders/inventory enhancements, RT11291 --- httemplate/misc/did_order_provision.html | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'httemplate/misc/did_order_provision.html') diff --git a/httemplate/misc/did_order_provision.html b/httemplate/misc/did_order_provision.html index b0c7210b7..8241121a8 100644 --- a/httemplate/misc/did_order_provision.html +++ b/httemplate/misc/did_order_provision.html @@ -10,9 +10,34 @@ Order # <% $ordernum %> + + Customer + <% $cust_main->name %> + + Package/Service + +% if ( !$avail ) { + No packages exist for this customer having at least <% scalar(@dids) %> + unprovisioned DIDs, as required for this order. +% } else { + +% } + + +% if ( $avail ) { +% } <%init> @@ -31,5 +56,31 @@ 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 @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); -- cgit v1.2.1