X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fdid_order_provision.html;h=8739c161977dd4dee5a2fb20bcd3c9fcf4da6dc2;hp=8241121a80f0e5b30a440d427e69c66a1759298a;hb=11bbf29de447fe39e9d7155fe280a0df70fa8c3c;hpb=073169e80bea0560b64e468a76121bf837de34f3 diff --git a/httemplate/misc/did_order_provision.html b/httemplate/misc/did_order_provision.html index 8241121a8..8739c1619 100644 --- a/httemplate/misc/did_order_provision.html +++ b/httemplate/misc/did_order_provision.html @@ -5,27 +5,33 @@
+ + - - - + + - - - - + + + +% 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; + + -% if ( $avail ) { - - - -% } +% } +% if ( $anyavail ) { + +% }
Order #<% $ordernum %>
Order # <% $ordernum %>
Customer<% $cust_main->name %>
Package/ServiceCustomerPackage/Service
<% $cust_main->name |h %> % 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 { - +% foreach my $pkgnum ( keys %$cust_pkg_phone ) { +% my @svcpart = @{$cust_pkg_phone->{$pkgnum}}; % foreach my $svcpart ( @svcpart ) { % } % } @@ -33,11 +39,10 @@ % }
<%init> @@ -53,34 +58,37 @@ my $did_order = qsearchs( { } ); 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 = $did_order->cust_main; -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); +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); -my (%cust_pkg_phone, %cust_pkg_label, %svc_label ); +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; - 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; + 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; } - $cust_pkg_phone{$pkg->pkgnum} = \@svcpart if scalar(@svcpart); - $cust_pkg_label{$pkg->pkgnum} = $pkg->part_pkg->pkg; + + (\%cust_pkg_phone,\%cust_pkg_label,\%svc_label); } -my $avail = keys(%cust_pkg_phone); -