1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<% include('/elements/header-popup.html', 'Bulk DID order - DID provisioning' ) %>
<% include('/elements/error.html') %>
<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>
<TH COLSPAN="2" ALIGN="LEFT">Order # <% $ordernum %></TH>
</TR>
<TR>
<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><% $cust_main->name |h %></TD>
<TD>
% if ( !$avail ) {
No suitable packages exist for this customer.
% } else {
<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} %>
</OPTION>
% }
% }
</SELECT>
% }
</TD>
</TR>
% }
% if ( $anyavail ) {
<TR><TD COLSPAN="2"><INPUT TYPE="SUBMIT" value="Provision"></TD></TR>
% }
</TABLE>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
$cgi->param('ordernum') =~ /^(\d+)$/ or die 'illegal ordernum';
my $ordernum = $1;
my $did_order = qsearchs( {
'table' => 'did_order',
'hashref' => { 'ordernum' => $ordernum },
} );
die "No order $ordernum" unless $did_order;
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);
}
</%init>
|