diff options
author | ivan <ivan> | 2006-03-08 12:14:04 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-03-08 12:14:04 +0000 |
commit | 6d2cd8e6fc566b4fccd0075156e3e1ddd59fa042 (patch) | |
tree | 5c08fa887aca0ca1b19adb009d06e4beb85a56b6 /httemplate/search | |
parent | 600a0939e7e7e589dae4f4f5bfef3650728940b7 (diff) |
Add an option to the web interface to batch upload new entries to the
inventory_item table.
Diffstat (limited to 'httemplate/search')
-rw-r--r-- | httemplate/search/inventory_class.html | 49 | ||||
-rw-r--r-- | httemplate/search/inventory_item.html | 25 |
2 files changed, 61 insertions, 13 deletions
diff --git a/httemplate/search/inventory_class.html b/httemplate/search/inventory_class.html index 1bf1bcbce..37735f3c9 100644 --- a/httemplate/search/inventory_class.html +++ b/httemplate/search/inventory_class.html @@ -5,11 +5,18 @@ tie my %labels, 'Tie::IxHash', 'num_used' => 'In use', #'Used', #'Allocated', 'num_total' => 'Total', ; -my %inv_action_link = ( - 'num_avail' => 'eventually' + +my %link = ( + 'num_avail' => ';avail=1', + 'num_used' => ';avail=1', + 'num_total' => '', ); -my %inv_action_label = ( - 'num_avail' => 'upload_batch' + +my %inv_action_link = ( + 'num_avail' => [ 'upload batch', + $p.'misc/inventory_item-import.html?classnum=', + 'classnum' + ], ); my $link = [ "${p}edit/inventory_class.html?", 'classnum' ]; @@ -29,20 +36,44 @@ my $link = [ "${p}edit/inventory_class.html?", 'classnum' ]; #my $inventory_class = shift; my $i_c = shift; + my $link = + $p. 'search/inventory_item.html?'. + 'classnum='. $i_c->classnum; + + my %actioncol = (); + foreach ( keys %inv_action_link ) { + my($label, $baseurl, $method) = + @{ $inv_action_link{$_} }; + my $url = $baseurl. $i_c->$method(); + $actioncol{$_} = + '<FONT SIZE="-1">'. + '('. + '<A HREF="'.$url.'">'. + $label. + '</A>'. + ')'. + '</FONT>'; + } + + my %num = map { + $_ => $i_c->$_(); + } keys %labels; + [ map { [ { - 'data' => '<B>'. $i_c->$_(). '</B>', + 'data' => '<B>'. $num{$_}. '</B>', 'align' => 'right', }, { 'data' => $labels{$_}, 'align' => 'left', - }, - { 'data' => ( exists($inv_action_link{$_}) - ? '<FONT SIZE="-1">(<A HREF="'. $inv_action_link{$_}. '">'. $inv_action_label{$_}. '</A>)</FONT>' - : '' + 'link' => ( $num{$_} + ? $link.$link{$_} + : '' ), + }, + { 'data' => $actioncol{$_}, 'align' => 'left', }, ] diff --git a/httemplate/search/inventory_item.html b/httemplate/search/inventory_item.html index ff7f1fadf..bd74f5619 100644 --- a/httemplate/search/inventory_item.html +++ b/httemplate/search/inventory_item.html @@ -1,15 +1,31 @@ <% my $classnum = $cgi->param('classnum'); -$classnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; +$classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum"; $classnum = $1; -my $inventory_class = qsearchs('inventory_class', { 'classnum' => $classnum } ); + +my $inventory_class = qsearchs( { + 'table' => 'inventory_class', + 'hashref' => { 'classnum' => $classnum }, +} ); + +my $title = $inventory_class->classname. ' Inventory'; + +#little false laziness with SQL fragments in inventory_class.pm +my $extra_sql = ''; +if ( $cgi->param('avail') ) { + $extra_sql = 'AND ( svcnum IS NULL OR svcnum = 0 )'; + $title .= ' - Available'; +} elsif ( $cgi->param('used') ) { + $extra_sql = 'AND svcnum IS NOT NULL AND svcnum > 0'; + $title .= ' - In use'; +} my $count_query = - "SELECT COUNT(*) FROM inventory_class WHERE classnum = $classnum"; + "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql"; %><%= include( 'elements/search.html', - 'title' => $inventory_class->classname. ' Inventory', + 'title' => $title, #less lame to use Lingua:: something to pluralize 'name' => $inventory_class->classname. 's', @@ -17,6 +33,7 @@ my $count_query = 'query' => { 'table' => 'inventory_item', 'hashref' => { 'classnum' => $classnum }, + 'extra_sql' => $extra_sql, }, 'count_query' => $count_query, |