5e706a18dbdb91e7e1767cc906304c3fea229a09
[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
68 <%init>
69
70 die "access denied"
71   unless $FS::CurrentUser::CurrentUser->access_right('Qualify service');
72
73 my $qualnum;
74 if ( $cgi->param('qualnum') ) {
75   $cgi->param('qualnum') =~ /^(\d+)$/ or die "unparsable qualnum";
76   $qualnum = $1;
77 } else {
78   my($query) = $cgi->keywords;
79   $query =~ /^(\d+)$/ or die "no qualnum";
80   $qualnum = $1;
81 }
82
83 my $qual = qsearchs('qual', { qualnum => $qualnum }) or die "invalid qualnum";
84 my $location_line = '';
85 my %location_hash = $qual->location_hash;
86 my $cust_location;
87 if ( %location_hash ) {
88     $cust_location = new FS::cust_location(\%location_hash);
89     $location_line = $cust_location->location_label;
90 }
91
92 my $location_kind;
93 $location_kind = "Residential" if $cust_location->get('location_kind') eq 'R';
94 $location_kind = "Business" if $cust_location->get('location_kind') eq 'B';
95
96 my $cust_or_prospect = $qual->cust_or_prospect;
97 my $export = $qual->part_export;
98
99 </%init>