stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / search / svc_phone.cgi
index 65aa1ae..4c0b654 100644 (file)
@@ -1,4 +1,4 @@
-<% include( 'elements/search.html',
+<& elements/svc_Common.html,
                  'title'             => "Phone number search results",
                  'name'              => 'phone numbers',
                  'query'             => $sql_query,
@@ -9,6 +9,7 @@
                                           'Country code',
                                           'Phone number',
                                           @header,
+                                          emt('Pkg. Status'),
                                           FS::UI::Web::cust_header($cgi->param('cust_fields')),
                                         ],
                  'fields'            => [ 'svcnum',
                                           'countrycode',
                                           'phonenum',
                                           @fields,
+                                          sub {
+                                            $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                            return '' unless $cust_pkg_cache{$_[0]->svcnum};
+                                            $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
+                                          },
                                           \&FS::UI::Web::cust_fields,
                                         ],
                  'links'             => [ $link,
                                           $link,
                                           $link,
                                           ( map '', @header ),
+                                          '', # pkg status
                                           ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
                                                 FS::UI::Web::cust_header($cgi->param('cust_fields'))
                                           ),
                                         ],
                  'align' => 'rlrr'.
                             join('', map 'r', @header).
+                            'r'.
                             FS::UI::Web::cust_aligns(),
                  'color' => [ 
                               '',
                               '',
                               '',
                               ( map '', @header ),
+                              sub {
+                                $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
+                                return '' unless $cust_pkg_cache{$_[0]->svcnum};
+                                my $c = FS::cust_pkg::statuscolors;
+                                $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
+                              }, # pkg status
                               FS::UI::Web::cust_colors(),
                             ],
                  'style' => [ 
                               '',
                               '',
                               ( map '', @header ),
+                              'b',
                               FS::UI::Web::cust_styles(),
                             ],
-              )
-%>
+              
+&>
 <%init>
 
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('List services');
 
+my %cust_pkg_cache;
+
 my $conf = new FS::Conf;
 
 my @select = ();
@@ -132,6 +149,9 @@ if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
 
 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
   $search_hash{'svcpart'} = [ $1 ];
+  if ( defined($cgi->param('cancelled')) ) {
+    $search_hash{'cancelled'} = $cgi->param('cancelled') ? 1 : 0;
+  }
 } else {
   $cgi->param('phonenum') =~ /^([\d\- ]+)$/; 
   my $phonenum = $1;