X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fdid_order_provision.html;h=8739c161977dd4dee5a2fb20bcd3c9fcf4da6dc2;hp=b0c7210b7f36308d4b56b7c358adda811842fa58;hb=11bbf29de447fe39e9d7155fe280a0df70fa8c3c;hpb=59be9ba7caf1009a97af97156bbd700bffb18fd4 diff --git a/httemplate/misc/did_order_provision.html b/httemplate/misc/did_order_provision.html index b0c7210b7..8739c1619 100644 --- a/httemplate/misc/did_order_provision.html +++ b/httemplate/misc/did_order_provision.html @@ -5,14 +5,44 @@
+ + - - - + + - + + + +% 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 ( $anyavail ) { + +% }
Order #<% $ordernum %>
Order # <% $ordernum %>
CustomerPackage/Service
<% $cust_main->name |h %> +% if ( !$avail ) { + No suitable packages exist for this customer. +% } else { + +% } +
<%init> @@ -28,8 +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; + +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; + 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,\%cust_pkg_label,\%svc_label); +}