X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fphone_avail.html;h=1335379ae107466337509c5aedf251f640d81b1b;hb=d8299144d2175f1695adafe29e9549bd9b158e2f;hp=2388d25fffee2a34fd3a5c2794950e0cf4b7e8fc;hpb=40a7b3dc653e099f7bd0bd762b649b04c4432db2;p=freeside.git diff --git a/httemplate/search/phone_avail.html b/httemplate/search/phone_avail.html index 2388d25ff..1335379ae 100644 --- a/httemplate/search/phone_avail.html +++ b/httemplate/search/phone_avail.html @@ -3,7 +3,7 @@ 'name_singular' => 'phone number', 'query' => { 'table' => 'phone_avail', - 'hashref' => {}, + 'hashref' => $hashref, 'select' => join(', ', 'phone_avail.*', 'cust_main.custnum', @@ -16,6 +16,8 @@ 'header' => [ '#', 'State', 'Phone Number', + 'Rate Center', + 'Batch', 'Export', 'Service', FS::UI::Web::cust_header(), @@ -27,50 +29,90 @@ '+'. $pn->countrycode. ' '. $pn->npa. ' '. $pn->nxx. '-'. $pn->station; }, - 'exportnum', #XXX - #sub { }, - 'svcnum', #XXX + sub { shift->get('name') }, + 'availbatch', + sub { + my $pa = shift; + return '' unless $pa->part_export; + $pa->part_export->exportname; + }, + sub { + my $pa = shift; + return '' unless $pa->cust_svc; + my($label,$value) = $pa->cust_svc->label; + $label . ": " . $value; + }, \&FS::UI::Web::cust_fields, + '', ], - 'align' => 'rllll'.FS::UI::Web::cust_aligns(), + 'align' => 'rllllllc'.FS::UI::Web::cust_aligns(), 'links' => [ '', '', + '', + '', '', - '', #XXX #$export_link - '', #XXX #$svc_link + '', #XXX #$export_link - to what exactly? + $svc_link, ( map { $_ ne 'Cust. Status' ? $link_cust : '' } FS::UI::Web::cust_header() ), + '', ], 'color' => [ '', '', + '', + '', '', '', '', FS::UI::Web::cust_colors(), + '', ], 'style' => [ '', '', + '', + '', '', '', '', FS::UI::Web::cust_styles(), + '', ], ) %> <%init> die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Import'); + unless ( $FS::CurrentUser::CurrentUser->access_right('List inventory') + ); my @search = (); -if ( $cgi->param('availbatch') =~ /^([\w\/\:\-\.]+)$/ ) { - push @search, "availbatch = '$1'"; -} +push @search, "availbatch = '$1'" + if ( $cgi->param('availbatch') =~ /^([\w\d \/\:\-\.]+)$/ ); + +push @search, "countrycode = '$1'" + if ( $cgi->param('countrycode') =~ /^(\d{1,3})$/ ); + +push @search, "phone_avail.state = '$1'" + if ( $cgi->param('state') =~ /^(\w{2})$/ ); + +# i know that the regexps match more than NPA/NXX, but this is good enough now +push @search, "npa = '$1'" + if ( $cgi->param('npa') =~ /^(\d{3})$/ ); +push @search, "nxx = '$1'" + if ( $cgi->param('npa') =~ /^\d{3}$/ && $cgi->param('nxx') =~ /^(\d{3})$/ ); + +push @search, "name = '$1'" + if ( $cgi->param('ratecenter') =~ /^([\w \-\.]+)$/ ); + +push @search, "svcnum is null" + if ( $cgi->param('avail_status') eq 'AVAIL' ); +push @search, "svcnum is not null" + if ( $cgi->param('avail_status') eq 'UNAVAIL' ); # #here is the agent virtualization # push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; @@ -87,10 +129,13 @@ my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. my $count_query = "SELECT COUNT(*) FROM phone_avail $search"; #$addl_from? +my $hashref = {}; +$hashref->{'ordernum'} = $1 if $cgi->param('ordernum') =~ /^(\d+)$/; + my $link_cust = sub { my $phone_avail = shift; if ( $phone_avail->svcnum ) { - my $cust_svc = $phone_avail->svc_phone->cust_svc; + my $cust_svc = $phone_avail->cust_svc; if ( $cust_svc->pkgnum ) { #my $cust_main = $cust_svc->cust_pkg->cust_main; return [ "${p}view/cust_main.cgi?", 'custnum' ]; @@ -99,4 +144,13 @@ my $link_cust = sub { ''; }; +my $svc_link = sub { + my $phone_avail = shift; + my $cust_svc = $phone_avail->cust_svc; + if ( $cust_svc ) { + return [ "${p}view/svc_phone.cgi?", 'svcnum']; + } + ''; +}; +