show un-configured ikano products, RT#7111
[freeside.git] / httemplate / view / qual.cgi
1 <% include("/elements/header.html","View Qualification") %>
2
3 % if ( $cust_or_prospect->get('custnum') ) {
4
5   <% include( '/elements/small_custview.html', $cust_or_prospect->custnum, '', 1,
6      "${p}view/cust_main.cgi") %>
7
8 % } elsif ( $cust_or_prospect->get('prospectnum') ) {
9 %       my $prospectnum = $cust_or_prospect->get('prospectnum');
10 %       my $link = "${p}view/prospect_main.html?$prospectnum";
11         <A HREF="<%$link%>">Prospect #<%$prospectnum%></A>
12 % }
13
14 <BR><BR>
15
16 <B>Qualification #<% $qual->qualnum %></B>
17 <% ntable("#cccccc", 2) %>
18 <% include('elements/tr.html', label => 'Status', value => $qual->status_long ) %>
19 <% include('elements/tr.html', label => 'Service Telephone Number', value => $qual->phonenum || '(none - dry loop)' ) %>
20 <% include('elements/tr.html', label => 'Address', value => $location_line ) %>
21 % if ( $location_kind ) {
22 <% include('elements/tr.html', label => 'Location Kind', value => $location_kind ) %>
23 % } if ( $export ) { 
24 <% include('elements/tr.html', label => 'Qualified using', value => $export->exportname ) %>
25 <% include('elements/tr.html', label => 'Vendor Qualification #', value => $qual->vendor_qual_id ) %>
26 % } 
27 </TABLE>
28 <BR><BR>
29
30 % if ( $export ) {
31 %  my $qual_result = $export->qual_result($qual);
32 %  if ($qual_result->{'header'}) {
33         <B><% $qual_result->{'header'} %></B>
34 %  }
35 %  if ($qual_result->{'pkglist'}) { # one of the possible formats
36 %   my $svcpart = '';
37 %   my $pkglist = $qual_result->{'pkglist'};
38 %   my $cust_or_prospect = $qual->cust_or_prospect;
39 %   my $locationnum = '';
40 %   my %location = $qual->location_hash;
41 %   if (%location && $location{'locationnum'}) { 
42 %      $locationnum = $location{'locationnum'};
43 %   }
44     <UL>
45 %       foreach my $pkgpart ( keys %$pkglist ) { 
46 %           my %opt = ( 'label' => $pkglist->{$pkgpart},
47 %                          'pkgpart' => $pkgpart,
48 %                          'locationnum' => $locationnum, );
49 %           if ( $export->exporttype eq 'ikano' ) {
50 %               my $pkg_svc = qsearchs('pkg_svc', { 'pkgpart' => $pkgpart,
51 %                                                 'primary_svc' => 'Y',
52 %                                               } );
53 %               $opt{'svcpart'} = $pkg_svc->svcpart if $pkg_svc;
54 %           }
55             <LI>
56 %               if($cust_or_prospect && $cust_or_prospect->custnum) {
57                    <% include('/view/cust_main/order_pkg_link.html', $qual->cust_or_prospect, %opt) %>
58 %               }
59 %               else {
60                     <% $opt{label} %>
61 %               }
62             </LI>
63 %       }
64     </UL>
65 %  }
66
67 %  my $not_avail = $qual_result->{'not_avail'};
68 %  if ( keys %$not_avail ) {
69      <BR>
70      Qualifying vendor packages (not yet configured in any package definition):
71      <% join(', ', map $not_avail->{$_}, keys %$not_avail ) |h %>
72 %  }
73
74 % }
75
76 <%init>
77
78 die "access denied"
79   unless $FS::CurrentUser::CurrentUser->access_right('Qualify service');
80
81 my $qualnum;
82 if ( $cgi->param('qualnum') ) {
83   $cgi->param('qualnum') =~ /^(\d+)$/ or die "unparsable qualnum";
84   $qualnum = $1;
85 } else {
86   my($query) = $cgi->keywords;
87   $query =~ /^(\d+)$/ or die "no qualnum";
88   $qualnum = $1;
89 }
90
91 my $qual = qsearchs('qual', { qualnum => $qualnum }) or die "invalid qualnum";
92 my $location_line = '';
93 my %location_hash = $qual->location_hash;
94 my $cust_location;
95 if ( %location_hash ) {
96     $cust_location = new FS::cust_location(\%location_hash);
97     $location_line = $cust_location->location_label;
98 }
99
100 my $location_kind;
101 $location_kind = "Residential" if $cust_location->get('location_kind') eq 'R';
102 $location_kind = "Business" if $cust_location->get('location_kind') eq 'B';
103
104 my $cust_or_prospect = $qual->cust_or_prospect;
105 my $export = $qual->part_export;
106
107 </%init>