X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Finventory_item.html;h=1e7bdd91c858c730bb564326da32ac1e4bb7c9e7;hb=f731dc5a2bab0f3d04a43d7501257e18164bdcd8;hp=bd74f561902f3a48d5b79ad5921280df71d90611;hpb=6d2cd8e6fc566b4fccd0075156e3e1ddd59fa042;p=freeside.git diff --git a/httemplate/search/inventory_item.html b/httemplate/search/inventory_item.html index bd74f5619..1e7bdd91c 100644 --- a/httemplate/search/inventory_item.html +++ b/httemplate/search/inventory_item.html @@ -1,4 +1,80 @@ -<% +<% include( 'elements/search.html', + 'title' => $title, + + #less lame to use Lingua:: something to pluralize + 'name' => $inventory_class->classname. 's', + + 'query' => { + 'table' => 'inventory_item', + 'hashref' => { 'classnum' => $classnum }, + 'select' => join(', ', + 'inventory_item.*', + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), + ), + 'extra_sql' => $extra_sql, + 'addl_from' => $addl_from, + }, + + 'count_query' => $count_query, + + 'header' => [ + '#', + $inventory_class->classname, + 'Service', + FS::UI::Web::cust_header(), + ], + + 'fields' => [ + 'itemnum', + 'item', + #'svcnum', #XXX proper full service customer link ala svc_acct + # "unallocated" ? "available" ? + sub { + #this could be way more efficient with a mixin + # like cust_main_Mixin that let us all all the methods + # on data we already have... + my $inventory_item = shift; + my $cust_svc = $inventory_item->cust_svc; + if ( $cust_svc ) { + my($label, $value) = $cust_svc->label; + "$label: $value"; + } else { + '(available)'; + } + }, + + \&FS::UI::Web::cust_fields, + + ], + 'align' => 'rll'.FS::UI::Web::cust_aligns(), + 'links' => [ + '', + '', + $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('Configuration'); my $classnum = $cgi->param('classnum'); $classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum"; @@ -24,29 +100,26 @@ if ( $cgi->param('avail') ) { my $count_query = "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql"; -%><%= include( 'elements/search.html', - 'title' => $title, - - #less lame to use Lingua:: something to pluralize - 'name' => $inventory_class->classname. 's', +my $link = sub { + my $inventory_item = shift; + if ( $inventory_item->svcnum ) { + [ "${p}view/svc_acct.cgi?", 'svcnum' ]; + } else { + ''; + } +}; +my $link_cust = sub { + my $inventory_item = shift; + if ( $inventory_item->custnum ) { + [ "${p}view/cust_main.cgi?", 'custnum' ]; + } else { + ''; + } +}; - 'query' => { - 'table' => 'inventory_item', - 'hashref' => { 'classnum' => $classnum }, - 'extra_sql' => $extra_sql, - }, +my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. + ' LEFT JOIN part_svc USING ( svcpart ) '. + ' LEFT JOIN cust_pkg USING ( pkgnum ) '. + ' LEFT JOIN cust_main USING ( custnum ) '; - 'count_query' => $count_query, - - # XXX proper full service/customer link ala svc_acct - 'header' => [ '#', $inventory_class->classname, 'svcnum' ], - - 'fields' => [ - 'itemnum', - 'item', - 'svcnum', #XXX proper full service customer link ala svc_acct - # "unallocated" ? "available" ? - ], - - ) -%> +